On Wed, 2009-03-04 at 10:43 -0800, arbi wrote: > Hello, > I am new to Django and programming... > I have a model similar to this one : > > class myModel : > attribute 1 = models.ForeignKey(myModel2, primary_key = True) > attribute 2 = models.ForeignKey(myModel3, primary_key = True) > > is it possible to have two primary keys?
No. One primary key per model. > In fact I want that the id of an instance of this class is the > concatenation of the (attribute 1 +attribute2). > How to do this? You might be able to do it with a custom field type and fair bit of code. However, this is definitely not the approach to take if you are just starting out. Instead, just let the primary key be the default one Django provides you with. You can have another property or method on the model that creates your combined value that you can use for other purposes. Trying to overly control the primary key almost always is not necessary. What is the problem you are really trying to solve here? Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---