简体   繁体   English

空的Django项目出现错误:缺少1个必需的位置参数

[英]Empty Django project with error: missing 1 required positional argument

I just started to learn Django, created first project using django-admin startproject Returner and got an error trying to run it: 我刚开始学习Django,使用django-admin startproject Returner创建了第一个项目,并在尝试运行它时遇到错误:

在此处输入图片说明

How I can solve that? 我该如何解决?

Possibly, the problem is related to multiple version of software. 该问题可能与软件的多个版本有关。 I have Python2.7 with Django 1.11 and Python3.5 with Django 2.0. 我有带Django 1.11的Python2.7和带Django 2.0的Python3.5。

But I have properly set command line aliases from Python to Python3.5 , from pip to pip3.5 , and from django-admin to python /.../python3.5/.../django-admin.py 但是我已经正确设置了命令行别名,从PythonPython3.5 ,从pippip3.5 ,以及从django-adminpython /.../python3.5/.../django-admin.py

And generated files have the comment: 并且生成的文件具有注释:

Generated by 'django-admin startproject' using Django 2.0.3. 由django-admin startproject使用Django 2.0.3生成。

And this code: 这段代码:

import sys
print('Python:')
print(sys.version)

import django
print('\nDjango:')
print(django.VERSION)

Turns into: 变成:

Python: 蟒蛇:
3.5.0b2 (v3.5.0b2:7a088af5615b, May 31 2015, 01:00:01) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] 3.5.0b2(v3.5.0b2:7a088af5615b,2015年5月31日,01:00:01)[GCC 4.2.1(Apple Inc. build 5666)(dot 3)]

Django: Django:
(2, 0, 3, 'final', 0) (2,0,3,'最终',0)


Update 更新资料

I have set up Virtual Environment, added an App to my Project, but still get the same error when try to runserver or migrate . 我已经建立了虚拟环境中,增加了一个应用到我的项目,但仍然得到同样的错误,当尝试runservermigrate I hope someone will help me to solve this terrible problem, because it breaks all the plans of project development. 我希望有人能帮助我解决这个可怕的问题,因为它破坏了项目开发的所有计划。

您是否运行了python manage.py migrate命令?

After lots of trials I think that the cause of the problem was a bug of my Python 3.5 release. 经过大量的试验,我认为问题的原因是我的Python 3.5版本的一个错误。 The method get_models of the Apps class has this decorator: Apps类的get_models方法具有以下修饰符:

@functools.lru_cache(maxsize=None)

Maybe the Python 3.5 implementation of this decorator hides the arguments of the methods. 也许此装饰器的Python 3.5实现隐藏了方法的参数。

To solve the problem, I just installed and used Python 3.7. 为了解决该问题,我刚刚安装并使用了Python 3.7。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM