django、subprocess多进程 报错django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 5C

在django程序中,使用了subprocess多进程,代码如下。

#开始启动进程去处理业务 使用跨平台的多进程库subprocess
    PYTHON = sys.executable
    shell_cmd = '"%s" -m supportchannel.wechat_servers.wechatProcess %s' % (PYTHON, userKey) #let servers be a package
    cmd = shlex.split(shell_cmd)
    try:
        child = subprocess.Popen(args=cmd, shell=False)

程序在运行的时候报错django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 感觉是subprocess的多进程无法和djangoapp通讯,求解决方法。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
django连接MySQL报错django.db.utils.OperationalError: (2006, <NULL>)?

最近想学django,于是照着Django官方文档一步步学,没想到刚到连接数据库,就卡了。 在pycharm上通过django连接MySQL报如图所示错误![图片说明](https://img-ask.csdn.net/upload/201908/25/1566734912_878477.png)![图片说明](https://img-ask.csdn.net/upload/201908/25/1566734921_243846.png)![图片说明](https://img-ask.csdn.net/upload/201908/25/1566734929_53248.png) 网上搜索,试了各种方法,包括改hosts文件和HOST改成127.0.0.1,都不成功。把下面这几行代码注释掉,换成原来的sqlite,就可以成功运行,实在不知道什么原因,请各位大佬帮忙看下怎么解决。 环境:Django2.2.1、MySql8.0 下面是我的setting.py文件。一开始pycharm也连不上Mysql,我改了他的时区,Asia/Shanghai,就可以了,但是Django怎么也连不上 ``` """ Django settings for webProject project. Generated by 'django-admin startproject' using Django 2.2.1. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'uri0z)r@kn3p)l%6(9if)1$74kv9ag$p@zadp_p$ph_x0(v9h=' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'webProject.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')] , 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'webProject.wsgi.application' # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases # DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # } # } DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'webcrawler', 'USER': 'root', 'PASSWORD': '111111', 'HOST': 'localhost', 'PORT': '3306', } } # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' ```

Django migrate的时候报错

migration可以,但执行migrate的时候就报错 models.py ``` class Category(models.Model): name = models.CharField('名称', max_length=16) class Tag(models.Model): name = models.CharField('名称', max_length=16) class Article(models.Model): title = models.CharField(max_length=32, default='Title') content = models.TextField(null=True) pub_time = models.DateTimeField(auto_now_add=True) author = models.CharField(max_length=16, default='Author') category = models.ForeignKey(Category, verbose_name='分类', default='Category') tags = models.ManyToManyField(Tag, verbose_name='标签') def __unicode__(self): return self.title class Comment(models.Model): blog = models.ForeignKey(Article, verbose_name='博客') name = models.CharField('称呼', max_length=16) email = models.EmailField('邮箱') content = models.CharField('内容', max_length=140) created = models.DateTimeField('发布时间', auto_now_add=True) ``` 下面是报错信息![图片说明](https://img-ask.csdn.net/upload/201804/07/1523113359_702807.png) 感觉可能是版本问题但是又不知道是哪的错,把Category的语句注释了也不行,求大神帮忙解答,感谢!

Django已有的model表新增字段,执行migrate报错:django.db.utils.DatabaseError:ORA-00955: name is already used by an existing object,出现重名是啥情况。。。

Django已有的model表新增字段,执行migrate报错:django.db.utils.DatabaseError:ORA-00955: name is already used by an existing object,出现重名是啥情况。。。

django创建项目时,urls.py报错:No module named 'index.urls'

django创建音乐网站项目时,urls.py写入代码后,pycharm一直报错: No module named 'index.urls' 用idle运行时候就报错: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. 创建过程中只修改了urls.py 和setting.py 文件 代码如下: [b]urls.py[/b] from django.contrib import admin from django.urls import path, include from django.conf.urls import url from django.views import static from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), path('', include('index.urls')), path('ranking.html', include('ranking.urls')), path('play/', include('play.urls')), path('comment/', include('comment.urls')), path('search/', include('search.urls')), path('user/', include('user.urls')), ] [b]settings.py[/b] (部分代码) INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'index', 'ranking', 'user', 'play', 'search', 'comment', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', # 使用中文 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'music.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'index/templates'), os.path.join(BASE_DIR, 'ranking/templates'), os.path.join(BASE_DIR, 'user/templates'), os.path.join(BASE_DIR, 'play/templates'), os.path.join(BASE_DIR, 'comment/templates'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'music.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'music_db', 'USER': 'root', 'PASSWORD': '1234', 'HOST': '127.0.0.1', 'POST': '3306', } } 请问这种情况该如何处理呢?求指点

Django执行python manage.py makemigrations 报错,数据库是postgresql,大神救救孩子

Traceback (most recent call last): File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection self.connect() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 197, in connect self.connection = self.get_new_connection(conn_params) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection connection = Database.connect(**conn_params) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\psycopg2\__init__.py", line 126, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\core\management\base.py", line 369, in execute output = self.handle(*args, **options) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\core\management\base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\core\management\commands\makemigrations.py", line 101, in handle loader.check_consistent_history(connection) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\migrations\loader.py", line 283, in check_consistent_history applied = recorder.applied_migrations() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\migrations\recorder.py", line 76, in applied_migrations if self.has_table(): File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 260, in cursor return self._cursor() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 236, in _cursor self.ensure_connection() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection self.connect() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection self.connect() File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\base\base.py", line 197, in connect self.connection = self.get_new_connection(conn_params) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection connection = Database.connect(**conn_params) File "D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\psycopg2\__init__.py", line 126, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError

Django配置MySQL,运行python manage.py startapp myapp 报错!!

python manage.py startapp myapp Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 357, in execute django.setup() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\auth\models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 117, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 321, in add_to_class value.contribute_to_class(cls, name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\options.py", line 204, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\__init__.py", line 28, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 201, in __getitem__ backend = load_backend(db['ENGINE']) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 110, in load_backend return import_module('%s.base' % backend_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 36, in <module> raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. da

django刚入门,创建博客的时候出现这个错误,求解决

![图片说明](https://img-ask.csdn.net/upload/201904/01/1554112752_11759.png) ![图片说明](https://img-ask.csdn.net/upload/201904/01/1554112854_18340.png) 具体代码如下 html文件应该没错 views.py: from django.shortcuts import render # Create your views here. from django.template import loader,Context from django.http import HttpResponse from blog.models import BlogPost def archive(request): posts = BlogPost.objects.all(); #@UndefinedVariable t = loader.get_template('archive.html') c = Context({'posts': posts}) return HttpResponse(t.render(c)) models.py: from django.db import models from django.contrib import admin # Create your models here. class BlogPost(models.Model): title = models.CharField(max_length = 150) content = models.TextField() timestamp = models.DateTimeField() class BlogPostAdmin(admin.ModelAdmin): list_display = ('title', 'content', 'timestamp') admin.site.register(BlogPost, BlogPostAdmin) settings.py: TEMPLATE_DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog' ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', ) ROOT_URLCONF = 'wangxiran.urls' WSGI_APPLICATION = 'wangxiran.wsgi.application' # Database # https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME':'wangxiran', 'USER':'root', 'PASSWORD':'Aa123456', 'HOST':'127.0.0.1', 'POST':'3306', } } # Internationalization # https://docs.djangoproject.com/en/dev/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/dev/howto/static-files/ STATIC_URL = '/static/' urls.py: from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() from blog.views import archive urlpatterns = patterns('', # Examples: # url(r'^$', 'wangxiran.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^blog/', archive), ) 照着网上教材做的 但是就是出不来啊 求大佬们帮帮

Django连接数据库报错,Connection to db failed

连接MySQL报错了,问题出在哪呢,求大佬指点 Connection to db failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

django中 django.db.utils.ProgrammingError: (1146, "Table 'xxx' doesn't exist")的问题

新上手django,为了测试,对其中一个app 进行了 很多次 makemigrations 和 migrate(主要是做了数据库的变更),现在报错, 显示django.db.utils.ProgrammingError: (1146, "Table 'xxx' doesn't exist") 如下图所示: ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814038_212243.png) 但是这个表明明存在:如下图所示: ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814070_231776.png) 以下为makemigrations的信息: 001initial.py ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814223_588095.png) 002.py ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814296_762669.png) 003.py ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814308_915151.png) 004.py ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814322_193149.png) 005.py ![图片说明](https://img-ask.csdn.net/upload/201812/26/1545814330_536118.png) 第二个问题: 其中还有几次报错是 1054 Unknown column ‘tableName.id' in 'field list' 但是表中并没有id这个字段,是什么原因呢? 是不是这个app的model没有映射到相应的数据表呢?

Django报错:django.server:"GET /favicon.ico HTTP/1.1" 500 59,该如何解决?

搭建完HttpRunnerManager环境后进行接口的调试,运行用例时页面报错: A server error occurred. Please contact the administrator. ![图片说明](https://img-ask.csdn.net/upload/201908/14/1565747464_929466.jpg) 返回用例页面收到提示: ![图片说明](https://img-ask.csdn.net/upload/201908/14/1565747577_116158.jpg) 点击确定后页面依旧是500报错,和图一相同,刷新页面也无济于事 ![图片说明](https://img-ask.csdn.net/upload/201908/14/1565747927_436972.jpg) dos命令窗口关于django服务的报错: ![图片说明](https://img-ask.csdn.net/upload/201908/14/1565748112_123790.jpg) 分别查询了前台和后台的错误解决办法,发现前台错误和其他人的原因不同,后台django的错误实在搜不到详细的内容,本人也是初次接触这套框架,对django的报错没有头绪,希望有大佬帮忙分析一下原因所在,万分感谢。

python3 django models 调用出错

![图片说明](https://img-ask.csdn.net/upload/201708/08/1502160029_39827.png)![![图片说明](https://img-ask.csdn.net/upload/201708/08/1502159234_483138.png)图片说明](https://img-ask.csdn.net/upload/201708/08/1502159219_209781.png)[参考连接](http://www.runoob.com/django/django-model.html "demo") # models.py from django.db import models class Test(models.Model): name = models.CharField(max_length=20) #testdb.py from django.http import HttpResponse from TestModel.models import Test # 数据库操作 def testdb(request): test1 = Test(name='runoob') test1.save() return HttpResponse("<p>数据添加成功!</p>") 报错:ModuleNotFoundError: No module named 'Test'

django安装后使用 mange.py错误,求解

在ubuntu下安装了django 1.9, 使用manage.py时有报错:(python版本为2.7和3.4) 比如./manage.py runserver 8888 ``` fenice@fenice:~/WorkSpace/django/mysite$ ./manage.py startapp blog Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/core/management/__init__.py", line 331, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/core/management/__init__.py", line 305, in execute django.setup() File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/apps/registry.py", line 115, in populate app_config.ready() File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/admin/apps.py", line 22, in ready self.module.autodiscover() File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/admin/__init__.py", line 26, in autodiscover autodiscover_modules('admin', register_to=site) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/utils/module_loading.py", line 50, in autodiscover_modules import_module('%s.%s' % (app_config.name, module_to_search)) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/admin.py", line 7, in <module> from django.contrib.auth.forms import ( File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/forms.py", line 259, in <module> class SetPasswordForm(forms.Form): File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/forms.py", line 269, in SetPasswordForm help_text=password_validation.password_validators_help_text_html()) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/password_validation.py", line 85, in password_validators_help_text_html help_texts = password_validators_help_texts(password_validators) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/password_validation.py", line 74, in password_validators_help_texts password_validators = get_default_password_validators() File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/utils/lru_cache.py", line 101, in wrapper result = user_function(*args, **kwds) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/password_validation.py", line 21, in get_default_password_validators return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/password_validation.py", line 32, in get_password_validators validators.append(klass(**validator.get('OPTIONS', {}))) File "/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/password_validation.py", line 164, in __init__ with open(password_list_path) as f: IOError: [Errno 2] No such file or directory: u'/usr/local/lib/python2.7/dist-packages/Django-1.9.dev20150709131027-py2.7.egg/django/contrib/auth/common-passwords.txt.gz' ```

在VS2017里开发Django项目,在views.py里写中文时提示编码错误

``` """ Definition of views. """ # -*- coding: UTF-8 -*- from django.shortcuts import render from django.http import HttpRequest from django.template import RequestContext from datetime import datetime def home(request): """Renders the home page.""" assert isinstance(request, HttpRequest) return render( request, 'app/index.html', { 'title':'主页', 'year':datetime.now().year, } ) ``` 然后Views.py没有报错,但是urls.py报错了,这是为什么? ![图片说明](https://img-ask.csdn.net/upload/201903/07/1551943208_493451.png)

django项目 makemigrations时出现nodenotfounderror错误。

如题 makemigrations时出现 django.db.migrations.graph.NodeNotFoundError: Migration blog.0001_initial dependencies reference nonexistent parent node (u'auth', u'0007_alter_validators_add_error_messages')错误 求大家解答! 问题源文件: # -*- coding: utf-8 -*- # Generated by Django 1.9 on 2016-02-24 10:34 from __future__ import unicode_literals import blog.models from django.conf import settings import django.contrib.auth.models import django.core.validators from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ('tagging', '0001_initial'), ('auth', '0007_alter_validators_add_error_messages'), ] operations = [ migrations.CreateModel( name='User', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=30, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.')], verbose_name='username')), ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), ('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')), ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('name', models.CharField(max_length=12)), ('avatar_path', models.ImageField(default='/static/image/avatar_default.jpg', upload_to='/avatar')), ], options={ 'abstract': False, 'verbose_name': 'user', 'verbose_name_plural': 'users', }, managers=[ ('objects', django.contrib.auth.models.UserManager()), ], ), migrations.CreateModel( name='Carousel', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=100)), ('img', models.ImageField(upload_to='/carousel')), ('create_time', models.DateTimeField(auto_now_add=True)), ], options={ 'ordering': ['-create_time'], }, ), migrations.CreateModel( name='Catalogue', fields=[ ('name', models.CharField(max_length=20, primary_key=True, serialize=False)), ], ), migrations.CreateModel( name='Comment', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('publish_Time', models.DateTimeField(auto_now_add=True)), ('ip_address', models.GenericIPAddressField()), ('content', models.CharField(max_length=200)), ('isDelete', models.BooleanField(default=False)), ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( name='Editor', fields=[ ('name', models.CharField(max_length=20, primary_key=True, serialize=False)), ('avaliable', models.BooleanField(default=True)), ], ), migrations.CreateModel( name='Post', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=100)), ('publish_time', models.DateTimeField(auto_now_add=True)), ('modify_time', models.DateTimeField(auto_now_add=True)), ('content', models.TextField()), ('tag', blog.models.TagField_Mine(blank=True, max_length=255)), ('view_count', models.IntegerField(default=0, editable=False)), ('status', models.SmallIntegerField(choices=[(0, '\u8349\u7a3f'), (1, '\u53d1\u5e03'), (2, '\u5220\u9664')], default=0)), ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ('catalogue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='blog.Catalogue')), ('editor_choice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='blog.Editor')), ], options={ 'ordering': ['-modify_time'], }, ), migrations.CreateModel( name='Repository', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=100)), ('publish_time', models.DateTimeField(auto_now_add=True)), ('author', models.CharField(max_length=20)), ('content', models.TextField()), ('view_count', models.IntegerField(default=0, editable=False)), ('tag', models.ManyToManyField(blank=True, default='', to='tagging.Tag')), ], options={ 'ordering': ['-publish_time'], }, ), migrations.AddField( model_name='comment', name='post', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='blog.Post'), ), migrations.AddField( model_name='carousel', name='post', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='blog.Post'), ), migrations.AddField( model_name='user', name='editor_choice', field=models.ForeignKey(blank=True, default='tinyMCE', null=True, on_delete=django.db.models.deletion.CASCADE, to='blog.Editor'), ), migrations.AddField( model_name='user', name='groups', field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups'), ), migrations.AddField( model_name='user', name='user_permissions', field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'), ), ]

初学django报错,views.py中一个path有两个函数

代码如下: views.py: ![图片说明](https://img-ask.csdn.net/upload/201901/09/1547010639_909597.png) urls.py:![图片说明](https://img-ask.csdn.net/upload/201901/09/1546998870_922609.png) 报错: ![图片说明](https://img-ask.csdn.net/upload/201901/09/1546998986_991158.png) 因为这是 两个 功能,所以写了 两个function,但是urls里的参数有只能写一个view,这两个function我应该怎么改? 还请大神帮忙看看错误 谢谢

<python从入门到实践>19章书中只给topic设定了owner,但是entry没有出现了报错django.db.utils.OperationalError: no such column: learning_logs_entry.owner_id

我用改topic的方法改了new_entry,也没有行通。 views.py ``` from django.shortcuts import render from django.http import HttpResponseRedirect from django.urls import reverse from .models import Topic,Entry from .forms import TopicForm,EntryForm from django.contrib.auth.decorators import login_required def index(request): #学习笔记的主页 return render(request,'learning_logs/index.html') @login_required def topics(request): #显示所有的主题 topics = Topic.objects.filter(owner=request.user).order_by('date_added') context = {'topics':topics} return render(request,'learning_logs/topics.html',context) @login_required def topic(request,topic_id): #显示单个主题及其所有的项目 topic = Topic.objects.filter(owner=request.user).get(id = topic_id) #确认请求的主题属于当前用户 if topic.owner != request.user: raise Http404 entries = topic.entry_set.order_by('-date_added') context = {'topic':topic,'entries':entries} return render(request,'learning_logs/topic.html',context) @login_required def new_topic(request): '''添加新主题''' if request.method != 'POST': #未提交数据 创建一个新表单 form = TopicForm() else: #POST提交的数据 对数据进行处理 form = TopicForm(request.POST) if form.is_valid(): new_topic = form.save(commit=False) new_topic.owner = request.user new_topic.save() return HttpResponseRedirect(reverse('learning_logs:topics')) context = {'form':form} return render(request, 'learning_logs/new_topic.html',context) @login_required def new_entry(request,topic_id): topic = Topic.objects.get(id=topic_id) if request.method != 'POST': form = EntryForm() else: form = EntryForm(data=request.POST) if form.is_valid(): return HttpResponseRedirect(reverse('learning_logs:topic',args=[topic_id])) context = {'topic':topic,'form':form} return render(request, 'learning_logs/new_entry.html',context) @login_required def edit_entry(request,entry_id): '''编辑现有的条目''' entry = Entry.objects.get(id=entry_id) topic = entry.topic if topic.owner != request.user: raise Http404 if request.method != 'POST': form = EntryForm(instance=entry) else: #POST提交的数据,对数据进行处理 form = EntryForm(instance=entry,data=request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('learning_logs:topic',args=[topic.id])) context = {'entry':entry, 'topic':topic, 'form':form } return render(requ ``` models.py ``` from django.db import models from django.contrib.auth.models import User class Topic(models.Model): #用户学习主题 text = models.CharField(max_length= 200) date_added = models.DateTimeField(auto_now_add=True) owner = models.ForeignKey(User,on_delete=models.CASCADE) def __str__(self): #返回模型的字符串表示 return self.text class Entry(models.Model): #学到的有关某个主题的具体知识 topic = models.ForeignKey(Topic,on_delete=models.CASCADE) text = models.TextField() date_added = models.DateTimeField(auto_now_add= True) owner = models.ForeignKey(User, on_delete=models.CASCADE) class meta: verbose_name_plural ='entries' def __str__(self): #返回模型的字符串表示 if len(self.text) >= 50: return self.text[:50] + '...' else: return self.text[:] ```

django启动服务时报错 UnicodeDecodeError: 'utf8' codec can't decode byte 0xcb

Win7 python2.7环境 运行django服务时报错(python manage.py runserver 127.0.0.1:8080) ![图片说明](https://img-ask.csdn.net/upload/201904/19/1555604532_414102.png)

Django搭建的网站登录Xadmin时报错:TemplateDoesNotExist: xadmin/views/register.html。

用Django做的网站,别的页面都能用,但是http://127.0.0.1:8000/xadmin/ 登不上去,一直显示:TemplateDoesNotExist at /xadmin/。 ![图片说明](https://img-ask.csdn.net/upload/201902/26/1551196011_149515.jpg) 调试器报错为:django.template.exceptions.TemplateDoesNotExist: xadmin/views/register.html APP注册和路径设置应该都没问题 ``` INSTALLED_APPS = [ ..., 'xadmin', 'crispy_forms', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')] , 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), ... ] ``` 请问是哪里有问题?该如何解决?

django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") 迁移文件建立数据表的时候一直报错

django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") 在网上看到很多的方法,大概都是 先删除 所有的迁移文件, 再删除 数据库中对应的 Django_migrations 表里面的所有数据 之后再进行创建迁移文件然后再执行创建数据表的操作,但是报 没有应用啥啥啥的错误。。。 接着执行: python manage.py migrate booktest --fake 结果再执行 : python manage.py migrate 还是报 1050 的错误。。。。。。。。 下面附上详细报错信息,求网友大哥们解答~~!! (django_py3) huangdonglin@huangdonglin-virtual-machine:~/django_show/test2$ python manage.py migrate Operations to perform: Synchronize unmigrated apps: messages, staticfiles Apply all migrations: admin, booktest, sessions, auth, contenttypes Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial...Traceback (most recent call last): File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute result = self._query(query) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query conn.query(q) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result result.read() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read first_packet = self.connection._read_packet() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet packet.check_error() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error err.raise_mysql_exception(self._data) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval) pymysql.err.InternalError: (1050, "Table 'django_content_type' already exists") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 221, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 110, in migrate self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in apply_migration state = migration.apply(state, schema_editor) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/migration.py", line 115, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 59, in database_forwards schema_editor.create_model(model) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 286, in create_model self.execute(sql, params or None) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 111, in execute cursor.execute(sql, params) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute result = self._query(query) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query conn.query(q) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result result.read() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read first_packet = self.connection._read_packet() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet packet.check_error() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error err.raise_mysql_exception(self._data) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval)

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

差点跪了...

最近微信又搞出了一个大利器,甚至都上了热搜,当然消息最敏捷的自媒体人,纷纷都开通了自己的视频号。01 视频号是什么呢?视频号是微信体系内的短视频,它不同...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

Vue回炉重造之router路由(更新中)

你好,我是Vam的金豆之路,可以叫我豆哥。2019年年度博客之星、技术领域博客专家。主要领域:前端开发。我的微信是 maomin9761,有什么疑问可以加我哦,自己创建了一个微信技术交流群,可以加我邀请你一起交流学习。最后自己也创建了一个微信公众号,里面的文章是我自己精挑细选的文章,主要介绍各种IT新技术。欢迎关注哦,微信搜索:臻美IT,等你来。 欢迎阅读本博文,本博文主要讲述【】,文字通...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大胆预测下未来5年的Web开发

在2019年的ReactiveConf 上,《Elm in Action》的作者Richard Feldman对未来5年Web开发的发展做了预测,很有意思,分享给大家。如果你有机会从头...

立即提问
相关内容推荐