OpenMOOC / moocng

MOOC Engine
Apache License 2.0
88 stars 43 forks source link

Create superuser with "openmooc-moocng-admin syncdb" is broken. #65

Open jlsalvador opened 10 years ago

jlsalvador commented 10 years ago

If you ask "yes" to the question "Would you like to create one now? (yes/no)", the script fails:

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
Username (leave blank to use 'root'): 
E-mail address: admin@example.com
Password: 
Password (again): 
Traceback (most recent call last):
  File "/usr/bin/openmooc-moocng-admin", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.6/site-packages/south/management/commands/syncdb.py", line 90, in handle_noargs
    syncdb.Command().execute(**options)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/usr/lib/python2.6/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser
    call_command("createsuperuser", interactive=True, database=db)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 124, in handle
    User.objects.db_manager(database).create_superuser(username, email, password)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/models.py", line 164, in create_superuser
    u = self.create_user(username, email, password)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/models.py", line 160, in create_user
    user.save(using=self._db)
  File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 463, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 565, in save_base
    created=(not record_exists), raw=raw, using=using)
  File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/lib/python2.6/site-packages/moocng/profile/models.py", line 44, in create_user_profile
    profile = instance.get_profile()
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/models.py", line 400, in get_profile
    self._state.db).get(user__id__exact=self.id)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 361, in get
    num = len(clone)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 85, in __len__
    self._result_cache = list(self.iterator())
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 291, in iterator
    for row in compiler.results_iter():
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 763, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
    return self.cursor.execute(query, args)
django.db.utils.DatabaseError: relation "profile_userprofile" does not exist
LINE 1: ..."profile_userprofile"."last_announcement_id" FROM "profile_u...
neokore commented 10 years ago

Hello, José Luis. I'm trying to install OpenMOOC from the sources in Ubuntu, but I'm stuck in this bug. Is there any known workaround to continue? If not, I guess I have to try creating the superuser by hand.

Thanks!

jlsalvador commented 10 years ago

Hello @neokore

See https://github.com/OpenMOOC/documentation/blob/master/source/configure/moocng.rst#copy-the-static-files about how to trick this issue.

openmooc-moocng-admin syncdb

openmooc-moocng-admin migrate

openmooc-moocng-admin createsuperuser --username=root --email=admin@example.com

I think that these issues will be fixed before we reach the end of the month.

neokore commented 10 years ago

Thank you @jlsalvador, it worked, but changing the command names: openmooc-moocng-admin syncdb => django-admin.py syncdb --settings=moocng.settings openmooc-moocng-admin migrate => ./manage.py migrate openmooc-moocng-admin createsuperuser --username=root --email=admin@example.com => ./manage.py createsuperuser --username=root --email=admin@example.com

That's because I don't have the openmooc-moocng-admin script file (I created it later).