Re: Django database referential problem

2007-04-25 Thread Drasty

Depending on how you want to limit versions in your projects, you
could do something with the "limit_choices_to" argument in your
ForeignKey.


--~--~-~--~~~---~--~~
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: Django database referential problem

2007-04-25 Thread Gerry Steele

Thanks for the reply Yaron. I think I was basically over thinking the 
whole thing.

The ManyToMany was a mistake, you were right,  as there is another class 
that should need manytomany. (each Issue will potentially relate to more 
than one ProjectVersion).

The admin still displays all versions, however this shouldn't be a 
problem in my application itself as i can use the version_set

Thanks
Gerry

Yaron Buskilla wrote:
> Hi Gerry.
>
> Why do you use the many to many field for version in the project model ?
> I think all you have to do is define the ForiegnKey as you did in the 
> ProjectVersion model and it is enough .
> Because every project has many versions. Then you can get the versions 
> of a projetc by writing :
>
> p = Project()
> versions = p.version_set()
>
> and there you have versions as a list of all p's versions.
>
> Yaron
>
>
> Gerry Steele wrote:
>
>> I'm having a problem designing my data model. I'm sure there must be 
>> an  elementary solution but I can't find it.
>>
>> Below i have two models. ProjectVersion and Project. It all kind of 
>> works,  however the admin "add" section for Project displays all rows 
>> for  ProjectVersion in that field, instead of all the versions for 
>> just that  Project. Is there a constraint or something i'm missing?
>>
>> Many Thanks
>> Gerry
>>
>>
>> class ProjectVersion(models.Model):
>> name = models.CharField(maxlength=30)
>> released = models.NullBooleanField()
>> release_date = models.DateField(blank = True, null=True)
>> unnasigned = models.BooleanField()
>> project_for_version = models.ForeignKey("Project")
>> 
>> def __str__(self):
>> return self.name
>>
>> class Admin:
>> pass   
>> 
>> class Project(models.Model):
>> name = models.CharField(maxlength=30)
>> tag = models.CharField(maxlength=5)
>> project_lead = models.ForeignKey(UserProfile)
>> component = models.ForeignKey(ProjectComponent, blank=True, 
>> null=True)
>> version = models.ManyToManyField(ProjectVersion, blank=True, 
>> null=True)
>> 
>> def __str__(self):
>> return self.name
>> 
>> class Admin:
>> pass
>>
>>
>>  
>>
>


--~--~-~--~~~---~--~~
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: Django database referential problem

2007-04-25 Thread Yaron Buskilla

Hi Gerry.

Why do you use the many to many field for version in the project model ?
I think all you have to do is define the ForiegnKey as you did in the 
ProjectVersion model and it is enough .
Because every project has many versions. Then you can get the versions 
of a projetc by writing :


p = Project()
versions = p.version_set()

and there you have versions as a list of all p's versions.

Yaron


Gerry Steele wrote:

I'm having a problem designing my data model. I'm sure there must be an  
elementary solution but I can't find it.


Below i have two models. ProjectVersion and Project. It all kind of works,  
however the admin "add" section for Project displays all rows for  
ProjectVersion in that field, instead of all the versions for just that  
Project. Is there a constraint or something i'm missing?


Many Thanks
Gerry


class ProjectVersion(models.Model):
name = models.CharField(maxlength=30)
released = models.NullBooleanField()
release_date = models.DateField(blank = True, null=True)
unnasigned = models.BooleanField()
project_for_version = models.ForeignKey("Project")

def __str__(self):
return self.name

class Admin:
pass

class Project(models.Model):
name = models.CharField(maxlength=30)
tag = models.CharField(maxlength=5)
project_lead = models.ForeignKey(UserProfile)
component = models.ForeignKey(ProjectComponent, blank=True, null=True)
version = models.ManyToManyField(ProjectVersion, blank=True, null=True)

def __str__(self):
return self.name

class Admin:
pass


 





smime.p7s
Description: S/MIME Cryptographic Signature


Django database referential problem

2007-04-25 Thread Gerry Steele

I'm having a problem designing my data model. I'm sure there must be an  
elementary solution but I can't find it.

Below i have two models. ProjectVersion and Project. It all kind of works,  
however the admin "add" section for Project displays all rows for  
ProjectVersion in that field, instead of all the versions for just that  
Project. Is there a constraint or something i'm missing?

Many Thanks
Gerry


class ProjectVersion(models.Model):
name = models.CharField(maxlength=30)
released = models.NullBooleanField()
release_date = models.DateField(blank = True, null=True)
unnasigned = models.BooleanField()
project_for_version = models.ForeignKey("Project")

def __str__(self):
return self.name

class Admin:
pass

class Project(models.Model):
name = models.CharField(maxlength=30)
tag = models.CharField(maxlength=5)
project_lead = models.ForeignKey(UserProfile)
component = models.ForeignKey(ProjectComponent, blank=True, null=True)
version = models.ManyToManyField(ProjectVersion, blank=True, null=True)

def __str__(self):
return self.name

class Admin:
pass


-- 
http://belfast.no-ip.info/
Get http://www.ubuntu.com/

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