django.db.utils.OperationalError when remove the parent model

44 views
Skip to first unread message

Cheng-Hung Hsueh

unread,
Sep 14, 2016, 2:00:35 AM9/14/16
to Django users
My original models like this

class A(models.Model):
    data
= models.CharField(max_length=30)

class B(models.Model):
   
pass

Make migrations, then I modified the artitecture

class A(models.Model):
    data
= models.CharField(max_length=30)

class B(models.Model):
   
pass

Make migration and migrate.

get the error:

  File "/..../lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute
   
return Database.Cursor.execute(self, query, params)
django
.db.utils.OperationalError: near ")": syntax error

Is it a bug?

Env:
django 1.10.1

Cheng-Hung Hsueh

unread,
Sep 14, 2016, 2:02:54 AM9/14/16
to Django users

Simon Charette

unread,
Sep 14, 2016, 2:09:36 AM9/14/16
to Django users
Hi Cheng-Hung,

This is know bug[1]

Simon

[1] https://code.djangoproject.com/ticket/24424

Le mardi 13 septembre 2016 22:02:54 UTC-4, Cheng-Hung Hsueh a écrit :

Cheng-Hung Hsueh

unread,
Sep 14, 2016, 2:28:59 AM9/14/16
to Django users
I tyied with some new filed in model B.

class A(models.Model):
    data
= models.CharField(max_length=30)

class B(A):
    data2
= models.CharField(max_length=30)

to

class A(models.Model):
    data
= models.CharField(max_length=30)


class B(models.Model):

    data2
= models.CharField(max_length=30)

migrated and got

  File "/.../lib/python3.4/site-packages/django/db/models/base.py", line 226, in __new__
   
base.__name__,
django
.core.exceptions.FieldError: Local field 'id' in class 'B' clashes with field of the same name from base class 'A'.


Reply all
Reply to author
Forward
0 new messages