Wednesday, January 27, 2016

Re: help with ManyToMany

your code is correct,where are the problem ?in the admin first add Studio and sfter this select on the field studio from class studiogroup one or more entries from the class studio so simple,

christos

Τη Τετάρτη, 27 Ιανουαρίου 2016 - 5:50:21 μ.μ. UTC+2, ο χρήστης dave.l έγραψε:
Hi,

I have recently returned to a Django project after a few years and I'm a little rusty on ManyToMany fields.

Here's my very simple models:


class Studio(models.Model):
    name
= models.CharField(max_length=255, unique=True)

class StudioGroup(models.Model):
    description
= models.CharField(max_length=255, unique=True)
    studio
= models.ManyToManyField(Studio)


So a bunch of Studio(), which can be in multiple StudioGroups()

Given a single instance of a Studio(), I would like a single list of all other studios in all other groups.

so if Group1 is A,B,C and Group2 is A,D,E

I would like to return B,C,D,E for A.

My current solution is entirely in Python (which works), but I'd like a more Django-esque solultion of possible!

Thank you,

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b2e5699-8365-4827-8803-59160e746b18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment