First time here? Check out the FAQ!
2

syncdb can't create admin in Django >= 1.5

Hello, I installed askbot as a part of my project, and it works pretty well but I recently noticed a problem in the admin creation phase when running (python mnage.py syncdb) I get this error : NameError: "global name 'User' is not defined"

I tried Django 1.5, 1.5.4 and I still have same problem I had no problems with django 1.4

Any ideas what is the problem?

6455260's avatar
21
6455260
asked 2013-10-30 12:44:22 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2013-10-30 14:19:33 -0600
edit flag offensive 0 remove flag close merge delete

Comments

Which commands do you type? Can you reproduce this issue with "askbot-only" installation?

Evgeny's avatar Evgeny (2013-10-30 14:19:12 -0600) edit

1- I installed askbot 2- I used django (1.5) as askbot-setup doesn't work for higher versions 3- I ran askbot-setup 4- I chose sqlite3, db name = database.db 5- I entered the standalone installation of askbot, and removed the database file (rm database.db) 6- I ran : python manage.py syncdb 7- I chose to add admin 8- I got the error : NameError: global name 'User' is not defined 9- I removed django 1.5 and installed django 1.4 10- I removed the database (rm database.db) 11- I ran : python manage.py syncdb 12 when prompted to add an admin, I chose YES and everything went OK and I was managed to add admin user successfull

6455260's avatar 6455260 (2013-10-30 15:58:18 -0600) edit

btw, I tried to edit the previous comment and add new lines , but it seems askbot ignoring me :)

6455260's avatar 6455260 (2013-10-30 16:05:54 -0600) edit

I am having the same problem. Fresh install askbot in a vritualenv (askbot only). Followed all the official documetnation installation steps. `pip install askbot`. when I follow this step: http://askbot.org/doc/initialize-database-tables.html, and run `python manage.py syncdb`, the following is the output:

Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table auth_message
...
Creating table djkombu_queue
Creating table djkombu_message
Creating table followit_followuser

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
NameError: global name 'User' is not defined

sgon00's avatar sgon00 (2013-11-04 03:41:52 -0600) edit
1

I have the same problem with a brand new installation of askbot and postgresql

Dr.Dran's avatar Dr.Dran (2013-11-09 09:18:54 -0600) edit
add a comment see more comments

1 Answer

1

I had the same problem on a new install of askbot & postgresql. Make sure that you answer NO to creating an admin account. After getting the NameError: global name 'User' is not defined, run:

  python manage.py migrate askbot

You'll get lots of errors but after completion, you should be able to launch the site with:

  python manage.py runserver `hostname -i`:8000

At least it works for you me...

thinkwell's avatar
26
thinkwell
answered 2013-11-15 18:25:06 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2013-11-25 14:24:28 -0600
edit flag offensive 0 remove flag delete link

Comments

This may be due to our patching the `auth.User` model and django's new way of allowing custom user models.

Evgeny's avatar Evgeny (2013-11-25 14:24:01 -0600) edit

Also you can use command `python manage.py syncdb --migrate --noinput`. This migrates and syncdb's in one and avoids the create admin issue.

Evgeny's avatar Evgeny (2013-11-25 14:26:24 -0600) edit
add a comment see more comments