Reputation: 12666
I'm working on a new django project and following this tutorial. I'm at the step "Using South for Database Migrations", attempting to run python manage.py syncdb
, and I'm getting the following error:
(editorial)[hookedonwinter@hookedonwinter editorial (master *)]$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/django/core/management/__init__.py", line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/south/management/commands/__init__.py", line 13, in <module>
from south.management.commands.syncdb import Command as SyncCommand
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/south/management/commands/syncdb.py", line 18, in <module>
from south import migration
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/south/migration/__init__.py", line 11, in <module>
from south.models import MigrationHistory
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/south/models.py", line 4, in <module>
class MigrationHistory(models.Model):
File "/Users/hookedonwinter/.virtualenvs/editorial/lib/python2.6/site-packages/django/db/models/base.py", line 97, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
TypeError: Error when calling the metaclass bases
__init__() keywords must be strings
Here is my settings.py file: https://gist.github.com/pjhoberman/5273653
There are no apps yet, just an empty project. I'm guessing it's a simple overlook on my part - any thoughts?
Edit
From the comments:
I don't have any models yet. Just following that tutorial, I'm trying to start with South before I do any model work.
Versions:
If I comment out south in settings.py, I get this error:
$ python manage.py syncdb
TypeError: Error when calling the metaclass bases __init__() keywords must be strings
Edit2
I started over and used django 1.4, and it works.
Edit3
I updated python to 2.7 and used django 1.5, and it all works as well.
Upvotes: 1
Views: 1190
Reputation: 1704
You need Python 2.6.5+ to run Django 1.5. That's why downgrading to Django 1.4 or upgrading to Python 2.7 was what solved your problem.
https://docs.djangoproject.com/en/dev/releases/1.5/#python-compatibility
Upvotes: 0
Reputation: 9660
The "TypeError" at the bottom is the solution. You get this error from Django 1.5 if you use a Python version lower than 2.6.5. There is a Django bug report and a SO discussion on the issue. Arguably the error message is less than intuitive.
The OP is right, none of the answers solved this problem. The solutions are: 1) upgrade Python to 2.7, 2) downgrade Django to 1.4.
Upvotes: 2
Reputation: 12666
I updated python to 2.7 and used django 1.5, and it all works as well.
None of the answers actually solved the problem, so I'm answering it myself since I can't delete the question now that there's bounty.
Upvotes: 1
Reputation: 8488
I think the problem is with that "~" character you have on your database setting. Try putting #coding=utf-8
as the first or second line of your settings and see what happen.
If that doesn't resolve your problem, change the database filename for one on the same directory of manage.py
file like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'databasename.sql',
}
}
I tried making a new environment following that tutorial you post and i have no problem. But when i tried to use a database name as you were trying (the one with "~" in its name) i get this error:
(env) user@pc:/path >$ python manage.py syncdb --noinput
Syncing...
OperationalError: unable to open database file
I bet that symbol is the root of your problem... Tell us if this solved your problem!
Upvotes: 1
Reputation: 2877
It seems a DB config problem, try this. On the top of the file:
import os
then:
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_DIR, 'yourdatabasename.db'),
}
}
And finally a syncdb should do the trick. Also you can try "python manage.py reset south" to fix possible problems in the APP. If this doesn't work i suggest you start a new problem to discard other errors.
Original post: Django setup with sqlite3?
Upvotes: 0
Reputation: 331
South is very well documented and i'm sure you'll be clear after going through it.
This is the tutorial.
http://south.readthedocs.org/en/0.7.6/tutorial/part1.html
Still to make life simpler..
1) Download south and add it to your apps directory.
2) Add 'south' to INSTALLED APPS in settings.py
3) Run syncdb
4) $ ./manage.py schemamigration appname --initial
5) $ ./manage.py migrate appname
This is all you need for a very basic start.
Upvotes: 0