Django tutorial 2 - DoesNotExist at /admin/


(Marcin86s) #1

Zamiast upijać się kolejny weekend ponownie zabrałem się za Django. Mam problem z drugim etapem oficjalnego tutoriala, w momencie gdy powinienem zobaczyć logowanie do generowanego panelu administracyjnego. Dostaje:

DoesNotExist at /admin/

Site matching query does not exist.

Request Method:	GET

Request URL:	http://127.0.0.1:8000/admin/

Django Version:	1.4.5

Exception Type:	DoesNotExist

Exception Value:	

Site matching query does not exist.

Exception Location:	/usr/lib/python2.7/dist-packages/django/db/models/query.py in get, line 366

Python Executable:	/usr/bin/python2.7

Python Version:	2.7.3

Python Path:	

['/home/marcin/Dropbox/Workspace/myapp',

 '/home/marcin/Dropbox/Workspace/myapp',

 '/usr/lib/python2.7',

 '/usr/lib/python2.7/plat-linux2',

 '/usr/lib/python2.7/lib-tk',

 '/usr/lib/python2.7/lib-old',

 '/usr/lib/python2.7/lib-dynload',

 '/usr/local/lib/python2.7/dist-packages',

 '/usr/lib/python2.7/dist-packages',

 '/usr/lib/python2.7/dist-packages/PIL',

 '/usr/lib/python2.7/dist-packages/gst-0.10',

 '/usr/lib/python2.7/dist-packages/gtk-2.0',

 '/usr/lib/pymodules/python2.7']

Server time:	Nd, 21 Lip 2013 12:18:58 +0200

Environment:



Request Method: GET

Request URL: http://127.0.0.1:8000/admin/


Django Version: 1.4.5

Python Version: 2.7.3

Installed Applications:

('django.contrib.auth',

 'django.contrib.contenttypes',

 'django.contrib.sessions',

 'django.contrib.sites',

 'django.contrib.messages',

 'django.contrib.staticfiles',

 'django.contrib.admin',

 'polls')

Installed Middleware:

('django.middleware.common.CommonMiddleware',

 'django.contrib.sessions.middleware.SessionMiddleware',

 'django.middleware.csrf.CsrfViewMiddleware',

 'django.contrib.auth.middleware.AuthenticationMiddleware',

 'django.contrib.messages.middleware.MessageMiddleware')



Traceback:

File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  111. response = callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in wrapper

  213. return self.admin_view(view, cacheable)(*args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view

  91. response = view_func(request, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func

  89. response = view_func(request, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner

  195. return self.login(request)

File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func

  89. response = view_func(request, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in login

  326. return login(request, **defaults)

File "/usr/lib/python2.7/dist-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper

  69. return view(request, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view

  91. response = view_func(request, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func

  89. response = view_func(request, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/contrib/auth/views.py" in login

  53. current_site = get_current_site(request)

File "/usr/lib/python2.7/dist-packages/django/contrib/sites/models.py" in get_current_site

  92. current_site = Site.objects.get_current()

File "/usr/lib/python2.7/dist-packages/django/contrib/sites/models.py" in get_current

  25. current_site = self.get(pk=sid)

File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py" in get

  131. return self.get_query_set().get(*args, **kwargs)

File "/usr/lib/python2.7/dist-packages/django/db/models/query.py" in get

  366. % self.model._meta.object_name)


Exception Type: DoesNotExist at /admin/

Exception Value: Site matching query does not exist.

OS: LMDE IDE: Aptana DB: MySQL Może ktoś z was wie w czym leży problem? -- Dodane 21.07.2013 (N) 12:43 --

INSTALLED_APPS = (

    'django.contrib.auth',

    'django.contrib.contenttypes',

    'django.contrib.sessions',

    'django.contrib.sites',

    'django.contrib.messages',

    'django.contrib.staticfiles',

    # Uncomment the next line to enable the admin:

    'django.contrib.admin',

    # Uncomment the next line to enable admin documentation:

    # 'django.contrib.admindocs',

    'polls',

)

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


# Uncomment the next two lines to enable the admin:

from django.contrib import admin

admin.autodiscover()


urlpatterns = patterns('',

    # Examples:

    # url(r'^$', 'niewynajme.views.home', name='home'),

    # url(r'^niewynajme/', include('niewynajme.foo.urls')),


    # Uncomment the admin/doc line below to enable admin documentation:

    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),


    # Uncomment the next line to enable the admin:

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

)

(Mario16) #2

Sprawdz w mysql czy masz tabele “django_site” i czy w tej tabeli jest przynajmniej jeden wpis.

Swoja droga najlepiej uzywac sqlite dla srodowiska dev. masz wtedy plik sqlite w jednym miejscu z projektem.