BryanWheelock
BryanWheelock

Reputation: 12244

How do I add a new model and generate the migrations with South 0.7.2?

I created a new model:

class RssFeed(models.Model):  
  url = mdels.CharField(max_length=300)  

$ python manage.py schemamigration forum --add-model RssFeed

  Traceback (most recent call last):
    File "manage.py", line 13, in <module>
      execute_manager(settings)
    File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/__init__.py", line 438, in execute_manager
      utility.execute()
    File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/__init__.py", line 379, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/base.py", line 191, in run_from_argv
      self.execute(*args, **options.__dict__)
    File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/base.py", line 220, in execute
      output = self.handle(*args, **options)
    File "/usr/local/lib/python2.7/site-packages/South-0.7.2-py2.7.egg/south/management/commands/schemamigration.py", line 134, in handle
      for action_name, params in change_source.get_changes():
    File "/usr/local/lib/python2.7/site-packages/South-0.7.2-py2.7.egg/south/creator/changes.py", line 397, in get_changes
      real_fields, meta, m2m_fields = self.split_model_def(model, model_defs[model_key(model)])
    File "/usr/local/lib/python2.7/site-packages/South-0.7.2-py2.7.egg/south/creator/freezer.py", line 58, in model_key
      return "%s.%s" % (model._meta.app_label, model._meta.object_name.lower())
  AttributeError: 'NoneType' object has no attribute '_meta'

Upvotes: 3

Views: 1974

Answers (1)

BryanWheelock
BryanWheelock

Reputation: 12244

My syntax was correct, the way I had created the model wasn't.

I had placed all my models into a directory /models

If you do this, you must add Meta to your model definition:

class Meta:  
   app_label = 'APP_NAME'

If you don't do this, Django can't discover the new models.

Upvotes: 11

Related Questions