Answer the question
In order to leave comments, you need to log in
Django.db.utils.IntegrityError. How to correctly specify the username in the model field argument? And how to fix the django.db.utils.IntegrityError error?
I'm trying to add a username to the name field of the Profile model.
models.py
from django import forms
from django.contrib.auth.models import User
class Profile(models.Model):
name = models.ForeignKey(User, on_delete=models.CASCADE)
I am using SQlite3, Django 2 version
Answer the question
In order to leave comments, you need to log in
Where does the title_id column come from? Either you do not show all the code, or you have scraps of experiments in the database. Recreate the database from scratch.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question