Ok, thanks for the reply.  I had wondered along those lines myself, and
changed the code to;

class elements(models.Model):
   name=models.CharField(max_length=21)
   elementgroup=models.ForeignKey(grouping)

class grouping(models.Model):
   name=models.CharField(max_length=48)

Though now when using the admin interface, when viewing the 'change
groupings' screen, I get no way to say what elements are in the group, that
assignment can only be made in the 'change elements' page.

Is there any way to get the behavior I'm after using the admin interface? or
would I need to look at writing a new view say, 'manage groupings' , or
would it be better to find similar functionality in a relevant class and
extend it?

thanks,

Matt.



On 6 March 2010 19:44, Christophe Pettus <x...@thebuild.com> wrote:

>
> On Mar 6, 2010, at 10:37 AM, Matthew Warren wrote:
>
>  Hi,
>>
>> I have a model like the following;
>>
>> class elements(models.Model):
>>    name=models.CharField(max_length=21)
>>
>>
>> class grouping(models.Model):
>>    name=models.CharField(max_length=48)
>>    elementgroup=models.ForeignKey(elements)
>>
>>
>>
>> I'm assuming this means that a grouping may relate to multiple elements,
>> but an element may only be related to a single group.
>>
>
> It's the other way around.  As written, a grouping can only relate to a
> single element, but each element can have any number of groupings.  You can
> think of the ForeignKey field a pointer, pointing from the grouping to the
> element.  It's a real field, so it can only have one value per instance.  If
> what you want is for one element to only have a single grouping, but each
> grouping to have multiple elements, the ForeignKey goes in the element, not
> the grouping.
>
> --
> -- Christophe Pettus
>   x...@thebuild.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to