Re: new at this -- need some guidance
The problem is very clear. Add a related_name argument to those fields
in your model. If you are not sure how to do this, search the
documentation for "related_name"
On 9/10/11, Danny Gale <danny.m.gale@gmail.com> wrote:
> Hi, I'm learning Django (albeit slowly) and I'm trying to set up a really
> simple database. I want to have Artists, Albums, and Tracks. I want to be
> able to navigate both ways in the db. So you should be able to go from
> artist -> album or from album -> artist. Same thing with album and track. I
> really can't figure it out. Here's the simplest test case I can come up
> with:
>
> class Song(models.Model):
> album = models.ForeignKey('Album')
>
> class Album(models.Model):
> tracks = models.ManyToManyField(Song)
>
> when i run syncdb, it comes up with the following error:
> music.album: Reverse query name for m2m field 'tracks' clashes with field
> 'Song.album'. Add a related_name argument to the definition for 'tracks'.
>
> So I go back and add the related_name argument:
> class Song(models.Model):
> album = models.ForeignKey('Album')
>
> class Album(models.Model):
> tracks = models.ManyToManyField(Song, related_name='album')
>
> and run syncdb again:
> music.album: Accessor for m2m field 'tracks' clashes with field
> 'Song.album'. Add a related_name argument to the definition for 'tracks'.
> music.album: Reverse query name for m2m field 'tracks' clashes with field
> 'Song.album'. Add a related_name argument to the definition for 'tracks'.
>
> uh oh. Now there's *TWO* errors!!! What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/1i5-cwJxoqAJ.
> 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.
>
>
--
Sent from my mobile device
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home