迁移显示startproject生成站点的错误-Django 1.8.2 Windows [英] Migrate shows error with startproject built site - Django 1.8.2 Windows

查看:30
本文介绍了迁移显示startproject生成站点的错误-Django 1.8.2 Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我希望使用Django构建简单的东西,这是我使用Python编写的第一行代码,虽然我是菜鸟,但是我已经在其他平台上工作过.

So I was hoping to build something simple with Django and this was my very first line of code with Python, I'm a noob but I have worked with other platforms.

我确实像教程中所说的那样,并在我的系统中安装了Django,并进行了代码测试,以查看它是否正常运行.Django,setuptool和pip都已安装,并且路径变量都已设置.

I did like the tutorials said and installed Django into my system did the code tests to see if it is working, passed. Django, setuptool and pip are all installed and path variables are all set.

我做了

django-admin startproject mysite

有效.

我去做了

python manage.py migrate

我得到一个错误,

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\core\management\__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\core\management\__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\core\management\__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\core\management\__init__.py", line 40, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\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 661, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\core\management\commands\migrate.py", line 19, in <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\db\migrations\autodetector.py", line 13, in <module>
    from django.db.migrations.questioner import MigrationQuestioner
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\db\migrations\questioner.py", line 12, in <module>
    from .loader import MIGRATIONS_MODULE_NAME
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\db\migrations\loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\db\migrations\recorder.py", line 9, in <module>
    class MigrationRecorder(object):
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\db\migrations\recorder.py", line 23, in MigrationRecorder
    class Migration(models.Model):
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\db\models\base.py", line 309, in __new__
    new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\apps\registry.py", line 223, in register_model
    self.clear_cache()
  File "c:\Users\Sworup\AppData\Local\Programs\Python\Python35-32\lib\site-packa
ges\django\apps\registry.py", line 344, in clear_cache
    for model in self.get_models(include_auto_created=True):
TypeError: get_models() missing 1 required positional argument: 'self'

我尚未使用默认代码进行任何更改.我只是想进行迁移,然后启动服务器以查看默认的启动画面.

I haven't changed anything with the default code yet. I just wanted to do the migration and then start the server to see the default splashscreen.

服务器启动命令也不起作用.

Server start command is not working either by the way.

我不知道这里出了什么问题,我做了入门指南所说的话,Django让我很尴尬,没有让我通过入门教程.:(

I have no idea what's the problem here, I did what the how to get started tutorial said, Django is embarrassing me not letting me pass the getting started tutorial. :(

推荐答案

简而言之
开始学习Python和Django时,我个人认为,在 Python 3.3 上运行它目前是 的最佳选择.

In short
To start learning Python and Django my personal opinion is that running it on Python 3.3 is currently the best choice.

更长一点

如评论中所述,我怀疑您正在与Django 1.8和Python 3.5不兼容.Django 1.9将是第一个应支持Python 3.5的版本.有关受支持版本的列表,请

As written in the comment, I suspect that you are running into an incompatibility with Django 1.8 and Python 3.5. Django 1.9 will be the first version that should support Python 3.5. For a list of supported versions see this table.

Python 3.4当前是最新的稳定Python版本,因此选择 3.3 可确保您不会遇到尚未针对3.4进行测试和更新的第三方程序包中的次要错误.

Python 3.4 is currently the latest stable Python release, so picking 3.3 ensures that you are not running into minor bugs in third party packages that are not already being tested and updated for 3.4.

而且,也许更重要:许多提供Python托管的商业托管公司可能没有最新的稳定Python.因此有可能发生,当您要启动网站时,无论如何都必须使用较旧的版本进行检查.

Also, and maybe a bit more important: many of the commercial hosting companies that provide Python hosting might not have the latest stable Python available. So it could happen that when you are going to launch your website you will then have to check it with an older version anyways.

Python 2与Python 3
要使您的代码运行,请安装最新的稳定版 Python 2.7 Python 3.3 .原因是巨大的第三方软件包生态系统可用于Django和Python.通过使用Python 2.7,您仍将获得最高的兼容性.也就是说,Python 3是未来,并且在广泛使用的库和软件包中的支持很高,因此在大多数用例中都可以使用它.

Python 2 vs. Python 3
To get your code running install either the latest stable Python 2.7 or Python 3.3. The reason is the huge ecosystem of third party packages that are available for Django and Python. You will still get the highest compatibility by going with Python 2.7. That said, Python 3 is the future and support among the widely used libraries and packages is very high so that it is fine using it in the majority of use cases.

请记住,只要您正在查看要安装的新软件包(例如,使用 pip install< package_name> ),请检查该软件包是否与Python 3兼容.通常会有一个在 README 中对此进行评论,因此此信息很容易找到.

Just remember that anytime you are looking at a new package that you want to install (e.g. with pip install <package_name>, check that the package is compatible with Python 3. There is usually a comment about it in the README, so this info is easy to find.

这篇关于迁移显示startproject生成站点的错误-Django 1.8.2 Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆