Tuesday, January 25, 2011

Re: 'unique' field upon inserting



On Tue, Jan 25, 2011 at 10:28 AM, Jonas Geiregat <jonas@geiregat.org> wrote:
The id field (which is added by django by default has this) other then that the field doesn't have unique=True

I was also thinking of a better solution.

I have a Gig model which contains gigs with a ForeignKey to Artist.
I have a Artist model which contains artists.

One Gig can have multiple artists.

So instead of creating a field that is unique for each Gig (which might occur more then once since each gig might have more the  one artist) I was thinking of the following.

Create a model GigArtist (and leave the Artist Foreign key out of the Gig model).

This model contains two fields one who references to a specific gig and one that references to a (or more then one) specific artist.





Op 25-jan-2011, om 16:20 heeft Shawn Milochik het volgende geschreven:

> Do you have 'unique = True' in the field definition in the model?
>
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

Met vriendelijke groeten,

Jonas Geiregat
jonas@geiregat.org




--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Why can't you just use a ManyToManyField (http://docs.djangoproject.com/en/1.2/ref/models/fields/#manytomanyfield)?  Or am I not correctly understanding what you're trying to do?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment