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

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 =

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

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

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

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