|Reported by:||lsaffre||Owned by:||nobody|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||yes|
|Needs tests:||no||Patch needs improvement:||no|
I think that a new "non-(de)serializing" type of fixtures might be useful.
If loaddata finds a fixture of this type, then it simply executes it, assuming it is valid Python code.
Example of how such a fixture might look:
from myapp import MyModel def add_mymodel(field1,field2,field3): MyModel(field1,field2,field3) add_mymodel("a",1,True) add_mymodel("b",2,True) add_mymodel("c",3,True)
This example is only one possible application; in fact the programmer is free to write more sophisticated scripts, for example fetch data from different external sources (including csv files), or fill the database with randomly generated data,..
Such fixtures would offer the special characteristic that they execute custom save methods.
They would of course be slower than normal fixtures.
We can also extend dumpdata to support this format, outputting python code as in the example above.
This would be useful when converting a database after model changes.
Change History (7)
comment:1 Changed 7 years ago by jacob
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:3 follow-up: ↓ 6 Changed 7 years ago by lsaffre
- Needs documentation set
comment:4 Changed 7 years ago by thejaswi_puthraya
- Component changed from django-admin.py to Serialization