Error whil creating super user in django1.4 on MAC

I got the following error while trying to create a super user from shell for django1.4.

File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username
    return getpass.getuser().decode(locale.getdefaultlocale()[1])
TypeError: decode() argument 1 must be string, not None

This problem was rectified by running this command in terminal before adding the user
export LANG="en_US.UTF-8"

I’m guessing this character encoding problem while running syncdb is the reason for the following error while accessing admin section of django1.4

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
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: /Library/Python/2.7/site-
packages/Django-1.4-py2.7.egg/django/db/models/query.py in get, line
366
Python Executable: /usr/bin/python
Python Version: 2.7.1
Python Path:
['/Users/mohammedelsebaey/a/mysite1',
'/Library/Python/2.7/site-packages/Django-1.4-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/
python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7
/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/
python/PyObjC',
'/Library/Python/2.7/site-packages']

If i’m wrong you can solve the above problem by running this code i django shell

from django.contrib.sites.models import Site
Site.objects.create(pk=1)
This entry was posted in Django, PYTHON and tagged , . Bookmark the permalink.

Leave a Reply