Saturday, October 20, 2018

Re: Using Primary key in two fields

Hi Rakhee,
Could you try following ? :

icatid = models.BigIntegerField(db_column='ICatID') makedate = models.DateTimeField(db_column='MakeDate') revdate = models.DateTimeField(db_column='RevDate', blank=True, null=True) makeid = models.BigAutoField(db_column='MakeId') class Meta: unique_together = (('icatid', 'makeid'),)


On Wednesday, 17 October 2018 11:25:48 UTC+5:30, Rakhee Menon wrote:
Hi Everyone,

I have a scenario where one field needs to be a primary key and another field needs to be an AutoField....and Autofield requires a condition primary_key = true

I get this error 
django_reports.MstCompositionFm.makeid: (fields.E100) AutoFields must set primary_key=True.
django_reports.MstSalarystructure: (models.E026) The model cannot have more than one field with 'primary_key=True'

This is my case:

icatid = models.BigIntegerField(db_column='ICatID', primary_key=True)
makedate = models.DateTimeField(db_column='MakeDate')
revdate = models.DateTimeField(db_column='RevDate', blank=True, null=True)
makeid = models.BigAutoField(db_column='MakeId', primary_key=False)

It would be of great help if anyone could figure out whats the solution

Thanks in Advance,
Rakhee

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a864b7d5-11e0-4964-b272-00a70e445e88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment