Hello Django Users,
I just started working with django again but i'm running into some
troubles adding values into my database.
just for an example i made the following three tables
class Method(models.Model):
method_id = models.AutoField(primary_key=True)
methodName = models.CharField(max_length=20)
class Sponsor(models.Model):
sponsor_id = models.AutoField(primary_key=True)
sponsorName = models.CharField(max_length=50)
class Clients(models.Model):
labcode = models.AutoField(primary_key = True)
invoiceNr = models.IntegerField()
sponsor_id = models.ForeignKey(Sponsor)
method_id = models.ForeignKey(SubmitMethod)
I added some values into the tables method and sponsor and now i want
to add the values into the table clients. The problem is that it has
multiple foreignkeys and the method from the tutorial doesn't work in
this case
sponsor = Sponsor.objects.get(sponsor_id=1)
method = Method.objects.get(method_id=1)
sponsor.method.clients_set.create(labcode=101,invoiceNr='None')
the error it states is the following
AttributeError: 'Sponsor' object has no attribute 'method'
offcourse that is correct because only clients is a attribute from
sponsor.
Can someone help me out, how can i add values to this table using the
django method ? ( offcourse i can fall back to sql querying but i like
to know the django way )
any help would be greatly appreciated,
Regards,
Richard M
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---