foreignkey (user) in models
Don't use the User
model directly.
From the documentation
Instead of referring to
User
directly, you should reference the user model usingdjango.contrib.auth.get_user_model()
When you define a foreign key or many-to-many relations to the user model, you should specify the custom model using the
AUTH_USER_MODEL
setting.
Example:
from django.conf import settingsfrom django.db import modelsclass Article(models.Model): author = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, )
If you created a custom User model, you would use setting.AUTH_USER_MODEL
, if not you can go ahead an use User model
the column "author_id" doesn't exist, looks like is the same problem from here : Django suffix ForeignKey field with _id , so to avoid this traceback you may use :
author = models.ForeignKey(User, db_column="user")