Unable to create a superuser in Django, bugged? - django

I can't seem to create a superuser when prompted to our manually after the prompt(im using sqlite for a db if it is relevant). When I choose 'No' at the prompt it proceeds normally but when I choose 'Yes' here's what happens.
Peter-Buddemeyers-MacBook-Pro:mysite Pete$ python manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
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
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.6/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/Library/Python/2.6/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal
interactive=interactive, db=db)
File "/Library/Python/2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/Library/Python/2.6/site-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser
call_command("createsuperuser", interactive=True, database=db)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 150, in call_command
return klass.execute(*args, **defaults)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
default_username = get_default_username()
File "/Library/Python/2.6/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username
default_username = get_system_username()
File "/Library/Python/2.6/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
Has anyone any ideas ?

It seems that system locale is not set up correctly, therefore locale.getdefaultlocale() returns (None, None). Look at the output of locale to check if this is the case (details are in this document). The simplest solution would be to execute something like setenv LANG en_US.UTF-8 before running python manage.py syncdb.

Related

Unable to migrate, django.db.migrations.exceptions.MigrationSchemaMissing

I have no valuable data in my database and was unable to migrate, as you can see here:
ResetDjango postgresql database? flush does not work
I tried to reset the database using:
Delete migration files
Enter psql command prompt. Connect to database. drop schema public cascade; create schema public;
Step 2 unfortunately seemed to have removed my user role and rights so I went back to the psql command promt and recreated those.
Now I have tried to migrate again, and it still doesn't work. What might be wrong now?
vagrant#vagrant-ubuntu-trusty-64:/vagrant/grader$ python3 manage.py makemigrations
Migrations for 'core':
0001_initial.py:
- Create model Student
vagrant#vagrant-ubuntu-trusty-64:/vagrant/grader$ python3 manage.py migrate Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
psycopg2.ProgrammingError: no schema has been selected to create in
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/recorder.py", line 57, in ensure_schema
editor.create_model(self.Migration)
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/schema.py", line 284, in create_model
self.execute(sql, params or None)
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/schema.py", line 110, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.4/dist-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python3.4/dist-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: no schema has been selected to create in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/migrate.py", line 89, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/loader.py", line 176, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/usr/local/lib/python3.4/dist-packages/django/db/migrations/recorder.py", line 59, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (no schema has been selected to create in
)
Adding these two lines in settings.py at the top are important for mysql to connect:
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField']='datetime'

django db migration failed with postgres

I made some changes to my models and then ran a
python manage.py makemigrations
python manage.py migrate
and I got this traceback:
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, admin, study, auth, quiz, contenttypes, main
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying quiz.0013_auto_20151005_0644...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 154, in apply_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 67, in record_applied
self.migration_qs.create(app=app, name=name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 348, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 734, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 762, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 846, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 885, in _do_insert
using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 920, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 974, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "django_migrations_pkey"
DETAIL: Key (id)=(27) already exists.
I didn't know quite how to interpret the error that the primary key already exists. Strangely enough it added the field into the database because I was seeing it output on my site and when I ran a shell I could see that the fields were added and the default data 'that I chose' was populated.
I decided to run the migration again to see if it would pass after a second time and I got a different traceback...
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, admin, study, auth, quiz, contenttypes, main
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying quiz.0013_auto_20151005_0644...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 148, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards
field,
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 398, in add_field
self.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 111, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "lang1_back_to_choice" of relation "quiz_langpairinstructions" already exists
Now if I try it again I will always get the second traceback. I am wondering what I should do so I can make migrations in the futures. Why am I getting this error if everything appears to have gone smoothly in the db itself?
There is another way. Since you know the last id value in django_migrations table, say it is 100. Then, you need to do this:
ALTER SEQUENCE django_migrations_id_seq RESTART WITH 101;
I overlooked the name of the 'django_migrations_pkey' column and I didn't realize that was in the database. Somehow django was one step behind the actual database and trying to use the primary key (pk=27) instead of the number it was actually on (which should have been 28)
I was unsure about how to change this from within django so instead I just deleted the last column from the database so it was one primary key shorter and on track with django and it started working just fine.
I got this error after I had previously manually tinkered with the django migrations tables entries (after some previously dodgy migrations were added then removed).
This left the django_migrations IDs out of order (so to speak) with the default position of the entry in the django_migrations table.
The issue is that django takes the ID of the last entry and +1 to create a new entry (in table below: 197 + 1 = 198), however as you can see Key (id)=(198) already exists in the table.
187 | foo_app | 0016_auto_20161220_2332 | 2017-01-06 05:22:07.666172+00
198 | bar_app | 0004_auto_20160423_2122 | 2017-01-13 05:38:31.922738+00
197 | baz_app | 0013_auto_20170203_2311 | 2017-02-08 18:50:22.70143+00
As you can see the numbers for the primary key on the left are out of order.
What I did was manually delete the out of order entries in the django_migration then re-add them.
DELETE from django_migrations where name = '0004_auto_20160423_2122';
DELETE from django_migrations where name = '0013_auto_20170203_2311';
INSERT INTO django_migrations VALUES (188, 'baz_app', '0013_auto_20170203_2311', date());
INSERT INTO django_migrations VALUES (189, 'bar_app', '0004_auto_20160423_2122', date());
Also of note is that the migration that I was initially trying to add 'new_app, '0002_auto_00000000_1111' actually modified the new_app table in postgres, however the django_migrations table didn't get updated.
So the second time I tried to re-run the migration 0002_auto_00000000_1111 I got the error:
django.db.utils.ProgrammingError: column "new_app_field" of relation "new_app_new" already exists
My solution above fixed the problem for me.
Simply reindexing the django_migrations table worked for me.
Follow these steps in your terminal
Change user to root
$ sudo su
So that you can then then change user to postgres
$ su postgres
Open postgres terminal client with your db selected
$ psql name_of_your_db
In the postgres client issue the following command
REINDEX TABLE django_migrations;
And then quit the postgres client
\q

Custom user and django-registration-redux error when migrate

I just installed django-registration-redux, added 'registration' to INSTALLED_APPS and to urls, but when migrating, I get next error:
Synchronizing apps without migrations:
Creating tables...
Creating table core_brand
Creating table core_product
Creating table core_package
Creating table core_consignment
Creating table core_slider
Creating table core_slideritems
Creating table order_cart
Creating table order_order
Creating table order_orderproduct
Creating table registration_registrationprofile
Running deferred SQL...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 441, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 179, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 317, in sync_apps
cursor.execute(statement)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "login_customuser" does not exist
The problem is that I use CustomUser model. I do it in the next way: class
CustomUser(AbstractUser):
mobile = models.CharField(max_length=20)
address = models.CharField(max_length=100)
and in settings.py added AUTH_USER_MODEL = 'login.CustomUser'
Why does this error appear? Because, after this error, I looked into database tables and login_customuser exists.
You say you added login.customuser. The name is different from login_customuser you mentioned elsewhere. Try that to see if it works.
Aside from that, I advise you use makemigrations and migrate one after the other to have better results.

Django sqlite3 - an error when manage.py syncdb

I can't overcome a problem with making new sqlite3 database under django 1.6 app. When I am doing python manage.py syncdb then it allows me to create some tables like:
Creating table django_admin_log
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 django_content_type
Creating table django_session
...but after some tracebacks it finish with an error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/__init_
_.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/__init_
_.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/base.py
", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/base.py
", line 285, in execute
output = self.handle(*args, **options)
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/base.py
", line 415, in handle
return self.handle_noargs(**options)
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/command
s/syncdb.py", line 112, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/sql.py"
, line 216, in emit_post_sync_signal
interactive=interactive, db=db)
File "/usr/local/alwaysdata/python/django/1.6.1/django/dispatch/dispatcher.py"
, line 185, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/alwaysdata/python/django/1.6.1/django/contrib/auth/management
/__init__.py", line 82, in create_permissions
ctype = ContentType.objects.db_manager(db).get_for_model(klass)
File "/usr/local/alwaysdata/python/django/1.6.1/django/contrib/contenttypes/mo
dels.py", line 47, in get_for_model
defaults = {'name': smart_text(opts.verbose_name_raw)},
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/models/manager.py",
line 154, in get_or_create
return self.get_queryset().get_or_create(**kwargs)
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/models/query.py", li
ne 388, in get_or_create
six.reraise(*exc_info)
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/models/query.py", li
ne 379, in get_or_create
with transaction.atomic(using=self.db):
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/transaction.py", lin
e 277, in __enter__
connection._start_transaction_under_autocommit()
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/sqlite3/bas
e.py", line 436, in _start_transaction_under_autocommit
self.cursor().execute("BEGIN")
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/util.py", l
ine 69, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/util.py", l
ine 53, in execute
return self.cursor.execute(sql, params)
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/utils.py", line 99,
in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/util.py", l
ine 51, in execute
return self.cursor.execute(sql)
File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/sqlite3/bas
e.py", line 448, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: cannot start a transaction within a transaction
My settings my include:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'database.db',
}
}
I don't know how to solve this problem. Could someone help me, please?
I assume you are using the hosting service of Alwaysdata because I Googled this problem and here is the same question on Alwaysdata's forum: Django sqlite3 - an error when manage.py syncdb.
The way I solve this problem is switching to a lower version of Django (e.g. 1.5.5) in my Alwaysdata admin page. Then the db file can be created successfully.
I still have not got the reason why this happens.

Relational DatabaseError in django postgresql database after deploying project to bitnami

I am deploying my django project using amazon ec2 and the bitnami-djangostack ami.
While I was developing the app locally I used mysql. But after deploying the project I used the default for bitnami postgresql.
Now I am getting the following error:
django.db.utils.DatabaseError: relation "appName_appName" does not exist
LINE 1: SELECT (1) AS "a" FROM "appName_appName" WHERE "appName_a...
^
I don't know why the database is naming the database twice (appName_appName).
here is the full terminal:
bitnami#dom:/opt/bitnami/projects/Project$ sudo python manage.py syncdb
/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
DeprecationWarning
/opt/bitnami/projects/Project/cookbook/models.py:94: DeprecationWarning: A Field class whose db_type method hasn't been updated to take a `connection` argument.
class JSONField(models.TextField):
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table registration_registrationprofile
Creating table south_migrationhistory
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): yesa
Please enter either "yes" or "no": yes
Username (Leave blank to use 'root'): xxxx
E-mail address: xxxxx
Password: xxx
Password (again): xxx
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/opt/bitnami/python/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/management/commands/syncdb.py", line 90, in handle_noargs
syncdb.Command().execute(**options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
interactive=interactive, db=db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 70, in create_superuser
call_command("createsuperuser", interactive=True)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 134, in handle
User.objects.create_superuser(username, email, password)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/models.py", line 140, in create_superuser
u = self.create_user(username, email, password)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/models.py", line 136, in create_user
user.save(using=self._db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/base.py", line 570, in save_base
created=(not record_exists), raw=raw, using=using)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/opt/bitnami/projects/Project/cookbook/models.py", line 68, in create_cookbook_for_user
if created and not instance.cookbooks.exists():
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/manager.py", line 192, in exists
return self.get_query_set().exists(*args, **kwargs)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/query.py", line 496, in exists
return self.query.has_results(using=self.db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/sql/query.py", line 424, in has_results
return bool(compiler.execute_sql(SINGLE))
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: relation "appName_appName" does not exist
LINE 1: SELECT (1) AS "a" FROM "appName_appName" WHERE "appName_a...
^
thank you,
katie
I just added the appname_appname to my database and it now works fine.
sorry to mislead - my mistake. I still don't understand why the piece of code wasn't being added to the database on syncdb to begin with though.
but all is well now