I set up the virtual environment variable for Django 1.8 as per the instructions in the Django tutorial (1.8) and the (almost) matching 1.7 tutorial on PythonAnywhere. When I go into Bash and follow the instructions to check the Django version it confirms that I have version 1.8. installed.
我根据Django教程(1.8)和PythonAnywhere上的(几乎)匹配1.7教程中的说明为Django 1.8设置了虚拟环境变量。当我进入Bash并按照说明检查Django版本时,它确认我有1.8版本。安装。
I am up to part 3 in the Django tutorial at this URL:
我在这个URL的Django教程的第3部分:
https://docs.djangoproject.com/en/1.8/intro/tutorial03/
https://docs.djangoproject.com/en/1.8/intro/tutorial03/
In mysite/urls.py the tutorial tells me to write this:
在mysite / urls.py中,教程告诉我写这个:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
]
However, when I actually opened the file I was presented with this:
但是,当我实际打开文件时,我看到了这个:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)
The tutorial then has this to say:
然后教程有这样说:
Doesn’t match what you see? If you’re seeing admin.autodiscover() before the definition of urlpatterns, you’re probably using a version of Django that doesn’t match this tutorial version. You’ll want to either switch to the older tutorial or the newer Django version.
与你看到的不符?如果您在urlpatterns的定义之前看到admin.autodiscover(),那么您可能正在使用与本教程版本不匹配的Django版本。您将要切换到较旧的教程或较新的Django版本。
As I said though, Bash confirms that I Do have Django 1.8 installed. What am I missing here? Why do I not have the correct files for Django 1.8 even though that's what I supposedly installed?
正如我所说,Bash确认我安装了Django 1.8。我在这里想念的是什么?为什么我没有Django 1.8的正确文件,即使这是我应该安装的?
I tried to make the files match the tutorial files, but it only resulted in an error appearing on my public site.
我试图使文件与教程文件匹配,但它只导致我的公共站点上出现错误。
1 个解决方案
#1
1
The most likely cause is that you didn't activate the virtualenv when you ran startproject
, so you got the default Django from PythonAnywhere instead of the one that you installed.
最可能的原因是你在运行startproject时没有激活virtualenv,所以你从PythonAnywhere获得了默认的Django而不是你安装的那个。
#1
1
The most likely cause is that you didn't activate the virtualenv when you ran startproject
, so you got the default Django from PythonAnywhere instead of the one that you installed.
最可能的原因是你在运行startproject时没有激活virtualenv,所以你从PythonAnywhere获得了默认的Django而不是你安装的那个。