A
A
ahmed_al_asad2016-10-17 01:24:26
Django
ahmed_al_asad, 2016-10-17 01:24:26

Why doesn't django want to migrate migrations?

I use django 1.9
In general, I created a model:

from django.db import models

# Create your models here.

class content(models.Model):
    title = models.CharField(max_length=255)
    subTitle = models.CharField(max_length=200)
    contactTitle = models.CharField(max_length=255)
    address = models.TextField(max_length=500)
    subAddress = models.TextField(max_length=300)

    def __str__(self):
        return self.title

and created a migration:
class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='content',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=255)),
                ('subTitle', models.CharField(max_length=200)),
                ('contactTitle', models.CharField(max_length=255)),
                ('address', models.TextField(max_length=500)),
                ('subAddress', models.TextField(max_length=300)),
            ],
        ),
    ]

Tried to create a table using migration but nothing worked
(env) MacBook-Pro-Ahmed:landing HeartProgrammer$ python manage.py makemigrations
Migrations for 'content':
  0001_initial.py:
    - Create model content
(env) MacBook-Pro-Ahmed:landing HeartProgrammer$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, content, sessions
Running migrations:
  No migrations to apply.
(env) MacBook-Pro-Ahmed:landing HeartProgrammer$

What am I doing wrong? Tell a newbie.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Yakovenko, 2016-10-17
@ahmed_al_asad

The output says that the migration has already been applied before, check the database if you have a content table .
You can also look at the migration entries: SELECT * FROM django_migrations;
It seems that there is even a command for this in django-admin:python manage.py showmigrations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question