Hick
Hick

Reputation: 36404

How to automate creating models in django?

My models are generated from the shapefiles by using ogrinspect . But , after the creation of the model , lets say the user want to add an additional attribute . For this , the new attribute should be reflected in two tables . One should contain the name of the attribute , the other the attribute as a column . The name of the attribute doesnt need a change in model , and can be easily taken care of . But how to add an attribute to a table which was generated automatically ?

Upvotes: 3

Views: 139

Answers (2)

adamnfish
adamnfish

Reputation: 11255

You may be able to use South to manage changes changes to your models. Whenever the model is changed you can run schemamigration --auto <appname> to create a migration and then migrate <appname> to apply it. This will create the tables in your model.

If you expect the models in your application to be changing a lot - particularly if it can be changed by end-users, you are probably thinking about it the wrong way. You may need to think about re-designing your information schema so it is more flexible!

If you have any more information about what you are trying to achieve, we may be able to offer suggestions!

Upvotes: 2

DrTyrsa
DrTyrsa

Reputation: 31951

Use post_save signal. (docs)

Upvotes: 0

Related Questions