开发者

Django DoesNotExist/admin/

开发者 https://www.devze.com 2023-03-08 05:21 出处:网络
Hi Folks this is my first encounter with django im doing the django tutorial https://docs.djangoproject.com/en/1.3/intro/tutorial02/ and i have an error when i uncomment the lines they told me to,

Hi Folks this is my first encounter with django im doing the django tutorial https://docs.djangoproject.com/en/1.3/intro/tutorial02/ and i have an error when i uncomment the lines they told me to,

from django.contrib import admin
admin.autodiscover()

and

(r'^admin/', include(admin.site.urls)),

in urls.py inside my roots folder

besides i realized that some lines are different ( i supose because i'm using a newer version of django ) like

here are some extra screen开发者_如何学运维shots

(r'^admin/', include(admin.site.urls)), //(site)

to

url(r'^admin/', include(admin.site.urls)), //(myProject)

Any django expert that can help me with this error, because i had great reviews about this amazing framework,

here are some screenshots

Error, urls.py, settings.py


It's most likely to be a django.contrib.sites app problem. If you are running only one site you can comment this app on your INSTALLED_APPS

If you want to create the missing object you can do it from python manage.py shell:

from django.contrib.sites.models import Site
Site.objects.create(pk=1, domain='<your domain>', name='<your name>')


Without the full error message, I'm not 100% sure what DoesNotExist is referring to, but it sounds like the admin application models haven't been created. Did you add "django.contrib.admin" to your INSTALLED_APPS in settings.py and run python manage.py syncdb and restart the (development) server?

UPDATE:

Probably not a good idea to be using the Subversion source (1.4 pre-alpha mind you). I guarantee whatever change they've made to the proper admin site setup hasn't been updated in the docs. Check out 1.3--it's great, trust me.


You should spacify a SITE_ID in settings.py, so the the site you specificed will manage other sites' content. You can check this page: https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-SITE_ID it refers:

SITE_ID: The ID, as an integer, of the current site in the django_site database table. This is used so that application data can hook into specific sites and a single database can manage content for multiple sites.

0

精彩评论

暂无评论...
验证码 换一张
取 消