Hi Raitucarp,

you can use the convert_to_south command to convert an existing app (with existing database tables) to south.
In your case a

manage.py migrate ngobrol 0001 --fake

followed by a "manage.py migrate ngobrol" should fix your issue (given that you ran south initially, before changing the model).

Reference:

http://south.readthedocs.org/en/latest/convertinganapp.html

Good luck!

hendrik

On 06/10/2012 09:00 PM, Raitucarp wrote:
'ENGINE': 'django.db.backends.sqlite3'

I have a model such this:

class Ngobrol(models.Model):
         title = models.CharField(max_length=200, blank = True)
         message = models.TextField('Message')
         linkp  = models.URLField(max_length=255, blank = True)
         meta_data = models.TextField('Meta data', blank=True)
         hash_tags = models.CharField(max_length=255, blank=True)
         pub_date = models.DateTimeField('Date Posted')

         def short_message(self):
             return self.message[:50]

         def __unicode__(self):
             return self.title

And I add some data (about 20 data) to it. Then, I add one column name
aa

aa = models.CharField(max_length = 10, blank = True)

I ran manage.py syncdb, and access to my admin: 
http://localhost:8000/admin/ngobrol/ngobrol/
I got:

DatabaseError at /admin/ngobrol/ngobrol/
no such column: ngobrol_ngobrol.aa

So, I install south, I got this error:

manage.py migrate ngobrol
Running migrations for ngobrol:
  - Migrating forwards to 0001_initial.
  >  ngobrol:0001_initial
FATAL ERROR - The following SQL query failed: CREATE TABLE
"ngobrol_ngobrol" ("i
d" integer NOT NULL PRIMARY KEY, "title" varchar(200) NOT NULL,
"message" text N
OT NULL, "linkp" varchar(255) NOT NULL, "aa" varchar(10) NOT NULL,
"meta_data" t
ext NOT NULL, "hash_tags" varchar(255) NOT NULL, "pub_date" datetime
NOT NULL);
The error was: table "ngobrol_ngobrol" already exists
  ! Error found during real run of migration! Aborting.

  ! Since you have a database that does not support running
  ! schema-altering statements in transactions, we have had
  ! to leave it in an interim state between migrations.

! You *might* be able to recover with:   = DROP TABLE
"ngobrol_ngobrol"; []
    = DROP TABLE "ngobrol_comment"; []

  ! The South developers regret this has happened, and would
  ! like to gently persuade you to consider a slightly
  ! easier-to-deal-with DBMS (one that supports DDL transactions)
  ! NOTE: The error which caused the migration to fail is further up.
Error in migration: ngobrol:0001_initial
Traceback (most recent call last):
   File "E:\sasisu\manage.py", line 10, in<module>
     execute_from_command_line(sys.argv)
   File "E:\Python27\lib\site-packages\django\core\management
\__init__.py", line
443, in execute_from_command_line
     utility.execute()
   File "E:\Python27\lib\site-packages\django\core\management
\__init__.py", line
382, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "E:\Python27\lib\site-packages\django\core\management\base.py",
line 196,
  in run_from_argv
     self.execute(*args, **options.__dict__)
   File "E:\Python27\lib\site-packages\django\core\management\base.py",
line 232,
  in execute
     output = self.handle(*args, **options)
   File "E:\Python27\lib\site-packages\south\management\commands
\migrate.py", lin
e 107, in handle
     ignore_ghosts = ignore_ghosts,
   File "E:\Python27\lib\site-packages\south\migration\__init__.py",
line 219, in
  migrate_app
     success = migrator.migrate_many(target, workplan, database)
   File "E:\Python27\lib\site-packages\south\migration\migrators.py",
line 235, i
n migrate_many
     result = migrator.__class__.migrate_many(migrator, target,
migrations, datab
ase)
   File "E:\Python27\lib\site-packages\south\migration\migrators.py",
line 310, i
n migrate_many
     result = self.migrate(migration, database)
   File "E:\Python27\lib\site-packages\south\migration\migrators.py",
line 133, i
n migrate
     result = self.run(migration)
   File "E:\Python27\lib\site-packages\south\migration\migrators.py",
line 107, i
n run
     return self.run_migration(migration)
   File "E:\Python27\lib\site-packages\south\migration\migrators.py",
line 81, in
  run_migration
     migration_function()
   File "E:\Python27\lib\site-packages\south\migration\migrators.py",
line 57, in
  <lambda>
     return (lambda: direction(orm))
   File "E:\sasisu\ngobrol\migrations\0001_initial.py", line 20, in
forwards
     ('pub_date', self.gf('django.db.models.fields.DateTimeField')()),
   File "E:\Python27\lib\site-packages\south\db\generic.py", line 44,
in _cache_c
lear
     return func(self, table, *args, **opts)
   File "E:\Python27\lib\site-packages\south\db\generic.py", line 348,
in create_
table
     ', '.join([col for col in columns if col]),
   File "E:\Python27\lib\site-packages\south\db\generic.py", line 273,
in execute

     cursor.execute(sql, params)
   File "E:\Python27\lib\site-packages\django\db\backends\util.py",
line 40, in e
xecute
     return self.cursor.execute(sql, params)
   File "E:\Python27\lib\site-packages\django\db\backends
\sqlite3\base.py", line
337, in execute
     return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: table "ngobrol_ngobrol" already exists

Please help to resolve this problem. Thanks


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to