django File "/home/tarena/.local/lib/python3.5/site-packages/django/utils/crypto.py", line 6, in <module> import secrets ImportError: No module named 'secrets'

提起django服务:python3 manage.py runserver时,显示import secrets ImportError

File "/home/tarena/.local/lib/python3.5/site-packages/django/utils/crypto.py", line 6, in <module>     
import secrets ImportError: No module named 'secrets'

请问有谁知道怎么解决a

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Django创建超级用户时,出现错误 ValueError: invalid literal for int() with base 10: ''
ERROR exception 135 Internal Server Error: /users/ Traceback (most recent call last): File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch response = self.handle_exception(exc) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception self.raise_uncaught_exception(exc) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception raise exc File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch response = handler(request, *args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/generics.py", line 242, in post return self.create(request, *args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/mixins.py", line 19, in create self.perform_create(serializer) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/mixins.py", line 24, in perform_create serializer.save() File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/serializers.py", line 213, in save self.instance = self.create(validated_data) File "/home/python/dihai02/per02/apps/users/serializers/user.py", line 25, in create user = User.objects.create_user(**validated_data) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/contrib/auth/models.py", line 159, in create_user return self._create_user(username, email, password, **extra_fields) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/contrib/auth/models.py", line 153, in _create_user user.save(using=self._db) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 80, in save super(AbstractBaseUser, self).save(*args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 808, in save force_update=force_update, update_fields=update_fields) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 838, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 924, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 963, in _do_insert using=using, raw=raw) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/query.py", line 1076, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1111, in execute_sql for sql, params in self.as_sql(): File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1064, in as_sql for obj in self.query.objs File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1064, in <listcomp> for obj in self.query.objs File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1063, in <listcomp> [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields] File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1003, in prepare_value value = field.get_db_prep_save(value, connection=self.connection) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 770, in get_db_prep_save prepared=False) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 762, in get_db_prep_value value = self.get_prep_value(value) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 1853, in get_prep_value return int(value) ValueError: invalid literal for int() with base 10: ''
python报这个错误如何解决
python3 manage.py runserver Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 357, in execute autoreload.check_errors(django.setup)() File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 16, in setup from django.urls import set_script_prefix File "/usr/local/lib/python3.5/dist-packages/django/urls/__init__.py", line 1, in <module> from .base import ( File "/usr/local/lib/python3.5/dist-packages/django/urls/base.py", line 9, in <module> from .exceptions import NoReverseMatch, Resolver404 File "/usr/local/lib/python3.5/dist-packages/django/urls/exceptions.py", line 1, in <module> from django.http import Http404 File "/usr/local/lib/python3.5/dist-packages/django/http/__init__.py", line 2, in <module> from django.http.request import ( File "/usr/local/lib/python3.5/dist-packages/django/http/request.py", line 10, in <module> from django.core import signing File "/usr/local/lib/python3.5/dist-packages/django/core/signing.py", line 45, in <module> from django.utils.crypto import constant_time_compare, salted_hmac File "/usr/local/lib/python3.5/dist-packages/django/utils/crypto.py", line 6, in <module> import secrets ImportError: No module named 'secrets' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 370, in execute _parser = self.fetch_command('runserver').create_parser('django', 'runserver') File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 244, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 37, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 10, in <module> from django.core.servers.basehttp import ( File "/usr/local/lib/python3.5/dist-packages/django/core/servers/basehttp.py", line 17, in <module> from django.core.handlers.wsgi import LimitedStream File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py", line 6, in <module> from django.core.handlers import base File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 8, in <module> from django.urls import get_resolver, set_urlconf File "/usr/local/lib/python3.5/dist-packages/django/urls/__init__.py", line 1, in <module> from .base import ( File "/usr/local/lib/python3.5/dist-packages/django/urls/base.py", line 9, in <module> from .exceptions import NoReverseMatch, Resolver404 File "/usr/local/lib/python3.5/dist-packages/django/urls/exceptions.py", line 1, in <module> from django.http import Http404 File "/usr/local/lib/python3.5/dist-packages/django/http/__init__.py", line 2, in <module> from django.http.request import ( File "/usr/local/lib/python3.5/dist-packages/django/http/request.py", line 10, in <module> from django.core import signing File "/usr/local/lib/python3.5/dist-packages/django/core/signing.py", line 45, in <module> from django.utils.crypto import constant_time_compare, salted_hmac File "/usr/local/lib/python3.5/dist-packages/django/utils/crypto.py", line 6, in <module> import secrets ImportError: No module named 'secrets'
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)
问各位大佬一个django+heroku的问题
当我在heroku终端执行python manage.py migrate时 ``` Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 325, in execute django.setup() File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/app/learning_logs/models.py", line 14, in <module> class Group(models.Model): File "/app/learning_logs/models.py", line 15, in Group choices = Help().choices() File "/app/learning_logs/help.py", line 9, in choices for user in users: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 162, in __iter__ self._fetch_all() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 965, in _fetch_all self._result_cache = list(self.iterator()) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 238, in iterator results = compiler.execute_sql() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... ``` models.py ``` from django.db import models from django.contrib.auth.models import User from .help import Help from django.utils.deconstruct import deconstructible # Create your models here. @deconstructible class File(models.Model): text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) def __str__(self): return self.text return self.text @deconstructible class Group(models.Model): choices = Help().choices() text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) visit_able = models.CharField( max_length=20, choices=(choices) ) def __str__(self): return self.text @deconstructible class Topic(models.Model): choices=Help().choices() text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) owner = models.ForeignKey(User) edit_able = models.CharField( max_length=20, choices=(choices), null=True ) group = models.ForeignKey( Group, on_delete=models.CASCADE, related_name='things' ) def __str__(self): return self.text @deconstructible class Entry(models.Model): choices=Help().choices() topic = models.ForeignKey( Topic, on_delete=models.CASCADE ) text = models.TextField(default='') date_added = models.DateTimeField(auto_now_add=True) edit_able = models.CharField( max_length=10, choices=(choices) ) class Meta: verbose_name_plural = 'entries' def __str__(self): return self.text @deconstructible class Root(models.Model): text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) meaning = models.CharField(max_length=1000) def __str__(self): return self.text @deconstructible class Suf_Pre_fix(models.Model): root = models.ForeignKey( Root, on_delete=models.CASCADE, related_name="things" ) date_added = models.DateTimeField(auto_now_add=True) prefixes = models.CharField(max_length=100) suffixes = models.CharField(max_length=100) word = models.CharField(max_length=200) text = models.TextField() class Meta: verbose_name_plural = 'suffixes&prefixes' def __str__(self): return self.text ```
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' ```
ImportError: No module named baseinstall
]# python manage.py startapp baseinsatll Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute django.setup() File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 87, in create module = import_module(entry) File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: No module named baseinstall
Hue安装的问题(启动失败)
我的hadoop集群是在centos上安装的,最近测试安装hue.build完成之后,启动hue爆出如下错误: KeyError: "Couldn't get user id for user hue" 参考:https://github.com/cloudera/hue/issues/27 增加了hue用户,再次启动还是报错. Traceback (most recent call last): File "/home/spark/hue/branch-3.9/build/env/bin/hue", line 11, in <module> load_entry_point('desktop', 'console_scripts', 'hue')() File "/home/spark/hue/branch-3.9/desktop/core/src/desktop/manage_entry.py", line 59, in entry execute_from_command_line(sys.argv) File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/management/__init__.py", line 261, in fetch_command commands = get_commands() File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/management/__init__.py", line 107, in get_commands apps = settings.INSTALLED_APPS File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/conf/__init__.py", line 49, in _setup self._wrapped = Settings(settings_module) File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/conf/__init__.py", line 128, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/home/spark/hue/branch-3.9/build/env/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/utils/importlib.py", line 40, in import_module __import__(name) File "/home/spark/hue/branch-3.9/desktop/core/src/desktop/settings.py", line 34, in <module> from desktop.lib.python_util import force_dict_to_strings File "/home/spark/hue/branch-3.9/desktop/core/src/desktop/lib/python_util.py", line 23, in <module> from desktop import conf File "/home/spark/hue/branch-3.9/desktop/core/src/desktop/conf.py", line 29, in <module> from desktop.lib.conf import Config, ConfigSection, UnspecifiedConfigSection,\ File "/home/spark/hue/branch-3.9/desktop/core/src/desktop/lib/conf.py", line 72, in <module> import configobj KeyboardInterrupt 请大家帮我看一下这是什么问题?谢谢
ProgrammingError at / relation "file_filetype" does not exist
我在部署django2.2项目到阿里云ECS上去,实例安装好了。然后按以下步骤进行: 1、安装虚拟环境:按教程已经成功。也建立了虚拟环境。 2、安装nginx:成功,可以看到初始页面; 3、安装postgresql10.11 for ubuntu18.04,按教程弄好了一切; 4、安装uwsgi:也能成功输出页面:Hello world. 5、上传项目文件到服务器后,就出了问题,我觉得问题可能是 migrations. 我的环境是:ubuntu18.04+nginx1.14+postgresql10+uwsgi2.18+python3.6.9+django2.2.9 异常如下: ProgrammingError at / relation "file_filetype" does not exist LINE 1: ...id", "file_filetype"."file_type_chinesename" FROM "file_file... ^ Request Method: GET Request URL: Django Version: 2.2 Exception Type: ProgrammingError Exception Value: relation "file_filetype" does not exist LINE 1: ...id", "file_filetype"."file_type_chinesename" FROM "file_file... ^ Exception Location: /home/tsfs/.virtualenvs/tsfswork/lib/python3.6/site-packages/django/db/backends/utils.py in _execute, line 84 Python Executable: /home/tsfs/.virtualenvs/tsfswork/bin/uwsgi Python Version: 3.6.9 Python Path: ['.', '', '/home/tsfs/.virtualenvs/tsfswork/lib/python36.zip', '/home/tsfs/.virtualenvs/tsfswork/lib/python3.6', '/home/tsfs/.virtualenvs/tsfswork/lib/python3.6/lib-dynload', '/usr/lib/python3.6', '/home/tsfs/.virtualenvs/tsfswork/lib/python3.6/site-packages'] Server time: Sun, 23 Feb 2020 21:26:27 +0800
hue 3.9 hive 查询界面日志无法动态显示
进入hue hive查询界面,随便执行一个查询,无法动态显示日志,F12查看日志刷新请求返回: {"status": 2, "message": "database is locked"} 后台报错: [15/Mar/2016 00:07:37 -0700] api ERROR error in <function watch_query_refresh_json at 0x7fa8f0e5e9b0> Traceback (most recent call last): File "/usr/lib/hue/apps/beeswax/src/beeswax/api.py", line 54, in decorator return view_fn(request, *args, **kwargs) File "/usr/lib/hue/apps/beeswax/src/beeswax/api.py", line 180, in watch_query_refresh_json query_history.save_state(state) File "/usr/lib/hue/apps/beeswax/src/beeswax/models.py", line 243, in save_state self.save() File "/usr/lib/hue/apps/beeswax/src/beeswax/models.py", line 189, in save super(QueryHistory, self).save(*args, **kwargs) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 545, in save force_update=force_update, update_fields=update_fields) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 573, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 635, in _save_table forced_update) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 679, in _do_update return filtered._update(values) > 0 File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/query.py", line 510, in _update return query.get_compiler(self.db).execute_sql(None) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/compiler.py", line 980, in execute_sql cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/compiler.py", line 786, in execute_sql cursor.execute(sql, params) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/util.py", line 53, in execute return self.cursor.execute(sql, params) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/utils.py", line 99, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/util.py", line 53, in execute return self.cursor.execute(sql, params) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/sqlite3/base.py", line 452, in execute return Database.Cursor.execute(self, query, params) **OperationalError: database is locked** 但是在历史记录里能查看到这次查询及结果。不知道什么原因,请大神指教
问个有关python+django+heroku的问题
``` Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... 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 "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 325, in execute django.setup() File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/app/learning_logs/models.py", line 7, in <module> class Topic(models.Model): File "/app/learning_logs/models.py", line 8, in Topic choices=Help().choices() File "/app/learning_logs/help.py", line 9, in choices for user in users: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 162, in __iter__ self._fetch_all() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 965, in _fetch_all self._result_cache = list(self.iterator()) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 238, in iterator results = compiler.execute_sql() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... ``` 在heroku bash操作makemigrations,migrate中出现的错误 在本地用这些没问题 settings.py ``` """ Django settings for learning_log project. Generated by 'django-admin startproject' using Django 1.8.5. For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os import django_heroku 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/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'o47!#$sbu_&=)pnbk63ra!hjbx@+pc=2j42cf(&mx82&hs&ph_' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'whitenoise.runserver_nostatic', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #my app 'learning_logs', 'users', #other app 'bootstrap3', ) MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', ] 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 = 'learning_log.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], '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 = 'learning_log.wsgi.application' # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True LOGIN_URL = '/users/login/' # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') if os.getenv('DATABASE_URL') is not None: import dj_database_url DATABASES['default'] = dj_database_url.config() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ALLOWED_HOSTS = ['stark-anchorage-08076.herokuapp.com'] DEBUG = False BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) django_heroku.settings(locals()) ``` views.py ``` from django.shortcuts import render from .models import Topic, Entry, Root, Suf_Pre_fix from django.http import HttpResponseRedirect, Http404 from django.core.urlresolvers import reverse from .forms import TopicForm, EntryForm, RootForm from django.contrib.auth.decorators import login_required from .help import Help from django.contrib.auth.models import User # Create your views here. def index(request): return render(request, 'learning_logs/index.html') @login_required def topics(request): topics = Topic.objects.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.get(id=topic_id) 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: form = TopicForm(request.POST) if form.is_valid(): new_topic = form.save(commit=False) new_topic.owner = request.user new_topic.edit_able = request.POST.getlist("edit_able") new_topic.save() return HttpResponseRedirect(reverse('learning_logs:topics')) context = {'form': form, 'users':Help().users()} 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(): new_entry = form.save(commit=False) new_entry.topic = topic new_entry.edit_able = request.POST.getlist("edit_able") new_entry.save() return HttpResponseRedirect(reverse('learning_logs:topic',args=[topic_id])) context = {'topic':topic, 'form': form, 'users':Help().users()} 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 not Help().check_user(request.user,entry.edit_able) or not Help().check_user(request.user,topic.edit_able): raise Http404 if request.method != 'POST': form = EntryForm(instance=entry) else: form = EntryForm(instance=entry, data=request.POST) if form.is_valid(): edit_entry = form.save(commit=False) edit_entry.edit_able = request.POST.getlist("edit_able") edit_entry.save() return HttpResponseRedirect(reverse('learning_logs:topic',args=[topic.id])) context = {'entry': entry, 'topic': topic, 'form': form ,'users':Help().users()} return render(request, 'learning_logs/edit_entry.html', context) @login_required def roots(request): roots = Root.objects.order_by('date_added') context = {'roots': roots} return render(request, 'learning_logs/roots.html', context) def root(request, root_id): root = Root.objects.get(id=root_id) things = root.things.order_by('-date_added') context = {'root':root, 'things':things} return render(request, 'learning_logs/root.html', context) ``` help.py ``` from django.contrib.auth.models import User class Help(): def __init__(self): pass def choices(self): users=User.objects.all() choices=[] a=1 for user in users: choices.append((a,str(user))) a+=1 return choices def check_user(self,user,users): try: str(users).index(str(user)) except: return False else: return True def users(self): users=[] for user in User.objects.all(): users.append(str(user)) return users def test_list(self,list1): for item in list1: print(type(item)) def test_word(self,item): print(item,type(item)) ```
问个有关django+heroku的问题
``` Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... 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 "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 325, in execute django.setup() File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/app/learning_logs/models.py", line 7, in <module> class Topic(models.Model): File "/app/learning_logs/models.py", line 8, in Topic choices=Help().choices() File "/app/learning_logs/help.py", line 9, in choices for user in users: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 162, in __iter__ self._fetch_all() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 965, in _fetch_all self._result_cache = list(self.iterator()) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 238, in iterator results = compiler.execute_sql() File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... ``` 在heroku bash操作makemigrations,migrate中出现的错误 在本地用这些没问题 settings.py ``` """ Django settings for learning_log project. Generated by 'django-admin startproject' using Django 1.8.5. For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os import django_heroku 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/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'o47!#$sbu_&=)pnbk63ra!hjbx@+pc=2j42cf(&mx82&hs&ph_' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'whitenoise.runserver_nostatic', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #my app 'learning_logs', 'users', #other app 'bootstrap3', ) MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', ] 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 = 'learning_log.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], '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 = 'learning_log.wsgi.application' # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True LOGIN_URL = '/users/login/' # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') if os.getenv('DATABASE_URL') is not None: import dj_database_url DATABASES['default'] = dj_database_url.config() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ALLOWED_HOSTS = ['stark-anchorage-08076.herokuapp.com'] DEBUG = False BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) django_heroku.settings(locals()) ``` views.py ``` from django.shortcuts import render from .models import Topic, Entry, Root, Suf_Pre_fix from django.http import HttpResponseRedirect, Http404 from django.core.urlresolvers import reverse from .forms import TopicForm, EntryForm, RootForm from django.contrib.auth.decorators import login_required from .help import Help from django.contrib.auth.models import User # Create your views here. def index(request): return render(request, 'learning_logs/index.html') @login_required def topics(request): topics = Topic.objects.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.get(id=topic_id) 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: form = TopicForm(request.POST) if form.is_valid(): new_topic = form.save(commit=False) new_topic.owner = request.user new_topic.edit_able = request.POST.getlist("edit_able") new_topic.save() return HttpResponseRedirect(reverse('learning_logs:topics')) context = {'form': form, 'users':Help().users()} 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(): new_entry = form.save(commit=False) new_entry.topic = topic new_entry.edit_able = request.POST.getlist("edit_able") new_entry.save() return HttpResponseRedirect(reverse('learning_logs:topic',args=[topic_id])) context = {'topic':topic, 'form': form, 'users':Help().users()} 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 not Help().check_user(request.user,entry.edit_able) or not Help().check_user(request.user,topic.edit_able): raise Http404 if request.method != 'POST': form = EntryForm(instance=entry) else: form = EntryForm(instance=entry, data=request.POST) if form.is_valid(): edit_entry = form.save(commit=False) edit_entry.edit_able = request.POST.getlist("edit_able") edit_entry.save() return HttpResponseRedirect(reverse('learning_logs:topic',args=[topic.id])) context = {'entry': entry, 'topic': topic, 'form': form ,'users':Help().users()} return render(request, 'learning_logs/edit_entry.html', context) @login_required def roots(request): roots = Root.objects.order_by('date_added') context = {'roots': roots} return render(request, 'learning_logs/roots.html', context) def root(request, root_id): root = Root.objects.get(id=root_id) things = root.things.order_by('-date_added') context = {'root':root, 'things':things} return render(request, 'learning_logs/root.html', context) ``` help.py ``` from django.contrib.auth.models import User class Help(): def __init__(self): pass def choices(self): users=User.objects.all() choices=[] a=1 for user in users: choices.append((a,str(user))) a+=1 return choices def check_user(self,user,users): try: str(users).index(str(user)) except: return False else: return True def users(self): users=[] for user in User.objects.all(): users.append(str(user)) return users def test_list(self,list1): for item in list1: print(type(item)) def test_word(self,item): print(item,type(item)) ```
关于Django执行迁移文件时,ForeignKey里面加on_delete=models.CASCADE报错问题,谁知道时怎么回事?万分感谢!!
Django 在创建模型类后,执行一下代码迁移文件时,在ForeignKey里面不加on_delete=models.CASCADE会报错,加了后,其他又外键的模型类不报错,就这个报错。 ``` class GoodsType(BaseModel): """商品类型模型类""" name = models.CharField(max_length=20, verbose_name="种类名称") logo = models.CharField(max_length=20, verbose_name="标识") image = models.ImageField(upload_to="type", verbose_name="商品类型图片") class Mete: db_table = "df_goods_type" verbose_name = "商品种类" verbose_name_plural = verbose_name def __str__(self): return self.name class GoodsSKU(BaseModel): """商品SKU模型类""" status_choices = ( (0, "下线"), (1, "上线"), ) type = models.ForeignKey("GoodsType", on_delete=models.CASCADE, verbose_name="商品种类") goods = models.ForeignKey("Goods", on_delete=models.CASCADE, verbose_name="商品SPU") name = models.CharField(max_length=20, verbose_name="商品名称") desc = models.CharField(max_length=256, verbose_name="商品简介") price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="商品价格") unite = models.CharField(max_length=20, verbose_name="商品单位") image = models.ImageField(upload_to='goods', verbose_name="商品图片") stock = models.IntegerField(default=1, verbose_name="商品库存") sales = models.IntegerField(default=0, verbose_name="商品销量") status = models.SmallIntegerField(default=1, choices=status_choices,verbose_name="商品状态") class Meta: db_table = "df_goods_sku" verbose_name = "商品" verbose_name_plural = verbose_name class GoodImage(models): """商品图片模型类""" sku = models.ForeignKey("GoodsSKU", on_delete=models.CASCADE, verbose_name="商品") image = models.ImageField(upload_to="good", verbose_name="图片路径") class Meta: db_table = "df_goods_image" verbose_name = "商品图片" verbose_name_plural = verbose_name ``` 报错 ``` python manage.py makemigrations 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 "/home/u/.virtualenvs/dailyfresh/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/u/.virtualenvs/dailyfresh/lib/python3.5/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/home/u/.virtualenvs/dailyfresh/lib/python3.5/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/u/.virtualenvs/dailyfresh/lib/python3.5/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/u/.virtualenvs/dailyfresh/lib/python3.5/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/home/u/jeth/dailyfresh/apps/goods/models.py", line 56, in <module> class GoodImage(models): TypeError: module.__init__() takes at most 2 arguments (3 given) ```
《pythno编程从入门到实践》18.2.2中makemigrations时出错是啥情况
Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/apps/registry.py", line 112, in populate app_config.import_models() File "/Users/taoyu/Desktop/learning_log/ll_env/lib/python3.7/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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 "/Users/taoyu/Desktop/learning_log/learning_logs/models.py", line 5, in <module> class Topics(models.Model): File "/Users/taoyu/Desktop/learning_log/learning_logs/models.py", line 8, in Topics date_added = models.DateTimeField(auto_now_add=Ture) NameError: name 'Ture' is not defined
Django 接入微信post方法时报错
code 400, message Bad request syntax ('\x00\xb3\x02\x00\x0c\x00QUERY_STRINGW\x00signature=a78c2ca4ca9a2594bf54fdda6727e9bf1151229a&timestamp=1457662563&nonce=755200386\x0e\x00REQUEST_METHOD\x04\x00POST\x0c\x00CONTENT_TYPE\x08\x00text/xml\x0e\x00CONTENT_LENGTH\x03\x00318\x0b\x00REQUEST_URIf\x00/wechat_access?signature=a78c2ca4ca9a2594bf54fdda6727e9bf1151229a&timestamp=1457662563&nonce=755200386\t\x00PATH_INFO\x0e\x00/wechat_access\r\x00DOCUMENT_ROOT\x15\x00/usr/share/nginx/html\x0f\x00SERVER_PROTOCOL\x08\x00HTTP/1.0\x0c\x00UWSGI_SCHEME\x04\x00http\x0b\x00REMOTE_ADDR\x0e\x00182.254.86.156\x0b\x00REMOTE_PORT\x05\x0042845\x0b\x00SERVER_PORT\x02\x0080\x0b\x00SERVER_NAME\x0b\x00bfy.sozi.it\x0c\x00UWSGI_SCHEME\x04\x00http\x0f\x00SERVER_SOFTWARE\x0b\x00nginx/1.4.6\x0f\x00HTTP_USER_AGENT\x0b\x00Mozilla/4.0\x0b\x00HTTP_ACCEPT\x03\x00*/*\t\x00HTTP_HOST\x0b\x00bfy.sozi.it\x0b\x00HTTP_PRAGMA\x08\x00no-cache\x13\x00HTTP_CONTENT_LENGTH\x03\x00318\x11\x00HTTP_CONTENT_TYPE\x08\x00text/xml<xml><ToUserName><![CDATA[gh_f24247160fad]]></ToUserName>') ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 34316) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 129, in __init__ super(WSGIRequestHandler, self).__init__(*args, **kwargs) File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__ self.handle() File "/usr/lib/python2.7/wsgiref/simple_server.py", line 117, in handle if not self.parse_request(): # An error code has been sent, just exit File "/usr/lib/python2.7/BaseHTTPServer.py", line 286, in parse_request self.send_error(400, "Bad request syntax (%r)" % requestline) File "/usr/lib/python2.7/BaseHTTPServer.py", line 368, in send_error self.send_response(code, message) File "/usr/lib/python2.7/BaseHTTPServer.py", line 385, in send_response self.log_request(code) File "/usr/lib/python2.7/BaseHTTPServer.py", line 422, in log_request self.requestline, str(code), str(size)) File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 136, in log_message msg = "[%s] %s\n" % (self.log_date_time_string(), format % args) UnicodeDecodeError: 'ascii' codec can't decode byte 0xb3 in position 2: ordinal not in range(128)
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的报错没有头绪,希望有大佬帮忙分析一下原因所在,万分感谢。
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
pip安装scrapy报错,求解?
root@iZ253bbf6h1Z:/home/guoyufeng/CODE/pythonCode/SCrapyLeraning/tutorial/tutorial/spiders# sudo apt-get install python-pipReading package lists... DoneBuilding dependency tree Reading state information... Donepython-pip is already the newest version.The following packages were automatically installed and are no longer required: ipython libwebp5 libwebpmux1 python-boto python-crypto python-decorator python-django python-guppy python-guppy-lib python-imaging python-mysqldb python-openssl python-pam python-pexpect python-pil python-pyasn1 python-pygments python-serial python-simplegeneric python-support python-twisted-bin python-twisted-conch python-twisted-core python-twisted-mail python-twisted-names python-twisted-web python-w3lib python-zope.interfaceUse 'apt-get autoremove' to remove them.0 upgraded, 0 newly installed, 0 to remove and 107 not upgraded.root@iZ253bbf6h1Z:/home/guoyufeng/CODE/pythonCode/SCrapyLeraning/tutorial/tutorial/spiders# pip install ScrapyDownloading/unpacking Scrapy Downloading Scrapy-1.0.1-py2-none-any.whl (290kB): 290kB downloadedCleaning up...Exception:Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1260, in prepare_files )[0]IndexError: list index out of rangeStoring debug log for failure in /root/.pip/pip.log
pip install ipython 时出现什么编码解码的问题导致无法安装
``` (django_st) pyvip@VIP:~/django_st$ pip install ipython Looking in indexes: https://pypi.douban.com/simple Collecting ipython Downloading https://pypi.doubanio.com/packages/05/d7/77b7a1988c99227f52402f93fb0f7e88c97239960516f53907ebbc44149c/ipython-7.11.0-py3-none-any.whl (777kB) |████████████████████████████████| 778kB 1.4MB/s ERROR: Could not install packages due to an EnvironmentError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check',)) (django_st) pyvip@VIP:~/django_st$ python manage.py shell Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> exit() (django_st) pyvip@VIP:~/django_st$ sudo pip install ipython [sudo] pyvip 的密码: The directory '/home/pyvip/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/pyvip/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Requirement already satisfied: ipython in /usr/local/lib/python3.6/dist-packages Requirement already satisfied: decorator in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: pickleshare in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: pexpect; sys_platform != "win32" in /usr/lib/python3/dist-packages (from ipython) Requirement already satisfied: backcall in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: pygments in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: jedi>=0.10 in /usr/local/lib/python3.6/dist-packages (from ipython) Requirement already satisfied: setuptools>=18.5 in /usr/lib/python3/dist-packages (from ipython) Requirement already satisfied: six in /usr/lib/python3/dist-packages (from traitlets>=4.2->ipython) Requirement already satisfied: ipython-genutils in /usr/local/lib/python3.6/dist-packages (from traitlets>=4.2->ipython) Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython) Requirement already satisfied: parso>=0.5.2 in /usr/local/lib/python3.6/dist-packages (from jedi>=0.10->ipython) (django_st) pyvip@VIP:~/django_st$ ipython --version 7.11.0 (django_st) pyvip@VIP:~/django_st$ python manage.py shell Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> exit() ```
openstack newton dashbaord 错误
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. log: Target WSGI script '/usr/share/openstack-dashboard/ openstack_dashboard/wsgi/django.wsgi' cannot be loaded as Python module.[Tue Apr 25 18:03:37.203741 2017] [:error] [pid 3712] [remote 10.0.0.1:188] mod_wsgi (pid=3712): Exception occurred processing WSGI script '/usr/sha re/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.[Tue Apr 25 18:03:37.203784 2017] [:error] [pid 3712] [remote 10.0.0.1:188] Traceback (most recent call last): [Tue Apr 25 18:03:37.203822 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.w sgi", line 14, in <module>[Tue Apr 25 18:03:37.204361 2017] [:error] [pid 3712] [remote 10.0.0.1:188] application = get_wsgi_application() [Tue Apr 25 18:03:37.204399 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application[Tue Apr 25 18:03:37.204449 2017] [:error] [pid 3712] [remote 10.0.0.1:188] django.setup() [Tue Apr 25 18:03:37.204473 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/django/__init__.py", line 17, i n setup[Tue Apr 25 18:03:37.204499 2017] [:error] [pid 3712] [remote 10.0.0.1:188] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) [Tue Apr 25 18:03:37.204514 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__[Tue Apr 25 18:03:37.204539 2017] [:error] [pid 3712] [remote 10.0.0.1:188] self._setup(name) [Tue Apr 25 18:03:37.204573 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup[Tue Apr 25 18:03:37.204600 2017] [:error] [pid 3712] [remote 10.0.0.1:188] self._wrapped = Settings(settings_module) [Tue Apr 25 18:03:37.204618 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__[Tue Apr 25 18:03:37.204640 2017] [:error] [pid 3712] [remote 10.0.0.1:188] mod = importlib.import_module(self.SETTINGS_MODULE) [Tue Apr 25 18:03:37.204655 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_ module[Tue Apr 25 18:03:37.204678 2017] [:error] [pid 3712] [remote 10.0.0.1:188] __import__(name) [Tue Apr 25 18:03:37.204693 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../op enstack_dashboard/settings.py", line 419, in <module>[Tue Apr 25 18:03:37.204729 2017] [:error] [pid 3712] [remote 10.0.0.1:188] '.secret_key_store')) [Tue Apr 25 18:03:37.204756 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/horizon/utils/secret_key.py", l ine 74, in generate_or_read_from_file[Tue Apr 25 18:03:37.204800 2017] [:error] [pid 3712] [remote 10.0.0.1:188] with lock: [Tue Apr 25 18:03:37.204829 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/fasteners/process_lock.py", lin e 174, in __enter__[Tue Apr 25 18:03:37.204877 2017] [:error] [pid 3712] [remote 10.0.0.1:188] self.acquire() [Tue Apr 25 18:03:37.204906 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/fasteners/process_lock.py", lin e 151, in acquire[Tue Apr 25 18:03:37.205884 2017] [:error] [pid 3712] [remote 10.0.0.1:188] self._do_open() [Tue Apr 25 18:03:37.205913 2017] [:error] [pid 3712] [remote 10.0.0.1:188] File "/usr/lib/python2.7/site-packages/fasteners/process_lock.py", lin e 123, in _do_open[Tue Apr 25 18:03:37.206513 2017] [:error] [pid 3712] [remote 10.0.0.1:188] self.lockfile = open(self.path, 'a') [Tue Apr 25 18:03:37.206615 2017] [:error] [pid 3712] [remote 10.0.0.1:188] IOError: [Errno 13] Permission denied: '/usr/share/openstack-dashboard/o penstack_dashboard/local/_usr_share_openstack-dashboard_openstack_dashboard_local_.secret_key_store.lock' ``` ```
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
【JSON解析】浅谈JSONObject的使用
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
只因接了一个电话,程序员被骗 30 万!
今天想给大家说一个刚刚发生在我身边的一起真实的诈骗经历,我的朋友因此被骗走30万。注:为了保护当事人隐私,部分情节进行了修改。1平安夜突来的电话开始以为就像普通的诈骗一样,想办法让你把钱...
我一个37岁的程序员朋友
周末了,人一旦没有点事情干,心里就瞎想,而且跟几个老男人坐在一起,更容易瞎想,我自己现在也是 30 岁了,也是无时无刻在担心自己的职业生涯,担心丢掉工作没有收入,担心身体机能下降,担心突...
python自动下载图片
近日闲来无事,总有一种无形的力量萦绕在朕身边,让朕精神涣散,昏昏欲睡。 可是,像朕这么有职业操守的社畜怎么能在上班期间睡瞌睡呢,我不禁陷入了沉思。。。。 突然旁边的IOS同事问:‘嘿,兄弟,我发现一个网站的图片很有意思啊,能不能帮我保存下来提升我的开发灵感?’ 作为一个坚强的社畜怎么能说自己不行呢,当时朕就不假思索的答应:‘oh, It’s simple. Wait for me for a ...
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
Idea 中最常用的10款插件(提高开发效率),一定要学会使用!
学习使用一些插件,可以提高开发效率。对于我们开发人员很有帮助。这篇博客介绍了开发中使用的插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
立即提问

相似问题

2
《pythno编程从入门到实践》18.2.2中makemigrations时出错是啥情况
0
openstack 登陆不上dashboard 500
2
python3.7,django 2.21,for...in...Python int too large to convert to C long
1
使用django模板语言生成静态页面,资源引用错误,多了static路径
2
Django报错:django.server:"GET /favicon.ico HTTP/1.1" 500 59,该如何解决?
1
python从入门到实践中,学习笔记项目,用户登录出错:
1
关于Django执行迁移文件时,ForeignKey里面加on_delete=models.CASCADE报错问题,谁知道时怎么回事?万分感谢!!
1
django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") 迁移文件建立数据表的时候一直报错
1
[django。html]我在gitkraken上传django文件时上传不了css文件
1
ubuntu18.04 python3.6 pip安装mysqlclient报错
1
Django创建超级用户时,出现错误 ValueError: invalid literal for int() with base 10: ''
1
执行python manage.py migrate命令有问题
0
Django 在后台管理页面中实现添加用户报错:RuntimeError at /admin/booktest/bookinfo/add/ generator raised StopIteration
0
pip install ipython 时出现什么编码解码的问题导致无法安装
3
执行 python manage.py makemigrations 提示错误
1
python编码问题UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 0: invalid start byte。
0
Django执行python manage.py makemigrations 报错,数据库是postgresql,大神救救孩子
1
问个有关python+django+heroku的问题
0
问个有关django+heroku的问题
1
利用django filefield上传的文件如何下载