First, the existing model is in '0001_initial.py'.
After adding the 'models' I added, and when I did 'makemigrations', It's going into '0002_xxx.py'.
I succeeded in Migrate, and there was no problem with the database.
And then when these 'models' were added, I wanted to put the initial data into the database.
so I made fixture folder for putting in initial data after make migrations.
I put the json file in it.
However, when I changed the name of 'model' and did 'makemigrations' again, I had an error finding the table.
So I went directly to sqlite and erased all the tables on the new models.
Then I did makemigrations.
After that,
python3 manage.py migrate sbimage
When I do 'migrate' here like this,
django.db.utils.OperationalError: table "sbimage_camerathreshold" already exists
There's an error like this.
python3 manage.py migrate sbimage --fake
This has made both 0001, 0002 'FAKED'.
It's my 0002 file was created after 'makemigrations'.
from django.db import migrations, models
def load_my_initial_data(apps, schema_editor):
call_command("loaddata", "addition.json")
class Migration(migrations.Migration):
dependencies = [
('sbimage', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='AuthNumberR',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('auth_number_r', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='AuthNumberT',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('auth_number_t', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='Claimant',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('claimant', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='CountryOfOrigin',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('country_of_origin', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='EquipmentName',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('equipment_name', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='FccId',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('fcc_id', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='Manufacturer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('manufacturer', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='NbId',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nb_id', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='Publisher',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('publisher', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='WarningStateList',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('warning', models.CharField(max_length=4096)),
],
),
migrations.CreateModel(
name='WifiWarningStateList',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('wifi_warning', models.CharField(max_length=4096)),
],
),
migrations.RunPython(load_my_initial_data),
]
How do I create a table of newly created models in this situation?
This code dosen't work at all.
python3 manage.py migrate sbimage 0002
Running migrations: No migrations to apply.