title: Django migrate: django.db.utils.OperationalError: (1364, "Field 'name' doesn't have a default value")
body: <p>basic datas:</p>
  
  <pre><code>mysql-server: 5.7.27-0ubuntu0.16.04.1
  Ubuntu: 16.04
  Python: 2.7.12
  Django: 1.11.16
  Virtualenv
  </code></pre>
  
  <p>I added a new application (gallery) and created the following table:</p>
  
  <pre><code>class Medi(models.Model):
      gd_id = models.CharField(max_length=128)
      name = models.CharField(max_length=512, default='1')
      original_name = models.CharField(max_length=512)
      title = models.CharField(max_length=512, blank=True, null=True)
      md5sum = models.CharField(max_length=32)
      date_of_event = models.DateTimeField()
      date_of_event_end = models.DateTimeField(blank=True, null=True)
      last_updated = models.DateTimeField(auto_now=True)
      created = models.DateTimeField(auto_now_add=True)
  </code></pre>
  
  <p>To be very clean after getting the above mentioned errors I deleted the table from the database, the entries from the django_migrations table and all the migrations file but <code>__init__.py</code>.</p>
  
  <p>I ran <code>makemigrations</code> and after that <code>migrate</code> which had the following output:</p>
  
  <pre><code># python manage.py makemigrations
  Migrations for 'gallery':
    gallery/migrations/0001_initial.py
      - Create model Medi
  
  # python manage.py migrate
  Operations to perform:
    Apply all migrations: admin, auth, bugtrack, common, contenttypes, follow, gallery, infokom, phonebook, sessions, sites
  Running migrations:
    Applying gallery.0001_initial... OK
  Traceback (most recent call last):
    File "manage.py", line 22, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
      utility.execute()
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
      output = self.handle(*args, **options)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 227, in handle
      self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/core/management/sql.py", line 53, in emit_post_migrate_signal
      **kwargs
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send
      for receiver in self._live_receivers(sender)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 63, in create_permissions
      ctype = ContentType.objects.db_manager(using).get_for_model(klass)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 60, in get_for_model
      model=opts.model_name,
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/query.py", line 466, in get_or_create
      return self._create_object_from_params(lookup, params)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/query.py", line 500, in _create_object_from_params
      obj = self.create(**params)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/query.py", line 394, in create
      obj.save(force_insert=True, using=self.db)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/base.py", line 808, in save
      force_update=force_update, update_fields=update_fields)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/base.py", line 838, in save_base
      updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/base.py", line 924, in _save_table
      result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/base.py", line 963, in _do_insert
      using=using, raw=raw)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/query.py", line 1079, in _insert
      return query.get_compiler(using=using).execute_sql(return_id)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1112, in execute_sql
      cursor.execute(sql, params)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
      return super(CursorDebugWrapper, self).execute(sql, params)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
      return self.cursor.execute(sql, params)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
      six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
      return self.cursor.execute(sql, params)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 101, in execute
      return self.cursor.execute(query, args)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
      self.errorhandler(self, exc, value)
    File "/home/lenovo/.virtualenvs/gjt/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
      raise errorclass, errorvalue
  django.db.utils.OperationalError: (1364, "Field 'name' doesn't have a default value")
  </code></pre>
  
  <p>What is strange is that even if there's the error it creates the table. I can save objects there and there's also an entry in the <code>django_migrations</code> table. Also, <code>showmigrations</code> shows that this migrations is done. However, when I run the <code>migrate</code> command again I get the same error.</p>
  
  <p>My question is what can cause this problem and how can I solve it? After removing the <strong>STRICT_TRANS_TABLES</strong> from the mysql config file, this error turns to be a warning, but it's still annoying. What causes this?</p>