Why this is showing a warning as it default take the primary key from the User model so should I also declare the primary key the Registration or candidate model again. models.py
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Registration(models.Model):
fname = models.CharField(max_length=30)
lname = models.CharField(max_length=30)
# phone = models.BigIntegerField(max_length=10,primary_key=True)
dob=models.DateField()
user = models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True)
def __str__(self):
return self.fname
class candidate(models.Model):
full_name = models.CharField(max_length=30)
position = models.CharField(max_length=30)
total_vote = models.IntegerField(default=0)
def __str__(self):
return "{} -- {}".format(self.full_name,self.position)
problem occured
WARNINGS:
poll.candidate: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the PollConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.