Django migrate throws AttributeError and I can't understand why

880 views
Skip to first unread message

Bogdan P.

unread,
Oct 9, 2016, 8:39:10 AM10/9/16
to Django users
Hello everyone.
I started to learn python and django and now I am building a small app so I can get used to them.
my first problem is that I've created a new model class Task with this structure:

name = models.CharField(max_length=100)
description
= models.TextField
modified_at
= models.DateTimeField(auto_now=True)
created_at
= models.DateTimeField(auto_now_add=True)

and when I run manage.py makemigrations my migration file looks like this:
 operations = [
        migrations.CreateModel(
            name='Task',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
        ),
    ]

the description field is skipped and I can't understand why. 
Also if I try to add it manually like this: ('description', models.TextField),
when I run manage.py migrate I get this error: AttributeError: type object 'TextField' has no attribute 'is_relation'

can someone please tell me why this is happening? I am missing something? I am doing something wrong?

Bogdan P.

unread,
Oct 9, 2016, 8:52:19 AM10/9/16
to Django users
I managed to solve this problem :)
In the model class instead of description = models.TextField I must write description = models.TextField(), I forgot the parentheses.
Reply all
Reply to author
Forward
0 new messages