'django - model foreign key as logged user

I've got model code as follows:

from django.db import models
from django.core.validators import MinLengthValidator
from django.urls import reverse
from django.conf import settings

class Doc(models.Model):
...
added_by = models.CharField(blank=False,null=True,max_length=100,validators=[MinLengthValidator(10)])
added_by_2 = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
...

I can migrate this without any problems, but every when I run server and in admin site try to view all records I get:

Exception Type: OperationalError
Exception Value: no such column: added_by_2_id

What is the cause of this error? How to resolve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source