On Sunday 18 October 2009 13:57:58 Shakefu wrote:
> > > a first working implementation of my models (remember you can test
> > > your models from the interactive shell and/or python scripts).
> >
> > Or write unit tests, which are more suited for testing than loose
> > bunch of scripts
> 
> Well, I certainly have noticed that a lot of guides/tutorials/snippets
> start with models and then write the rest of the required code in
> varying order.
> 
> Is there any downside to starting with the models first?


The biggest one is that if you decide later to add a field to the model that 
isn't there and you've filled in some data to the db. Syncdb is ineffective at 
updating the table so you either drop the table and reload the data as a 
fixture with the added field data, or start again with data or use a db 
migration tool like django evolution.


I tend to start with the models first and when I add a field, I just use alter 
to update the table in place. This has a gotcha with NOT NULL though, if you 
don't specify a default you'll end up with an error.  To bypass this error, I 
usually don't add the NOT NULL constraint till after I've added the field and 
updated the existing rows with the required data. 

This may not be the best approach to it, but it works for me and is fast 
enough and requires less prep time for using such tools as evolution and the 
like (no need to install or learn them) and/or editting fixtures.

Mike
How do I get HOME?

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to