Re: database relationships, many to one

2010-11-21 Thread Bruno Amaral
It Worked :)

Thank you both for the guidance.

Here's the final result in case it will help anyone else 
http://dpaste.com/278230/

On Nov 21, 5:09 pm, Carlos Daniel Ruvalcaba Valenzuela
 wrote:
> The first error is simple, university models is defined after your
> department model, thus is not found, you can define the foreign key as
> a string in the form of "appname.ModelName", so you will define it
> like this:
>
> class departments(models.Model):
>     university = models.ForeignKey("appname.university",
> related_name="departments")
>
> Where appname is the name of the application where the models are
> being defined (the folder where models.py is stored).
>
> About the other problem, it would be good to have a little more
> context on what is socialmediacourses and where is throwing you the
> error, but with the above change should do the trick, just don't
> forget to remove your ManyToMany departments definition on University
> model, that would make the name university.department clash.
>
> Regards,
> Carlos Ruvalcaba
>
>
>
> On Sun, Nov 21, 2010 at 7:10 AM, Bruno Amaral  wrote:
> > Carlos, Thank you for this!
>
> > Your solution is what I am looking for,but for some reason I get an
> > error message:
> > "NameError: name 'university' is not defined"  > 278024/>
>
> > Figuring this could an issue with Python and not Django, i added
> > university ='' to the top.
>
> > The validate command returned the message:
> > Error: One or more models did not validate:
> > socialmediacourses.departments: 'university' has a relation with
> > model , which has either not been installed or is abstract.
> > socialmediacourses.university: Reverse query name for m2m field
> > 'departments' clashes with field 'departments.university'. Add a
> > related_name argument to the definition for 'departments'.
>
> > what am I doing wrong?
>
> > On Nov 21, 4:23 am, Carlos Daniel Ruvalcaba Valenzuela
> >  wrote:
> >> Depends on you requirements, you could have used a Foreign Key to the
> >> University on the Department model and marking it as required, thus
> >> there cannot be a Department without university and set the
> >> related_name property on the ForeignKey to the "departments" so you
> >> can access University.departments property for the list of
> >> departments.
>
> >> You may not want this if you only want to have 1 kind of department
> >> which will be linked to many universities, but I see this may not be
> >> the case, thus your models may end like this:
>
> >> class departments(models.Model):
>
> >>         GENDER = ((u'M', u'Male'),(u'F', u'Female'),)
>
> >>         university = models.ForeignKey(university, 
> >> related_name="departments")
> >>         name = models.CharField(max_length=60)
> >>         head_name = models.CharField(max_length=60)
> >>         head_email = models.EmailField(max_length=60)
> >>         head_gender = models.CharField(max_length=2, choices=GENDER)
>
> >> Regards,
> >> Carlos Ruvalcaba
>
> >> On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
> >> > I have been trying to create a database for Universities, Departments
> >> > and Courses.
>
> >> > The idea is that a University has many departments, which in turn have
> >> > one or more courses.
>
> >> > So far, this model works:http://dpaste.com/277850/
>
> >> > With one caveat, it allows a department to exist without a University
> >> > linked to it.
>
> >> > I am at a loss here, even after reading over all the documentation I
> >> > could find on the website, does anyone have an idea on what I am doing
> >> > wrong, or where I should look for a solution?
>
> >> > --
> >> > 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 
> >> > athttp://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 
> > athttp://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.



Re: database relationships, many to one

2010-11-21 Thread Carlos Daniel Ruvalcaba Valenzuela
The first error is simple, university models is defined after your
department model, thus is not found, you can define the foreign key as
a string in the form of "appname.ModelName", so you will define it
like this:

class departments(models.Model):
university = models.ForeignKey("appname.university",
related_name="departments")

Where appname is the name of the application where the models are
being defined (the folder where models.py is stored).

About the other problem, it would be good to have a little more
context on what is socialmediacourses and where is throwing you the
error, but with the above change should do the trick, just don't
forget to remove your ManyToMany departments definition on University
model, that would make the name university.department clash.

Regards,
Carlos Ruvalcaba

On Sun, Nov 21, 2010 at 7:10 AM, Bruno Amaral  wrote:
> Carlos, Thank you for this!
>
> Your solution is what I am looking for,but for some reason I get an
> error message:
> "NameError: name 'university' is not defined"  278024/>
>
> Figuring this could an issue with Python and not Django, i added
> university ='' to the top.
>
> The validate command returned the message:
> Error: One or more models did not validate:
> socialmediacourses.departments: 'university' has a relation with
> model , which has either not been installed or is abstract.
> socialmediacourses.university: Reverse query name for m2m field
> 'departments' clashes with field 'departments.university'. Add a
> related_name argument to the definition for 'departments'.
>
> what am I doing wrong?
>
> On Nov 21, 4:23 am, Carlos Daniel Ruvalcaba Valenzuela
>  wrote:
>> Depends on you requirements, you could have used a Foreign Key to the
>> University on the Department model and marking it as required, thus
>> there cannot be a Department without university and set the
>> related_name property on the ForeignKey to the "departments" so you
>> can access University.departments property for the list of
>> departments.
>>
>> You may not want this if you only want to have 1 kind of department
>> which will be linked to many universities, but I see this may not be
>> the case, thus your models may end like this:
>>
>> class departments(models.Model):
>>
>>         GENDER = ((u'M', u'Male'),(u'F', u'Female'),)
>>
>>         university = models.ForeignKey(university, 
>> related_name="departments")
>>         name = models.CharField(max_length=60)
>>         head_name = models.CharField(max_length=60)
>>         head_email = models.EmailField(max_length=60)
>>         head_gender = models.CharField(max_length=2, choices=GENDER)
>>
>> Regards,
>> Carlos Ruvalcaba
>>
>>
>>
>> On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
>> > I have been trying to create a database for Universities, Departments
>> > and Courses.
>>
>> > The idea is that a University has many departments, which in turn have
>> > one or more courses.
>>
>> > So far, this model works:http://dpaste.com/277850/
>>
>> > With one caveat, it allows a department to exist without a University
>> > linked to it.
>>
>> > I am at a loss here, even after reading over all the documentation I
>> > could find on the website, does anyone have an idea on what I am doing
>> > wrong, or where I should look for a solution?
>>
>> > --
>> > 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 
>> > athttp://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.
>
>

-- 
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.



Re: database relationships, many to one

2010-11-21 Thread Bruno Amaral
Carlos, Thank you for this!

Your solution is what I am looking for,but for some reason I get an
error message:
"NameError: name 'university' is not defined" 

Figuring this could an issue with Python and not Django, i added
university ='' to the top.

The validate command returned the message:
Error: One or more models did not validate:
socialmediacourses.departments: 'university' has a relation with
model , which has either not been installed or is abstract.
socialmediacourses.university: Reverse query name for m2m field
'departments' clashes with field 'departments.university'. Add a
related_name argument to the definition for 'departments'.

what am I doing wrong?

On Nov 21, 4:23 am, Carlos Daniel Ruvalcaba Valenzuela
 wrote:
> Depends on you requirements, you could have used a Foreign Key to the
> University on the Department model and marking it as required, thus
> there cannot be a Department without university and set the
> related_name property on the ForeignKey to the "departments" so you
> can access University.departments property for the list of
> departments.
>
> You may not want this if you only want to have 1 kind of department
> which will be linked to many universities, but I see this may not be
> the case, thus your models may end like this:
>
> class departments(models.Model):
>
>         GENDER = ((u'M', u'Male'),(u'F', u'Female'),)
>
>         university = models.ForeignKey(university, related_name="departments")
>         name = models.CharField(max_length=60)
>         head_name = models.CharField(max_length=60)
>         head_email = models.EmailField(max_length=60)
>         head_gender = models.CharField(max_length=2, choices=GENDER)
>
> Regards,
> Carlos Ruvalcaba
>
>
>
> On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
> > I have been trying to create a database for Universities, Departments
> > and Courses.
>
> > The idea is that a University has many departments, which in turn have
> > one or more courses.
>
> > So far, this model works:http://dpaste.com/277850/
>
> > With one caveat, it allows a department to exist without a University
> > linked to it.
>
> > I am at a loss here, even after reading over all the documentation I
> > could find on the website, does anyone have an idea on what I am doing
> > wrong, or where I should look for a solution?
>
> > --
> > 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 
> > athttp://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.



Re: database relationships, many to one

2010-11-20 Thread Joseph (Driftwood Cove Designs)
unless a dept. can belong to several Universities (?), Carlos has the
right model.

On Nov 20, 8:23 pm, Carlos Daniel Ruvalcaba Valenzuela
 wrote:
> Depends on you requirements, you could have used a Foreign Key to the
> University on the Department model and marking it as required, thus
> there cannot be a Department without university and set the
> related_name property on the ForeignKey to the "departments" so you
> can access University.departments property for the list of
> departments.
>
> You may not want this if you only want to have 1 kind of department
> which will be linked to many universities, but I see this may not be
> the case, thus your models may end like this:
>
> class departments(models.Model):
>
>         GENDER = ((u'M', u'Male'),(u'F', u'Female'),)
>
>         university = models.ForeignKey(university, related_name="departments")
>         name = models.CharField(max_length=60)
>         head_name = models.CharField(max_length=60)
>         head_email = models.EmailField(max_length=60)
>         head_gender = models.CharField(max_length=2, choices=GENDER)
>
> Regards,
> Carlos Ruvalcaba
>
> On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
> > I have been trying to create a database for Universities, Departments
> > and Courses.
>
> > The idea is that a University has many departments, which in turn have
> > one or more courses.
>
> > So far, this model works:http://dpaste.com/277850/
>
> > With one caveat, it allows a department to exist without a University
> > linked to it.
>
> > I am at a loss here, even after reading over all the documentation I
> > could find on the website, does anyone have an idea on what I am doing
> > wrong, or where I should look for a solution?
>
> > --
> > 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 
> > athttp://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.



Re: database relationships, many to one

2010-11-20 Thread Carlos Daniel Ruvalcaba Valenzuela
Depends on you requirements, you could have used a Foreign Key to the
University on the Department model and marking it as required, thus
there cannot be a Department without university and set the
related_name property on the ForeignKey to the "departments" so you
can access University.departments property for the list of
departments.

You may not want this if you only want to have 1 kind of department
which will be linked to many universities, but I see this may not be
the case, thus your models may end like this:

class departments(models.Model):

GENDER = ((u'M', u'Male'),(u'F', u'Female'),)

university = models.ForeignKey(university, related_name="departments")
name = models.CharField(max_length=60)
head_name = models.CharField(max_length=60)
head_email = models.EmailField(max_length=60)
head_gender = models.CharField(max_length=2, choices=GENDER)

Regards,
Carlos Ruvalcaba

On Sat, Nov 20, 2010 at 6:19 PM, Bruno Amaral  wrote:
> I have been trying to create a database for Universities, Departments
> and Courses.
>
> The idea is that a University has many departments, which in turn have
> one or more courses.
>
> So far, this model works: http://dpaste.com/277850/
>
> With one caveat, it allows a department to exist without a University
> linked to it.
>
> I am at a loss here, even after reading over all the documentation I
> could find on the website, does anyone have an idea on what I am doing
> wrong, or where I should look for a solution?
>
> --
> 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.
>
>

-- 
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.



database relationships, many to one

2010-11-20 Thread Bruno Amaral
I have been trying to create a database for Universities, Departments
and Courses.

The idea is that a University has many departments, which in turn have
one or more courses.

So far, this model works: http://dpaste.com/277850/

With one caveat, it allows a department to exist without a University
linked to it.

I am at a loss here, even after reading over all the documentation I
could find on the website, does anyone have an idea on what I am doing
wrong, or where I should look for a solution?

-- 
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.



Re: database relationships

2008-08-27 Thread nek4life
t; > > > > artist,
> > > > > > how could I reverse the process so I can get all the artist vars 
> > > > > > plus
> > > > > > the data I need from the track and album tables?  Thanks a bunch,
> > > > > > you've been very helpful already.
>
> > > > > > Charlie
>
> > > > > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > > > One more note.  You wouldn't NEED to explicitly grab all those 
> > > > > > > vars,
> > > > > > > as you can get them in a template too.  I just wanted to show you 
> > > > > > > the
> > > > > > > relation.
> > > > > > > If you sent the track to the template, you can get the artist by
> > > > > > > using:
>
> > > > > > > {{ track.album.artist }}
>
> > > > > > > Keith
>
> > > > > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > The only part you have that is redundant is the "artist" in your
> > > > > > > > "Track" class.  You can find out the artist because a track is 
> > > > > > > > related
> > > > > > > > to an album, which in turn, is related to an artist.
>
> > > > > > > > Some of the code you'd maybe see in a view would be:
>
> > > > > > > > # views.py
> > > > > > > > from django.shortcuts import get_object_or_404
> > > > > > > > from models import Album, Track
>
> > > > > > > > def album(request, slug):
> > > > > > > >   album = get_object_or_404(Album, slug=slug)
> > > > > > > >   artist = album.artist
> > > > > > > >   tracks = album.track_set.all()
> > > > > > > >   ...etc... return a response...
>
> > > > > > > > def track(request, slug):
> > > > > > > >   track = get_object_or_404(Track, slug=slug)
> > > > > > > >   album = track.album
> > > > > > > >   artist = album.artist
> > > > > > > >   ..etc..
>
> > > > > > > > HTH
>
> > > > > > > > Keith
>
> > > > > > > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > I'm trying to set up my first Django application and I'm 
> > > > > > > > > trying to
> > > > > > > > > figure out the database relationships.  I want to be able to 
> > > > > > > > > list
> > > > > > > > > albums, with their corresponding tracks and album artwork.  
> > > > > > > > > Right now
> > > > > > > > > I only have foreign keys defined in the Track class and on the
> > > > > > > > > AlbumArt class pointing to the Album class.  I'm doing this 
> > > > > > > > > so I can
> > > > > > > > > keep a record of which track or which album art goes to which 
> > > > > > > > > album.
> > > > > > > > > However I also would like to add a ManyToManyField on my 
> > > > > > > > > Album class
> > > > > > > > > so I can pull the album data in my view.  Defining this is 
> > > > > > > > > both places
> > > > > > > > > seems redundant to me, but I'm not sure how else I can 
> > > > > > > > > accomplish
> > > > > > > > > this.  What would be best practice in this situation and how 
> > > > > > > > > should I
> > > > > > > > > proceed?
>
> > > > > > > > > class Album(models.Model):
> > > > > > > > >     title          = models.CharField(max_length=255)
> > > > > > > > >     prefix         = models.CharField(max_length=20, 
> > > > > > > > > blank=True)
> > > > > > > > >     subtitle       = models.CharField(blank=True, 
> > > > > > > > > max_length=255)
> > > > > > > > >     slug           = models.SlugField(unique=True)
> > > > > > > > >     artist         = models.ForeignKey('Artist')
>
> > > > > > > > > class AlbumArt(models.Model):
> > > > > > > > >     title          = models.CharField(max_length=200)
> > > > > > > > >     slug           = models.SlugField()
> > > > > > > > >     album          = models.ForeignKey('Album')
>
> > > > > > > > > class Track(models.Model):
> > > > > > > > >     title         = models.CharField(max_length=200)
> > > > > > > > >     slug          = models.SlugField(unique=True)
> > > > > > > > >     album         = models.ForeignKey('Album')
> > > > > > > > >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database relationships

2008-08-27 Thread lingrlongr
> > relation.
> > > > > > If you sent the track to the template, you can get the artist by
> > > > > > using:
>
> > > > > > {{ track.album.artist }}
>
> > > > > > Keith
>
> > > > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > > > The only part you have that is redundant is the "artist" in your
> > > > > > > "Track" class.  You can find out the artist because a track is 
> > > > > > > related
> > > > > > > to an album, which in turn, is related to an artist.
>
> > > > > > > Some of the code you'd maybe see in a view would be:
>
> > > > > > > # views.py
> > > > > > > from django.shortcuts import get_object_or_404
> > > > > > > from models import Album, Track
>
> > > > > > > def album(request, slug):
> > > > > > >   album = get_object_or_404(Album, slug=slug)
> > > > > > >   artist = album.artist
> > > > > > >   tracks = album.track_set.all()
> > > > > > >   ...etc... return a response...
>
> > > > > > > def track(request, slug):
> > > > > > >   track = get_object_or_404(Track, slug=slug)
> > > > > > >   album = track.album
> > > > > > >   artist = album.artist
> > > > > > >   ..etc..
>
> > > > > > > HTH
>
> > > > > > > Keith
>
> > > > > > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > I'm trying to set up my first Django application and I'm trying 
> > > > > > > > to
> > > > > > > > figure out the database relationships.  I want to be able to 
> > > > > > > > list
> > > > > > > > albums, with their corresponding tracks and album artwork.  
> > > > > > > > Right now
> > > > > > > > I only have foreign keys defined in the Track class and on the
> > > > > > > > AlbumArt class pointing to the Album class.  I'm doing this so 
> > > > > > > > I can
> > > > > > > > keep a record of which track or which album art goes to which 
> > > > > > > > album.
> > > > > > > > However I also would like to add a ManyToManyField on my Album 
> > > > > > > > class
> > > > > > > > so I can pull the album data in my view.  Defining this is both 
> > > > > > > > places
> > > > > > > > seems redundant to me, but I'm not sure how else I can 
> > > > > > > > accomplish
> > > > > > > > this.  What would be best practice in this situation and how 
> > > > > > > > should I
> > > > > > > > proceed?
>
> > > > > > > > class Album(models.Model):
> > > > > > > >     title          = models.CharField(max_length=255)
> > > > > > > >     prefix         = models.CharField(max_length=20, blank=True)
> > > > > > > >     subtitle       = models.CharField(blank=True, 
> > > > > > > > max_length=255)
> > > > > > > >     slug           = models.SlugField(unique=True)
> > > > > > > >     artist         = models.ForeignKey('Artist')
>
> > > > > > > > class AlbumArt(models.Model):
> > > > > > > >     title          = models.CharField(max_length=200)
> > > > > > > >     slug           = models.SlugField()
> > > > > > > >     album          = models.ForeignKey('Album')
>
> > > > > > > > class Track(models.Model):
> > > > > > > >     title         = models.CharField(max_length=200)
> > > > > > > >     slug          = models.SlugField(unique=True)
> > > > > > > >     album         = models.ForeignKey('Album')
> > > > > > > >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database relationships

2008-08-27 Thread nek4life

Well this works great while using the generic detail view, but when I
return a list view the relationships won't work.


in my view

def album_list(request, page=0):
return list_detail.object_list(
   request,
   queryset = Album.objects.select_related().all(),
   paginate_by = 20,
   page = page,
   template_object_name = 'album',
)

in my template

{% for albumart in album.albumart_set.all %}
{{ album.albumart.image }}
{% endfor %}

Is this not supported in list_detail.object_list?  I can't find
information on this anywhere, may have to change my database around.


On Aug 22, 11:44 am, nek4life <[EMAIL PROTECTED]> wrote:
> Awesome.  I got it to work using this code in my view.
>
> def artist_detail(request, slug):
>     album_list = Album.objects.all()
>     return list_detail.object_detail(
>         request,
>         queryset = Artist.objects.all(),
>         slug = slug,
>         template_object_name = 'artist',
>         extra_context={'album_list': album_list}
>     )
>
> But the way you're doing it only calls the database once instead of
> twice.  Beautiful!  Thank you.  I'm going to try the query you
> suggested.
>
> queryset=Artist.objects.select_related().all()
>
> I'd like to just pull in the albums, artwork, and tracks related to
> the particular artist in the url slug, for 
> instancehttp://www.example.com/artists/artist-name
>
> You've been a huge help.  Thanks a ton!
>
> Charlie
>
> On Aug 22, 11:20 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > Also note, if your intentions were to grab all that information and
> > just send the artist to the template, I think you'd get better
> > performance if your queryset in the view looked like this:
>
> > queryset=Artist.objects.select_related().all()
>
> > Keith
>
> > On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > Super easy :)  Just to show you another way to implement generic
> > > views, I used custom view that returns a generic view.
>
> > > # urls.py
> > > from myapp.views import artist
> > > ...
> > > (r'^artist/(?P\w+)/$', artist),
> > > ...
>
> > > #views.py
> > > from django.views.generic.list_detail import object_detail
> > > def artist(request, slug):
> > >     return object_detail(
> > >         request,
> > >         queryset=Artist.objects.all(),
> > >         slug = slug,
> > >         template_object_name = 'artist'
> > >     )
>
> > > # //artist_list.html
> > > {{ artist }}
> > > Albums
> > > 
> > > {% for album in artist.album_set.all %}
> > >    {{ album.name }}
> > >    
> > >    {% for track in album.track_set.all %}
> > >      {{ track.name }}
> > >    {% endfor %}
> > >    
> > > {% endfor %}
> > > 
>
> > > Django makes traversing relationships easy...
>
> > > HTH
>
> > > Keith
>
> > > On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > So if I sent the artist to the template and wanted to grab the list of
> > > > albums with all the album tracks how would I go about that.  Would I
> > > > have to pull in all the data with a custom view?  So far I've only
> > > > been using generic views.  It definitely makes sense pulling in the
> > > > information through the track back up through the album to the artist,
> > > > how could I reverse the process so I can get all the artist vars plus
> > > > the data I need from the track and album tables?  Thanks a bunch,
> > > > you've been very helpful already.
>
> > > > Charlie
>
> > > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > > > > as you can get them in a template too.  I just wanted to show you the
> > > > > relation.
> > > > > If you sent the track to the template, you can get the artist by
> > > > > using:
>
> > > > > {{ track.album.artist }}
>
> > > > > Keith
>
> > > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > > The only part you have that is redundant is the "artist" in your
> > > > > > "Track" class.  You can find out the artist because a track is 
> > > > > > related
> > > > > > to an album, which in turn, is related to an artist.
>
> > >

Re: database relationships

2008-08-22 Thread nek4life

Awesome.  I got it to work using this code in my view.

def artist_detail(request, slug):
album_list = Album.objects.all()
return list_detail.object_detail(
request,
queryset = Artist.objects.all(),
slug = slug,
template_object_name = 'artist',
extra_context={'album_list': album_list}
)

But the way you're doing it only calls the database once instead of
twice.  Beautiful!  Thank you.  I'm going to try the query you
suggested.

queryset=Artist.objects.select_related().all()

I'd like to just pull in the albums, artwork, and tracks related to
the particular artist in the url slug, for instance
http://www.example.com/artists/artist-name

You've been a huge help.  Thanks a ton!

Charlie

On Aug 22, 11:20 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Also note, if your intentions were to grab all that information and
> just send the artist to the template, I think you'd get better
> performance if your queryset in the view looked like this:
>
> queryset=Artist.objects.select_related().all()
>
> Keith
>
> On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > Super easy :)  Just to show you another way to implement generic
> > views, I used custom view that returns a generic view.
>
> > # urls.py
> > from myapp.views import artist
> > ...
> > (r'^artist/(?P\w+)/$', artist),
> > ...
>
> > #views.py
> > from django.views.generic.list_detail import object_detail
> > def artist(request, slug):
> >     return object_detail(
> >         request,
> >         queryset=Artist.objects.all(),
> >         slug = slug,
> >         template_object_name = 'artist'
> >     )
>
> > # //artist_list.html
> > {{ artist }}
> > Albums
> > 
> > {% for album in artist.album_set.all %}
> >    {{ album.name }}
> >    
> >    {% for track in album.track_set.all %}
> >      {{ track.name }}
> >    {% endfor %}
> >    
> > {% endfor %}
> > 
>
> > Django makes traversing relationships easy...
>
> > HTH
>
> > Keith
>
> > On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > So if I sent the artist to the template and wanted to grab the list of
> > > albums with all the album tracks how would I go about that.  Would I
> > > have to pull in all the data with a custom view?  So far I've only
> > > been using generic views.  It definitely makes sense pulling in the
> > > information through the track back up through the album to the artist,
> > > how could I reverse the process so I can get all the artist vars plus
> > > the data I need from the track and album tables?  Thanks a bunch,
> > > you've been very helpful already.
>
> > > Charlie
>
> > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > > > as you can get them in a template too.  I just wanted to show you the
> > > > relation.
> > > > If you sent the track to the template, you can get the artist by
> > > > using:
>
> > > > {{ track.album.artist }}
>
> > > > Keith
>
> > > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > The only part you have that is redundant is the "artist" in your
> > > > > "Track" class.  You can find out the artist because a track is related
> > > > > to an album, which in turn, is related to an artist.
>
> > > > > Some of the code you'd maybe see in a view would be:
>
> > > > > # views.py
> > > > > from django.shortcuts import get_object_or_404
> > > > > from models import Album, Track
>
> > > > > def album(request, slug):
> > > > >   album = get_object_or_404(Album, slug=slug)
> > > > >   artist = album.artist
> > > > >   tracks = album.track_set.all()
> > > > >   ...etc... return a response...
>
> > > > > def track(request, slug):
> > > > >   track = get_object_or_404(Track, slug=slug)
> > > > >   album = track.album
> > > > >   artist = album.artist
> > > > >   ..etc..
>
> > > > > HTH
>
> > > > > Keith
>
> > > > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > > > I'm trying to set up my first Django application and I'm trying to
> > > > > > figure out the database relationships.  I want to 

Re: database relationships

2008-08-22 Thread lingrlongr

Also note, if your intentions were to grab all that information and
just send the artist to the template, I think you'd get better
performance if your queryset in the view looked like this:

queryset=Artist.objects.select_related().all()

Keith

On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Super easy :)  Just to show you another way to implement generic
> views, I used custom view that returns a generic view.
>
> # urls.py
> from myapp.views import artist
> ...
> (r'^artist/(?P\w+)/$', artist),
> ...
>
> #views.py
> from django.views.generic.list_detail import object_detail
> def artist(request, slug):
>     return object_detail(
>         request,
>         queryset=Artist.objects.all(),
>         slug = slug,
>         template_object_name = 'artist'
>     )
>
> # //artist_list.html
> {{ artist }}
> Albums
> 
> {% for album in artist.album_set.all %}
>    {{ album.name }}
>    
>    {% for track in album.track_set.all %}
>      {{ track.name }}
>    {% endfor %}
>    
> {% endfor %}
> 
>
> Django makes traversing relationships easy...
>
> HTH
>
> Keith
>
> On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
>
> > So if I sent the artist to the template and wanted to grab the list of
> > albums with all the album tracks how would I go about that.  Would I
> > have to pull in all the data with a custom view?  So far I've only
> > been using generic views.  It definitely makes sense pulling in the
> > information through the track back up through the album to the artist,
> > how could I reverse the process so I can get all the artist vars plus
> > the data I need from the track and album tables?  Thanks a bunch,
> > you've been very helpful already.
>
> > Charlie
>
> > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > > as you can get them in a template too.  I just wanted to show you the
> > > relation.
> > > If you sent the track to the template, you can get the artist by
> > > using:
>
> > > {{ track.album.artist }}
>
> > > Keith
>
> > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > The only part you have that is redundant is the "artist" in your
> > > > "Track" class.  You can find out the artist because a track is related
> > > > to an album, which in turn, is related to an artist.
>
> > > > Some of the code you'd maybe see in a view would be:
>
> > > > # views.py
> > > > from django.shortcuts import get_object_or_404
> > > > from models import Album, Track
>
> > > > def album(request, slug):
> > > >   album = get_object_or_404(Album, slug=slug)
> > > >   artist = album.artist
> > > >   tracks = album.track_set.all()
> > > >   ...etc... return a response...
>
> > > > def track(request, slug):
> > > >   track = get_object_or_404(Track, slug=slug)
> > > >   album = track.album
> > > >   artist = album.artist
> > > >   ..etc..
>
> > > > HTH
>
> > > > Keith
>
> > > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > > I'm trying to set up my first Django application and I'm trying to
> > > > > figure out the database relationships.  I want to be able to list
> > > > > albums, with their corresponding tracks and album artwork.  Right now
> > > > > I only have foreign keys defined in the Track class and on the
> > > > > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > > > > keep a record of which track or which album art goes to which album.
> > > > > However I also would like to add a ManyToManyField on my Album class
> > > > > so I can pull the album data in my view.  Defining this is both places
> > > > > seems redundant to me, but I'm not sure how else I can accomplish
> > > > > this.  What would be best practice in this situation and how should I
> > > > > proceed?
>
> > > > > class Album(models.Model):
> > > > >     title          = models.CharField(max_length=255)
> > > > >     prefix         = models.CharField(max_length=20, blank=True)
> > > > >     subtitle       = models.CharField(blank=True, max_length=255)
> > > > >     slug           = models.SlugField(unique=True)
> > > > >     arti

Re: database relationships

2008-08-22 Thread lingrlongr

Super easy :)  Just to show you another way to implement generic
views, I used custom view that returns a generic view.

# urls.py
from myapp.views import artist
...
(r'^artist/(?P\w+)/$', artist),
...

#views.py
from django.views.generic.list_detail import object_detail
def artist(request, slug):
return object_detail(
request,
queryset=Artist.objects.all(),
slug = slug,
template_object_name = 'artist'
)

# //artist_list.html
{{ artist }}
Albums

{% for album in artist.album_set.all %}
   {{ album.name }}
   
   {% for track in album.track_set.all %}
 {{ track.name }}
   {% endfor %}
   
{% endfor %}


Django makes traversing relationships easy...

HTH

Keith


On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
> So if I sent the artist to the template and wanted to grab the list of
> albums with all the album tracks how would I go about that.  Would I
> have to pull in all the data with a custom view?  So far I've only
> been using generic views.  It definitely makes sense pulling in the
> information through the track back up through the album to the artist,
> how could I reverse the process so I can get all the artist vars plus
> the data I need from the track and album tables?  Thanks a bunch,
> you've been very helpful already.
>
> Charlie
>
> On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > as you can get them in a template too.  I just wanted to show you the
> > relation.
> > If you sent the track to the template, you can get the artist by
> > using:
>
> > {{ track.album.artist }}
>
> > Keith
>
> > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > The only part you have that is redundant is the "artist" in your
> > > "Track" class.  You can find out the artist because a track is related
> > > to an album, which in turn, is related to an artist.
>
> > > Some of the code you'd maybe see in a view would be:
>
> > > # views.py
> > > from django.shortcuts import get_object_or_404
> > > from models import Album, Track
>
> > > def album(request, slug):
> > >   album = get_object_or_404(Album, slug=slug)
> > >   artist = album.artist
> > >   tracks = album.track_set.all()
> > >   ...etc... return a response...
>
> > > def track(request, slug):
> > >   track = get_object_or_404(Track, slug=slug)
> > >   album = track.album
> > >   artist = album.artist
> > >   ..etc..
>
> > > HTH
>
> > > Keith
>
> > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > I'm trying to set up my first Django application and I'm trying to
> > > > figure out the database relationships.  I want to be able to list
> > > > albums, with their corresponding tracks and album artwork.  Right now
> > > > I only have foreign keys defined in the Track class and on the
> > > > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > > > keep a record of which track or which album art goes to which album.
> > > > However I also would like to add a ManyToManyField on my Album class
> > > > so I can pull the album data in my view.  Defining this is both places
> > > > seems redundant to me, but I'm not sure how else I can accomplish
> > > > this.  What would be best practice in this situation and how should I
> > > > proceed?
>
> > > > class Album(models.Model):
> > > >     title          = models.CharField(max_length=255)
> > > >     prefix         = models.CharField(max_length=20, blank=True)
> > > >     subtitle       = models.CharField(blank=True, max_length=255)
> > > >     slug           = models.SlugField(unique=True)
> > > >     artist         = models.ForeignKey('Artist')
>
> > > > class AlbumArt(models.Model):
> > > >     title          = models.CharField(max_length=200)
> > > >     slug           = models.SlugField()
> > > >     album          = models.ForeignKey('Album')
>
> > > > class Track(models.Model):
> > > >     title         = models.CharField(max_length=200)
> > > >     slug          = models.SlugField(unique=True)
> > > >     album         = models.ForeignKey('Album')
> > > >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database relationships

2008-08-22 Thread nek4life

So if I sent the artist to the template and wanted to grab the list of
albums with all the album tracks how would I go about that.  Would I
have to pull in all the data with a custom view?  So far I've only
been using generic views.  It definitely makes sense pulling in the
information through the track back up through the album to the artist,
how could I reverse the process so I can get all the artist vars plus
the data I need from the track and album tables?  Thanks a bunch,
you've been very helpful already.

Charlie

On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> One more note.  You wouldn't NEED to explicitly grab all those vars,
> as you can get them in a template too.  I just wanted to show you the
> relation.
> If you sent the track to the template, you can get the artist by
> using:
>
> {{ track.album.artist }}
>
> Keith
>
> On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > The only part you have that is redundant is the "artist" in your
> > "Track" class.  You can find out the artist because a track is related
> > to an album, which in turn, is related to an artist.
>
> > Some of the code you'd maybe see in a view would be:
>
> > # views.py
> > from django.shortcuts import get_object_or_404
> > from models import Album, Track
>
> > def album(request, slug):
> >   album = get_object_or_404(Album, slug=slug)
> >   artist = album.artist
> >   tracks = album.track_set.all()
> >   ...etc... return a response...
>
> > def track(request, slug):
> >   track = get_object_or_404(Track, slug=slug)
> >   album = track.album
> >   artist = album.artist
> >   ..etc..
>
> > HTH
>
> > Keith
>
> > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > I'm trying to set up my first Django application and I'm trying to
> > > figure out the database relationships.  I want to be able to list
> > > albums, with their corresponding tracks and album artwork.  Right now
> > > I only have foreign keys defined in the Track class and on the
> > > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > > keep a record of which track or which album art goes to which album.
> > > However I also would like to add a ManyToManyField on my Album class
> > > so I can pull the album data in my view.  Defining this is both places
> > > seems redundant to me, but I'm not sure how else I can accomplish
> > > this.  What would be best practice in this situation and how should I
> > > proceed?
>
> > > class Album(models.Model):
> > >     title          = models.CharField(max_length=255)
> > >     prefix         = models.CharField(max_length=20, blank=True)
> > >     subtitle       = models.CharField(blank=True, max_length=255)
> > >     slug           = models.SlugField(unique=True)
> > >     artist         = models.ForeignKey('Artist')
>
> > > class AlbumArt(models.Model):
> > >     title          = models.CharField(max_length=200)
> > >     slug           = models.SlugField()
> > >     album          = models.ForeignKey('Album')
>
> > > class Track(models.Model):
> > >     title         = models.CharField(max_length=200)
> > >     slug          = models.SlugField(unique=True)
> > >     album         = models.ForeignKey('Album')
> > >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database relationships

2008-08-21 Thread lingrlongr

One more note.  You wouldn't NEED to explicitly grab all those vars,
as you can get them in a template too.  I just wanted to show you the
relation.
If you sent the track to the template, you can get the artist by
using:

{{ track.album.artist }}

Keith

On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> The only part you have that is redundant is the "artist" in your
> "Track" class.  You can find out the artist because a track is related
> to an album, which in turn, is related to an artist.
>
> Some of the code you'd maybe see in a view would be:
>
> # views.py
> from django.shortcuts import get_object_or_404
> from models import Album, Track
>
> def album(request, slug):
>   album = get_object_or_404(Album, slug=slug)
>   artist = album.artist
>   tracks = album.track_set.all()
>   ...etc... return a response...
>
> def track(request, slug):
>   track = get_object_or_404(Track, slug=slug)
>   album = track.album
>   artist = album.artist
>   ..etc..
>
> HTH
>
> Keith
>
> On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to set up my first Django application and I'm trying to
> > figure out the database relationships.  I want to be able to list
> > albums, with their corresponding tracks and album artwork.  Right now
> > I only have foreign keys defined in the Track class and on the
> > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > keep a record of which track or which album art goes to which album.
> > However I also would like to add a ManyToManyField on my Album class
> > so I can pull the album data in my view.  Defining this is both places
> > seems redundant to me, but I'm not sure how else I can accomplish
> > this.  What would be best practice in this situation and how should I
> > proceed?
>
> > class Album(models.Model):
> >     title          = models.CharField(max_length=255)
> >     prefix         = models.CharField(max_length=20, blank=True)
> >     subtitle       = models.CharField(blank=True, max_length=255)
> >     slug           = models.SlugField(unique=True)
> >     artist         = models.ForeignKey('Artist')
>
> > class AlbumArt(models.Model):
> >     title          = models.CharField(max_length=200)
> >     slug           = models.SlugField()
> >     album          = models.ForeignKey('Album')
>
> > class Track(models.Model):
> >     title         = models.CharField(max_length=200)
> >     slug          = models.SlugField(unique=True)
> >     album         = models.ForeignKey('Album')
> >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database relationships

2008-08-21 Thread lingrlongr

The only part you have that is redundant is the "artist" in your
"Track" class.  You can find out the artist because a track is related
to an album, which in turn, is related to an artist.

Some of the code you'd maybe see in a view would be:

# views.py
from django.shortcuts import get_object_or_404
from models import Album, Track

def album(request, slug):
  album = get_object_or_404(Album, slug=slug)
  artist = album.artist
  tracks = album.track_set.all()
  ...etc... return a response...

def track(request, slug):
  track = get_object_or_404(Track, slug=slug)
  album = track.album
  artist = album.artist
  ..etc..

HTH

Keith

On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
> I'm trying to set up my first Django application and I'm trying to
> figure out the database relationships.  I want to be able to list
> albums, with their corresponding tracks and album artwork.  Right now
> I only have foreign keys defined in the Track class and on the
> AlbumArt class pointing to the Album class.  I'm doing this so I can
> keep a record of which track or which album art goes to which album.
> However I also would like to add a ManyToManyField on my Album class
> so I can pull the album data in my view.  Defining this is both places
> seems redundant to me, but I'm not sure how else I can accomplish
> this.  What would be best practice in this situation and how should I
> proceed?
>
> class Album(models.Model):
>     title          = models.CharField(max_length=255)
>     prefix         = models.CharField(max_length=20, blank=True)
>     subtitle       = models.CharField(blank=True, max_length=255)
>     slug           = models.SlugField(unique=True)
>     artist         = models.ForeignKey('Artist')
>
> class AlbumArt(models.Model):
>     title          = models.CharField(max_length=200)
>     slug           = models.SlugField()
>     album          = models.ForeignKey('Album')
>
> class Track(models.Model):
>     title         = models.CharField(max_length=200)
>     slug          = models.SlugField(unique=True)
>     album         = models.ForeignKey('Album')
>     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



database relationships

2008-08-21 Thread nek4life

I'm trying to set up my first Django application and I'm trying to
figure out the database relationships.  I want to be able to list
albums, with their corresponding tracks and album artwork.  Right now
I only have foreign keys defined in the Track class and on the
AlbumArt class pointing to the Album class.  I'm doing this so I can
keep a record of which track or which album art goes to which album.
However I also would like to add a ManyToManyField on my Album class
so I can pull the album data in my view.  Defining this is both places
seems redundant to me, but I'm not sure how else I can accomplish
this.  What would be best practice in this situation and how should I
proceed?

class Album(models.Model):
title  = models.CharField(max_length=255)
prefix = models.CharField(max_length=20, blank=True)
subtitle   = models.CharField(blank=True, max_length=255)
slug   = models.SlugField(unique=True)
artist = models.ForeignKey('Artist')


class AlbumArt(models.Model):
title  = models.CharField(max_length=200)
slug   = models.SlugField()
album  = models.ForeignKey('Album')


class Track(models.Model):
title = models.CharField(max_length=200)
slug  = models.SlugField(unique=True)
album = models.ForeignKey('Album')
artist= models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---