Am 03.06.2014 16:27, schrieb Erik Cederstrand:
> Den 03/06/2014 kl. 15.57 skrev Thomas Güttler <
h...@tbz-pariv.de>:
>
>> I am a software developer and like the way django ORM defines the database (via models.py) very much.
>>
>> Unfortunately for a new project, we have the constraint, that the admin must be able
>> to add some columns. The admin is not a developer, and he only uses a web interface.
>>
>> I don't want to make model.py files editable via an admin interface, since running migrations and all
>> that does not fit into "web editable".
>
> Are you *really* sure you want to do this? Monkey-patching running code, adding class attributes and inserting database columns on the fly to a production system isn't something recommended in textbooks. Try describing your situation a bit. Maybe you could use a key-value approach and m2m relations instead?
I am sure: I don't want it. I guess you have read my post too fast.
> Another possibility is that you avoid editing models.py by creating the new database column manually using raw SQL, so Django doesn't know about it. Then override __getattr__ on the model so my_obj.extra_col_123 circumvents the ORM and fetches data by other means, or simply issue raw SQL when you need to access 'extra_col_123' in your code.
Yes, this would be a solution.
Thank you for your feedback.