Hi all, I'm new to django and python and i'm working on a project that works with a legacy database. I've a particular problem with a "composite key" and "get" or "get_object_or_404".
i generated the below model form the legacy database using inspectdb model: ------------------ class Member: member_id = field.CharField(max_length=20) organization_id = field.Foreignkey(Organization) member_type = field.CharField(max_length=10) class Meta: db_table = u'member' unique_together = (('member_id','organization_id'),) # unique_together is a constraint i added in order to form the composite primary key class Organization: organization_id = field.CharField(max_length=2) organization_name = field.CharField(max_length=20) class Meta: db_table = u'organization' I have a function in my view which receives a "MemOrgId" which is nothing but the composite key of both member_id and organization_id. for example the value i get is MemOrgId='AA1001', now the problem is when i try to use get or a get_object_or_404 i get a Value Error:Invalid Literal for int with base 10. obj = get_object_or_404(Member,pk = MemOrgId) i assign the object instance to my form and save the form if the form is valid. The Trace Back starts with my view and ends at "fields.__init__." which retuns int(value). According to my understanding of the trace back its not able to convert the key "CP1001" to int coz it contains char data along with int. I cannot modify the database and i cannot change the way MemOrgId comes to the view function. Is there a way around this problem???? Thanks for your help. Regards, Pranav Hegde. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.