2

I am getting a weird issue when executing python manage.py migrate.

Below is the error.

django.db.utils.DatabaseError: Data truncated for column 'applied' at row 1

enter image description here

Can anyone help me?

Thanks

Here is my models.py data

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey has `on_delete` set to the desired behavior.
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals

from django.db import models


class Threads(models.Model):
    date = models.DateTimeField(db_column='Date', blank=True, null=True)  # Field name made lowercase.
    supplier = models.CharField(db_column='Supplier', max_length=45, blank=True, null=True)  # Field name made lowercase.
    activethreads = models.CharField(db_column='ActiveThreads', max_length=45, blank=True, null=True)  # Field name made lowercase.
    threadscreated = models.CharField(db_column='ThreadsCreated', max_length=45, blank=True, null=True)  # Field name made lowercase.
    ipaddress = models.CharField(db_column='IPAddress', max_length=45, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'Threads'


class DjangoContentType(models.Model):
    name = models.CharField(max_length=100)
    app_label = models.CharField(max_length=100)
    model = models.CharField(max_length=100)

    class Meta:
        managed = False
        db_table = 'django_content_type'
        unique_together = (('app_label', 'model'),)


class DjangoMigrations(models.Model):
    app = models.CharField(max_length=255)
    name = models.CharField(max_length=255)
    applied = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'django_migrations'
7
  • Show us your model and migration Commented Sep 29, 2016 at 7:57
  • Deselect NN and see what happens, otherwise post more context. Commented Sep 29, 2016 at 7:59
  • @SardorbekImomaliev - i have added model data in my question Commented Sep 29, 2016 at 8:09
  • @almostabeginner - I tried that, no luck. Commented Sep 29, 2016 at 8:31
  • Check settings.py --> Databases. Are you using mysql? Commented Sep 29, 2016 at 8:45

1 Answer 1

2

Solution of my problem is mentioned on the below URL, this is a bug with the latest version of Django. You need to change USE_TZ = False in settings.py

Incorrect datetime value when setting up Django with MySQL

After doing the above change then you will encounter a different issue while running "python manage.py migrate" which will give you the below error

TypeError: can't multiply sequence by non-int of type 'tuple'

For this issue please refer Chris Barrett solution mentioned below

https://bitbucket.org/Manfre/django-mssql/issues/80/error-when-using-django-19

You need to make the required changes in versions/3.5.2/lib/python3.5/site-packages/mysql/connector/django/operations.py (Check your setup) and make the changes

def bulk_insert_sql(self, fields, placeholder_rows):
        """
        Format the SQL for bulk insert
        """
        placeholder_rows_sql = (", ".join(row) for row in placeholder_rows)
        values_sql = ", ".join("(%s)" % sql for sql in placeholder_rows_sql)
        return "VALUES " + values_sql
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.