简体   繁体   English

Django-admin 启动项目<name>创建旧版本的 Django 项目

[英]Django-admin start project <name> creates old version django project

I created a directory "DjangoProject1" and in it created django project through the terminal with the line我创建了一个目录“DjangoProject1”,并在其中通过终端创建了 django 项目

$ django-admin startproject project $ django-admin startproject 项目

As I was expected, there were created two things in the directory "project": file "manage.py" and another directory "project".正如我所料,在目录“project”中创建了两个东西:文件“manage.py”和另一个目录“project”。 The problem is that in that directory "project" there were: { init , setting, urls, wsgi}.py, but there wasn't file "asgi.py".问题是在那个目录“项目”中有:{ init , setting, urls, wsgi}.py,但没有文件“asgi.py”。 From there I understood that there was created an old version django project.从那里我了解到创建了一个旧版本的 django 项目。 Again!再次! I checked it one more time in "urls.py" file and I saw this:我在“urls.py”文件中又检查了一次,我看到了这个:

urlpatterns = [
    url(r'^admin/', admin.site.urls),
]

instead of this:而不是这个:

urlpatterns = [
path('admin/', admin.site.urls),
]

So it is definitely an old version of django project.所以肯定是django项目的老版本。 I don't know why this problem occurs, as I installed a new version of django, and I was able to create new version django project, though I don't remember how I was doing that.我不知道为什么会出现这个问题,因为我安装了新版本的 django,并且我能够创建新版本的 django 项目,尽管我不记得我是怎么做的。 Can anyone help me to liquidate this problem so that only new version django projects would be created?谁能帮我解决这个问题,以便只创建新版本的 django 项目? (PS before new version maybe I installed an old version, and probably in my computer now there are both: new and old versions of Django) (PS新版本之前可能是我装了旧版本,可能现在我的电脑里有:新旧版本的Django)

I think you use pip instead of pip3我认为您使用pip而不是pip3

First Uninstall django installed by pip:首先卸载pip安装的django:

$ pip uninstall django

Next Install pip3: 接下来安装pip3:
$ pip3 install django

After that, Install Django using pip3: 之后,使用 pip3 安装 Django:
 $ pip3 install django

You can determine Django version that you want to install by this command: 您可以通过以下命令确定要安装的 Django 版本:
 $ pip3 install django==<version>

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

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