manage.py syncdb not working

928 views
Skip to first unread message

Sithembewena Lloyd Dube

unread,
Aug 24, 2010, 10:17:54 AM8/24/10
to django...@googlegroups.com
Hi all,

I have been working on some models and tried to run the manage.py syncdb command. It says there are no fixtures found even after I just added a field to a model.

A solution has been to drop the table in MySQL before running syncdb. This doesn't seem feasible all the time. What could I be doing wrong?

Thanks

--
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

Renne Rocha

unread,
Aug 24, 2010, 10:28:26 AM8/24/10
to django...@googlegroups.com
Hello,

It is correct. Syncdb will not alter existing tables:

http://docs.djangoproject.com/en/1.2/ref/django-admin/#syncdb

The reason is that if you've changed you model with some kind of
constrains (unique fields, etc), Django will not try to guess how to
mantain the correctness of your data. It is your task.

  Renne Rocha
  renne...@gmail.com
  http://www.linkedin.com/in/rennerocha

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

Reinout van Rees

unread,
Aug 24, 2010, 10:31:05 AM8/24/10
to django...@googlegroups.com
On 08/24/2010 04:17 PM, Sithembewena Lloyd Dube wrote:
> Hi all,
>
> I have been working on some models and tried to run the manage.py syncdb
> command. It says there are no fixtures found even after I just added a
> field to a model.

No fixtures found: it means to tell you that it didn't find any
special-named "initial_data" fixtures.

Regular fixtures must/can be loaded with "manage.py loaddata fixturename".

> A solution has been to drop the table in MySQL before running syncdb.
> This doesn't seem feasible all the time. What could I be doing wrong?

It is a (sensible) restriction of syncdb: it only creates missing
tables. If you modified a table, the table is still there, so it won't
re-add it. Doing so would mean potential data corruption.

So if you added fields to a model, you'll have to add that field by hand
to the table.

An alternative is for instance South (http://south.aeracode.org/) which
*can* do the database migration for you, also in the case of added fields.

Reinout

--
Reinout van Rees - rei...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

Sithembewena Lloyd Dube

unread,
Aug 24, 2010, 10:43:17 AM8/24/10
to django...@googlegroups.com
Thanks Reinout. I have been seeing a lot of discussions regarding South lately - time to dive in and find out what it is and what it means for me.

I was under the impression that Django would add a field to my table. So, is syncdb only good during initial database setup?

Many thanks,

Lloyd




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

Nick Arnett

unread,
Aug 24, 2010, 10:56:46 AM8/24/10
to django...@googlegroups.com
On Tue, Aug 24, 2010 at 7:43 AM, Sithembewena Lloyd Dube <zeb...@gmail.com> wrote:
Thanks Reinout. I have been seeing a lot of discussions regarding South lately - time to dive in and find out what it is and what it means for me.

I was under the impression that Django would add a field to my table. So, is syncdb only good during initial database setup?

That is essentially correct, though I have modified tables by renaming the old one, letting syncdb recreate it, then copy the old data into the new table.  However, due to foreign keys, that's not as simple as it might sound.  Early in development, I have also let syncdb create a whole new database, then copied the old data into it.

Come to think of it, I have also sometimes created a modified table under a temporary name, so that I can see what Django would have done if it were a new setup, so that I can modify the old table manually to match how Django would have done it automatically (and then drop the temporary table).

Nick

Sithembewena Lloyd Dube

unread,
Aug 24, 2010, 11:17:46 AM8/24/10
to django...@googlegroups.com
Thanks Nick - this echoes a thought that occured to me i.e. "create new table, copy data". The issue with constraints is what kept me from trying this out (remembered previous jobs updating SQL Server schemas - not fun with live data).

Regards,
Lloyd

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

Sells, Fred

unread,
Aug 24, 2010, 9:22:10 PM8/24/10
to django...@googlegroups.com

During development phase, I actually drop and recreate my database, then run syncdb etc to make sure I’ve got a clean start.  Probably not practical once I get into production.

--

!!CONDORIOUS!!

unread,
Aug 24, 2010, 9:46:54 PM8/24/10
to django...@googlegroups.com
I am constantly updating the database model. I have tried South but
still feel like the simplest most intuitive way to update a update an
existing project's database is to manually create the fields using
phpMyAdmin. Two steps

1. Add/Update field model.py
2. Add/Update in database to match (phpMyAdmin makes life so much simpler).

--
Condor
310.951.1177
condo...@gmail.com

:%s/war/peace/g

davidchambers

unread,
Aug 25, 2010, 9:50:55 AM8/25/10
to Django users
If you're interested in something _much_ nicer than phpMyAdmin and
you're on OS X, check out Querious or Sequel Pro. I've found Django
development about 25% more enjoyable since switching from browser-
based software to desktop software for database management (both local
and remote).

David


On Aug 25, 1:46 pm, "!!CONDORIOUS!!" <condor.c...@gmail.com> wrote:
> I am constantly updating the database model.  I have tried South but
> still feel like the simplest most intuitive way to update a update an
> existing project's database is to manually create the fields using
> phpMyAdmin.  Two steps
>
> 1.  Add/Update field model.py
> 2.  Add/Update in database to match (phpMyAdmin makes life so much simpler).
>
> On Tue, Aug 24, 2010 at 6:22 PM, Sells, Fred
>
>
>
>
>
> <fred.se...@adventistcare.org> wrote:
> > During development phase, I actually drop and recreate my database, then run
> > syncdb etc to make sure I’ve got a clean start.  Probably not practical once
> > I get into production.
>
> > From: django...@googlegroups.com [mailto:django...@googlegroups.com]
> > On Behalf Of Nick Arnett
> > Sent: Tuesday, August 24, 2010 10:57 AM
> > To: django...@googlegroups.com
> > Subject: Re: manage.py syncdb not working
>
> > On Tue, Aug 24, 2010 at 7:43 AM, Sithembewena Lloyd Dube <zebr...@gmail.com>
> condor.c...@gmail.com
>
> :%s/war/peace/g
Reply all
Reply to author
Forward
0 new messages