django-migrations

How to alter the ownership of some tables inside a database from postgres to another user?

╄→гoц情女王★ 提交于 2020-04-16 05:54:28
问题 I have a database which contains significant number of tables. Some of the tables are owned by postgres user and not the one I created. I want to transfer the ownership of such tables to the one I created,because when doing django-migrations, you can only set one user and password for the psql connection and that user doesnt have access to the tables owned by the postgres user, thus the migrations are not completed. So far, googling didn't help as they suggest either using ALTER or REASSIGN

ValueError: Related model u'app.model' cannot be resolved

北战南征 提交于 2020-04-07 16:59:28
问题 I have two applications ( ook and eek say) and I want to use a foreign key to a model in ook from a model in eek . Both are in INSTALLED_APPS with ook first. In ook.models.py , i have: class Fubar(models.Model): ... In eek.models.py , I have: class monkey(models.Model): external = models.ForeignKey('ook.Fubar', blank=True, null=True) ... The migration generated is: class Migration(migrations.Migration): dependencies = [ ('eek', '0002_auto_20151029_1040'), ] operations = [ migrations

How does django know which migrations have been run?

我是研究僧i 提交于 2020-03-18 03:08:21
问题 How does django know whether a migration has been applied yet? It usually gets it right, but when it doesn't I don't ever know where to start troubleshooting. 回答1: Django writes a record into the table django_migrations consisting of some information like the app the migration belongs to, the name of the migration, and the date it was applied. 回答2: You can simply use showmigrations command to provide a list of migrations $ python manage.py showmigrations whether or not each migration is

Django migrations - how to make it forget?

走远了吗. 提交于 2020-02-08 04:13:06
问题 I've been sketching out a new Django app with the runserver dev server running in a background window to tracking network wiring, and briefly had this in my model: class Interface(models.Model): name = models.CharField(max_length=200) # (blah) class Connection(models.Model): interface_from = models.ForeignKey(Interface, related_name="connections") interface_to = models.ForeignKey(Interface, related_name="connections") source = models.CharField(max_length=32) Before I realised I couldn't have

Django migrations - how to make it forget?

浪子不回头ぞ 提交于 2020-02-08 04:13:06
问题 I've been sketching out a new Django app with the runserver dev server running in a background window to tracking network wiring, and briefly had this in my model: class Interface(models.Model): name = models.CharField(max_length=200) # (blah) class Connection(models.Model): interface_from = models.ForeignKey(Interface, related_name="connections") interface_to = models.ForeignKey(Interface, related_name="connections") source = models.CharField(max_length=32) Before I realised I couldn't have

OperationalError: no such table

守給你的承諾、 提交于 2020-02-03 08:10:44
问题 So I was working on my app and added a slugfield to my models. Then as normal went ahead to makemigrations , and a massive red wall of errors appeared. Traceback (most recent call last): File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute return Database.Cursor.execute(self, query, params)

Django 1.7 remove field. Unknown field(s) (field) specified for Model

和自甴很熟 提交于 2020-01-25 17:35:11
问题 I have already many models in my application. I have already used migrations in my project. But when I want to remove a field from a model, the makemigration command show me : Unknown field(s) (field) specified for Model Where (fields) is equal to the field's name and Model is the model's name ? Do you have any solution to resolve this issue ? 回答1: You may try modifying auto_now and auto_now_add with default = 'xxx', then the field can be called 来源: https://stackoverflow.com/questions

Django 1.7 remove field. Unknown field(s) (field) specified for Model

折月煮酒 提交于 2020-01-25 17:35:08
问题 I have already many models in my application. I have already used migrations in my project. But when I want to remove a field from a model, the makemigration command show me : Unknown field(s) (field) specified for Model Where (fields) is equal to the field's name and Model is the model's name ? Do you have any solution to resolve this issue ? 回答1: You may try modifying auto_now and auto_now_add with default = 'xxx', then the field can be called 来源: https://stackoverflow.com/questions

InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>]

為{幸葍}努か 提交于 2020-01-22 07:17:24
问题 When I run tests I get this error during database initialization: django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>] This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth) I created this proxy for contrib.auth Group model to place it in my app in django admin: class GroupProxy(Group): class Meta: proxy = True verbose_name = Group._meta.verbose_name verbose_name_plural = Group._meta.verbose_name_plural

InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>]

杀马特。学长 韩版系。学妹 提交于 2020-01-22 07:16:07
问题 When I run tests I get this error during database initialization: django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>] This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth) I created this proxy for contrib.auth Group model to place it in my app in django admin: class GroupProxy(Group): class Meta: proxy = True verbose_name = Group._meta.verbose_name verbose_name_plural = Group._meta.verbose_name_plural