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?

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
6455260's avatar
21
6455260
asked 11 years ago
Evgeny's avatar
13.2k
Evgeny
updated 11 years ago

Comments

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

Evgeny's avatar Evgeny (11 years ago)

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 (11 years ago)

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

6455260's avatar 6455260 (11 years ago)

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 (11 years ago)
1

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

Dr.Dran's avatar Dr.Dran (11 years ago)
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...

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
thinkwell's avatar
26
thinkwell
answered 11 years ago
Evgeny's avatar
13.2k
Evgeny
updated 11 years ago
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 (11 years ago)

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 (11 years ago)
see more comments