i'm trying to dynamically add m2m field to model, any tips on how to
make it work?
# models.py
# after MyModel definition
if getattr(settings, 'MYMODEL_M2M', False):
app_label, model_name = settings.MYMODEL_M2M
model = models.get_model(app_label, model_name)
new_field = "%s_m2m" % model_name
setattr(MyModel, new_field, models.ManyToManyField(model))
opts = MyModel._meta
setattr(opts, new_field, new_field)
Aljosa Mohorovic
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---