我已经在个人资料模型中使用一对一关系扩展了用户模型,一旦用户注册并登录,他就可以填写个人资料详细信息
def profile(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True,)
date_of_birth=models.DateField()
permanent_address=models.TextField()
present_address = models.TextField()
pan_no=models.CharField(max_length=10)
phone_no=models.DecimalField(max_digits=10,decimal_places blood_group=models.CharField(max_length=50,default=None,choices=BLOOD_GROUP_CHOICES)
emergency_contact=models.DecimalField(max_digits=10,decimal_places=0)
photo=models.ImageField(upload_to='profile_photo',blank=True)
id_proof=models.CharField(max_length=50,default=None,choices=ID_CHOICES)
id_number=models.CharField(max_length=50)
views.py
@login_required(login_url='login')
def create_project(request):
form=projectform(request.POST or None)
if form.is_valid():
form.save()
return redirect('projects_panel')
context={
'form': form
}
return render(request, 'bootstrap_template/project/create_project.html', context)