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? If you *really* want to do it, and you want to edit models.py, then you should schedule an external task that appends the column to models.py (and commits the change to your VCS, adds tests, ...) and deploys the new code on your server. 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. Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/BD86175C-64BB-4258-8296-52D021529D39%40cederstrand.dk. For more options, visit https://groups.google.com/d/optout.