I'm just learning django, well, the biggest problem of django for me is, if something went wrong, I get a huge traceback without any information what is really went wrong.
I'm actually following tutorial steps from this Tutorial. Is there any explanation how to read and understand the django error messages?
Example:
DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL: http://localhost:8080/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/python
Python Version: 2.7.3
Python Path:
['/home/ps/src/python/django',
'/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/pymodules/python2.7/gtk-2.0',
'/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: So, 27 Okt 2013 19:32:52 +0100
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.
What is this thing gonna try to tell me? What is "DoesNotExist" at "/admin/"? The description about "DoesNotExists" tells only: "an object does not exists".
Admin interface was definitely working before, but I've just played around inside my app on my models, but even after remove my app in INSTALLED_APPS from settings.py from my project I'll get that message. My app itself seems to work, but the admin interface don't.
Now, after googling for my problem I found out that I have to comment out "django.contrib.sites", after that everything worked fine. But I don't believe that this would be the way of django: everytime if an error occurres, go to google, pass the confusing message and finding via try-error which of the answers will match my problem.
I would like to really understand what is django/python telling and what is "really" the problem, not just "error 17 somewhere in the deep of django".
Any Ideas how to "read" this error message?
You should have DEBUG set to True. Then you get a much more informative error message, complete with the code context and local variables at each point in the traceback.
In your case, you are missing an entry in the Site table (from django.contrib.sites), which should have been created when you ran manage.py syncdb
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With