The correct way to do is to create a new super account.
python manage.py createsuperuser
If you use the django-multilingual module for multilingual content, you need to add a translation for every language your entity could be seen through. Otherwise you get 'None' as a title (which is way too blurry and quite indescribable). Thanks to my colleague and friend lpetrov I found a way to pass through this limitation and print any possible translation if the current one is not available.
I've added a translation.py file in my project which I import in all my apps when necessary. Here there is the code:
- def get_local_str_or_other(obj, field_name):
- result = getattr(obj, field_name)
- if result:
- return result
- field_for_search = field_name + "_"
- translations = [getattr(obj, field_for_search + lang.replace("-","_")) for lang in settings.LANGUAGES]
- for translation in translations:
- if translation != None:
- return unicode(translation)
Later I import the function in my models and I redefine the __unicode__ function. If the name I want to print by default is the field 'title', we have the following:
- def __unicode__(self):
- return get_local_str_or_other(self, "title")
I found a great presentation on Django debugging from Simon Willison.
It's a presentation on "Django 101 in troubleshooting". You could find information how to address any errors from the error pages that django throws away, how to follow stack traces and how to debug information in variety of ways.
Simon pays attention to the basic and the core of all debugging tools - the console. Every single output pass through the console itself so it is the mother of all outputs. Other popular options is the python debugger under the pdb package.
I personally do like django-debug-toolbar for my apps. It is quite useful for taking care of the HTTP requests and response, passed variables across the website and so on. You could check the number of SQL queries and the load time of your website. Another important feature is printing the list of all templates used for rendering a web page. You could check the settings list for the current page load as well as the signals being called at the moment.