Re: Model with several ManyToManyFields - related_name problem
Hiya, thanks for the reply. So in this case the extra fields are actually denormalized subsets of the original field, and the reverse relation can use the main field. (At least, at the moment, that's my plan, but that could change. Which I guess goes to show how rare this case probably actually is.) But you can see that with the data being so similar on each many-to-many table, I'd want to avoid confusing the other model with a set of extra properties that aren't so useful and will have similar names! So I guess there might be other cases where you likewise didn't want to create a confusing backwards relation, and the '+' behaviour might be expected to work as the documentation suggests (to me) that it might. Incidentally I'm a bit confused about the naming of ManyToMany fields: the examples tend to name them in the plural sites = models.ManyToManyField(Site, verbose_name="list of sites") but the backwards relation gets created with a singular name (inevitably I guess, because that's what the system can work out). It seems a bit inconsistent? cheers George -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model with several ManyToManyFields - related_name problem
Hello, I believe you need related_name, for disambiguation at least. Maybe by setting a db_table you can bypass the related_name but I'm not convinced. Actually, I'm "parasiting" your post to ask when "[we]'d prefer Django didn't create a backwards relation"? Regards, -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Model with several ManyToManyFields - related_name problem
I have a model with more than one (3 in fact) ManyToManyFields which point to the same other model. As long as I specify distinct related_names for each, all is well. But the documentation [1] suggests that if I don't need the backwards relation, then specifying '+' as the related_name should work. But I don't seem to be able to specify '+' for more than one of the fields: I get a 'reverse query clashes' error. Is this expected? It feels like a bug (i.e. I'd expect all fields with related_name="+" to be ignored for this check). TIA George [1: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name ] -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.