kiritoxcii
kiritoxcii

Reputation: 27

Can't access Django admin site while import django.contrib.sites

importing django.contrib.sites and doing migrations I'm getting this error when trying to login to the admin site in my project

Request Method: GET Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/ Django Version: 1.8.2 Exception Type: DoesNotExist Exception Value:
Site matching query does not exist. Exception Location: /usr/lib/python2.7/site-packages/django/db/models/query.py in get, line 334

It doesn't recognize the pattern. I don't know whether it's something wrong with the urls or not, so I'm putting here the code.

web/urls.py (app settings)

from django.conf.urls import patterns, include, url

urlpatterns = patterns('web.views',
#   url(r'^$','index_view',name='vista_principal'),
#   url(r'^about/$','about_view',name='vista_about'),

    url(r'^$','index',name='home'),


    url(r'^Ciudad/$','Ciudad_view',name='vista_Ciudad'),
    url(r'^Plan/$','Plan_view',name='vista_Plan'),  
    url(r'^addTitular/$','addTitular',name='addTitular'),
    url(r'^servicio/$','Parentesco',name='parentesco'),
    url(r'^cargo/$','Cargo',name='cargo'),
    url(r'^addEmpleado/$','addEmpleado',name='addEmpleado'),
    url(r'^parentesco/$','Parentesco',name='parentesco'),
    url(r'^addAfiliado/$','addAfiliado',name='addAfiliado'),
    url(r'^addCobro/$','addCobro',name='addCobro'),
    url(r'^consultarEmpleado/$','consultarE',name='consultarEmpleado'),


)

'global'/urls.py (project settings)

from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import  static
from django.contrib import admin

urlpatterns = [
# Examples:
# url(r'^$', 'fun.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),  
url(r'^',include('web.urls')),  
url(r'^',include('usuarios.urls')),
url(r'^',include('registration.urls')),

]

if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root =      settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)

Upvotes: 0

Views: 674

Answers (1)

awwester
awwester

Reputation: 10182

It is recognizing the URL but it's trying to do a query for a site object somewhere and not finding it.

This can be caused by a variety of things such as when you have another package that is dependent upon having a site. For me, django-allauth is usually the culprit, but you don't have that information so I can't be sure.

In your settings, try putting SITE = 1 in your settings file and see if that gets rid of your error.

Upvotes: 1

Related Questions