0

While shifting database from sql light to cloudcluster, Got the Error- django.db.utils.IntegreityError: (1364,"Field 'name' doesnt have a default value") on running migrations as follows-

ONLY Port engine,database , database password was changed.

python manage.py makemigrations
python manage.py migrate sessions
python manage.py migrate auth 
python manage.py migrate migrate 

its giving me error -

ProgrammingError at /admin/login/ (1364,"Field 'name' doesnt have a default value")

while my

Models.py code

from django.db import models
from arasdir import settings

# Create your models here.
import django.db.backends.mysql
class category(models.Model):
    category_id = models.AutoField(primary_key=True)
    category_name=models.CharField(max_length=500)
    category_chemical=models.CharField(max_length=10)
    category_biological=models.CharField(max_length=10)
    def __str__(self):
        return self.category_name

class Siginingauthlist(models.Model):
    employee_id = models.AutoField(primary_key=True)
    employee_name=models.CharField(max_length=500)
    department_sign=models.CharField(max_length=10)
    sign_designation=models.CharField(max_length=50)
    year_validfrom=models.DateField()
    year_validthrough=models.DateField()
    def __str__(self):
        return self.department_sign
ritu
  • 43
  • 1
  • 8
  • Did you try this? https://stackoverflow.com/a/58981719/12870513 – Karthik Aug 31 '20 at 06:58
  • i am sorry for silly questions. i am new. i will try ALTER TABLE django_content_type MODIFY COLUMN name what is name here? it never asked me with sqlite – ritu Aug 31 '20 at 07:00
  • By default Django has a table called auth_user serving the user authentication which doesn't contain a field called name, so my assumption is that you have a custom AUTH_USER_MODEL defined in your settings.py which contains a field called name with not set default value. – Karthik Aug 31 '20 at 07:01
  • I tried this alter table command now error 2 on making migrations is over now but i am still getting error 1 – ritu Aug 31 '20 at 07:05
  • You have to create another superuser for that because you have migrated db – Karthik Aug 31 '20 at 07:06
  • on running command python manage.py createsuperuser its giving error django.db.utils.ProgrammingError: (1146, "Table 'databasename.auth_user' doesn't exist") – ritu Aug 31 '20 at 07:09
  • Check this out https://stackoverflow.com/questions/29994606/why-do-i-get-a-auth-user-does-not-existerror-when-running-migrate-on-a-newly/30447129 – Karthik Aug 31 '20 at 07:10
  • Tried make migrations ,migrate ,migrate auth . later for creating superuser command -same error table not found – ritu Aug 31 '20 at 07:16
  • I will suggest you to recreate the database from scratch as any dependency may have been created as you are concurrently trying several approaches – Karthik Aug 31 '20 at 07:19

0 Answers0