sqlite3 - Django 1.9 - created new app run migrate, tables are not created -
ive added new app , created models. have run makemigrations , migrate , went successfully. when open sqlite table, none of tables created.
sample models:
from __future__ import unicode_literals django.db import models django.conf import settings import string import random import time import os # create models here. service.models import servicecontacts class subnets(models.model): subnet = models.genericipaddressfield(protocol='ipv4',verbose_name="subnet",blank=true,null=true) subnet_mask = models.charfield(max_length=4,verbose_name="subnet mask",choices=settings.subnet_mask_choices,blank=true) subnet_type = models.charfield(max_length=10 ,verbose_name='subnet type',choices=settings.subnet_type_choices,blank=true) class meta: verbose_name = "site subnet data" verbose_name_plural = "site subnet data" class sitecontacts(models.model): name = models.charfield(max_length=200) title = models.charfield(max_length=200) mobile = models.charfield(max_length=200,blank=true, null=true) ddi = models.charfield(max_length=200,blank=true, null=true) notes = models.textfield(blank=true, null=true) class meta: verbose_name = "site contact data" verbose_name_plural = "site contact data"
sample inital
# -*- coding: utf-8 -*- # generated django 1.9.6 on 2016-11-09 17:32 __future__ import unicode_literals django.db import migrations, models import django.db.models.deletion import sites.models class migration(migrations.migration): initial = true dependencies = [ ('service', '0007_auto_20160701_0931'), ] operations = [ migrations.createmodel( name='circuitfiles', fields=[ ('id', models.autofield(auto_created=true, primary_key=true, serialize=false, verbose_name='id')), ('circuit_file', models.filefield(blank=true, upload_to=sites.models.service_upload_path)), ('file_name', models.charfield(max_length=200, verbose_name='file name')), ], options={ 'verbose_name': 'circuit files', 'verbose_name_plural': 'circuit files', }, ), migrations.createmodel( name='circuitnotes', fields=[ ('id', models.autofield(auto_created=true, primary_key=true, serialize=false, verbose_name='id')), ('date', models.datefield()), ('notes', models.textfield(blank=true)), ], options={ 'verbose_name': 'circuit notes', 'verbose_name_plural': 'circuit notes', }, ),
tables sqlite3db
[root@network-tools infternal]# sqlite3 db.sqlite3 sqlite version 3.7.17 2013-05-20 00:56:22 enter ".help" instructions enter sql statements terminated ";" sqlite> .tables auth_group networks_circuitnotes auth_group_permissions networks_configtemplates auth_permission networks_configvariables auth_user networks_majorsiteinfodata auth_user_groups networks_networkstock auth_user_user_permissions networks_networkstockusage django_admin_log networks_showroomconfigdata django_content_type networks_sitecontacts django_migrations networks_sitefiles django_session networks_sitefiletype django_site networks_snmpdata sqlite>
i should see sites_subnets , sites_sitecontacts in there, many others.
the migrations table has below in it, cant see sites|0001_inital in there...
100|networks|0069_configvariables_type|2016-11-03 15:17:41.424747 101|networks|0070_circuitinfodata_circuit_preference|2016-11-09 09:11:29.358213 102|networks|0071_auto_20161109_0915|2016-11-09 09:15:22.455639 103|networks|0072_auto_20161109_0916|2016-11-09 09:16:25.962542 104|sites|0002_auto_20161110_0859|2016-11-10 08:59:31.071382
installed apps:
installed_apps = ( 'home.apps.homeconfig', 'oncall.apps.oncallconfig', 'networks.apps.networksconfig', 'sites.apps.sitesconfig',
make migrations:
[root@network-tools infternal]# python manage.py makemigrations migrations 'networks': 0073_auto_20161110_1059.py: - alter field circuit_type on circuitinfodata migrations 'sites': 0003_auto_20161110_1059.py: - alter field circuit_type on circuits [root@network-tools infternal]# python manage.py migrate operations perform: apply migrations: service, sessions, admin, sites, auth, contenttypes, maintenance, oncall, networks running migrations: rendering model states... done applying networks.0073_auto_20161110_1059... ok applying sites.0003_auto_20161110_1059...traceback (most recent call last): file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() file "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) file "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) file "/usr/lib64/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) file "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) file "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) file "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py", line 198, in apply_migration state = migration.apply(state, schema_editor) file "/usr/lib64/python2.7/site-packages/django/db/migrations/migration.py", line 123, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) file "/usr/lib64/python2.7/site-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) file "/usr/lib64/python2.7/site-packages/django/db/backends/base/schema.py", line 482, in alter_field old_db_params, new_db_params, strict) file "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 253, in _alter_field self._remake_table(model, alter_fields=[(old_field, new_field)]) file "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 184, in _remake_table self.alter_db_table(model, temp_model._meta.db_table, model._meta.db_table) file "/usr/lib64/python2.7/site-packages/django/db/backends/base/schema.py", line 359, in alter_db_table "new_table": self.quote_name(new_db_table), file "/usr/lib64/python2.7/site-packages/django/db/backends/base/schema.py", line 110, in execute cursor.execute(sql, params) file "/usr/lib64/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(cursordebugwrapper, self).execute(sql, params) file "/usr/lib64/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) file "/usr/lib64/python2.7/site-packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) file "/usr/lib64/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) file "/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute return database.cursor.execute(self, query, params) django.db.utils.operationalerror: no such table: sites_circuits
try migrate particular app using following process.
if create initial migration , run migrate command sometime migration not don try migrate using following command
python manage.py makemigrations
initial migration created run migrate command app name
python manage.py migrate appname
hope you
Comments
Post a Comment