Sqlite3.OperationalError: нет такого столбца: user_customuser.fullname
Мое приложение django выдает эту ошибку при попытке использовать команду createsuperuser даже после удаления файла db и повторной синхронизации:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 477, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such column: user_customuser.fullname
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/Henkan/main_store/manage.py", line 22, in <module>
main()
File "/home/Henkan/main_store/manage.py", line 18, in main
execute_from_command_line(sys.argv)
models.py
from django.contrib.auth.models import AbstractUser
from django.db import models
from .managers import UserManager
from upload.models import Product
from django.conf import settings
class CustomUser(AbstractUser):
previous_orders = models.ManyToManyField(Product,related_name = 'previous_orders')
cart = models.ManyToManyField(Product,related_name = 'cart')
address = models.TextField(default='Address not provided')
fullname = models.CharField(max_length=20,default='Name')
email = models.EmailField(unique=True)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['fullname']
objects=UserManager()
def get_url(self):
token = settings.F.encrypt(bytes(self.email,encoding='utf8'))
return token
managers.py
from django.contrib.auth.base_user import BaseUserManager
class UserManager(BaseUserManager):
def create_user(self, email, password = None, **extra_fields):
if not email:
raise ValueError('Email is required')
extra_fields['email'] = self.normalize_email(email)
user = self.model(**extra_fields)
user.set_password(password)
user.save(using=self.db)
def create_superuser(self, email, password = None, **extra_fields):
extra_fields.setdefault('is_staff',True)
extra_fields.setdefault('is_superuser',True)
extra_fields.setdefault('is_active',True)
return self.create_user(email, password, **extra_fields)
Код работал раньше, но я пытался переключиться на fullname вместо имени пользователя, что привело к вышеупомянутой ошибке.