1 2 3 4 | class ManyToManyField_NoSyncdb(models.ManyToManyField):
def __init__(self, *args, **kwargs):
super(ManyToManyField_NoSyncdb, self).__init__(*args, **kwargs)
self.creates_table = False
|
More like this
- Limit queryset to objects related to parent in ManyToMany fields within admin inlines by DrMeers 2 years, 12 months ago
- unique_together with many to many fields by j4nu5 1 year, 8 months ago
- Database file storage by powerfox 4 years, 3 months ago
- Display user-friendly values of a ManyToManyRawIdWidget by luc_j 2 years, 10 months ago
- Link raw_id_fields (both ForeignKeys and ManyToManyFields) to their change pages by EmilStenstrom 2 years, 7 months ago
Comments
Thanks, this was very useful to me, because i have m2m relationships that i want to look at from both directions.
In fact, it seems useful enough that it might be handy to have a creates_table argument to the built-in ManyToManyField (defaults to True), so this workaround wouldn't be necessary.
#
Warning! This snippet fails in Django 1.2.3 since the Field property "creates_table" appears to no longer be supported. It tries to create the table which generates a "duplicate table" error.
#