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 fo

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

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 comma

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 ca

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

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

Re: database relationships

2008-08-27 Thread nek4life
> 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

Re: database relationships

2008-08-27 Thread lingrlongr
2: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 > > > > >

Re: database relationships

2008-08-27 Thread nek4life
e 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
ich 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 > > &g

Re: database relationships

2008-08-22 Thread lingrlongr
ack > > > > > 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 trac

Re: database relationships

2008-08-22 Thread lingrlongr
quest, 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, slu

Re: database relationships

2008-08-22 Thread nek4life
rtist > >   ..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

Re: database relationships

2008-08-21 Thread lingrlongr
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: > > >

Re: database relationships

2008-08-21 Thread lingrlongr
ug) 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,

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 point