django-1.9

Why does Django make migrations for help_text and verbose_name changes?

戏子无情 提交于 2019-11-29 02:49:27
When I change help_text or verbose_name for any of my model fields and run python manage.py makemigrations , it detects these changes and creates a new migration, say, 0002_xxxx.py . I am using PostgreSQL and I think these changes are irrelevant to my database (I wonder if a DBMS for which these changes are relevant exists at all). Why does Django generate migrations for such changes? Is there an option to ignore them? Can I apply the changes from 0002_xxxx.py to the previous migration ( 0001_initial.py ) manually and safely delete 0002_xxxx.py ? Is there a way to update previous migration

Django 1.9 JSONField order_by

倖福魔咒の 提交于 2019-11-28 10:03:34
I have the following django model that contains JSONField: class RatebookDataEntry(models.Model): data = JSONField(blank=True, default=[]) last_update = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = 'Ratebook data entries' And data field contains this json: { "annual_mileage": 15000, "description": "LEON DIESEL SPORT COUPE", "body_style": "Coupe", "range_name": "LEON", "co2_gkm_max": 122, "manufacturer_name": "SEAT" } Can I sort queryset by one of the data fields? This query doesn't work. RatebookDataEntry.objects.all().order_by("data__manufacturer_name") As Julien

Why does Django make migrations for help_text and verbose_name changes?

夙愿已清 提交于 2019-11-27 17:06:36
问题 When I change help_text or verbose_name for any of my model fields and run python manage.py makemigrations , it detects these changes and creates a new migration, say, 0002_xxxx.py . I am using PostgreSQL and I think these changes are irrelevant to my database (I wonder if a DBMS for which these changes are relevant exists at all). Why does Django generate migrations for such changes? Is there an option to ignore them? Can I apply the changes from 0002_xxxx.py to the previous migration ( 0001

Django 1.9 ImportError for import_module

会有一股神秘感。 提交于 2019-11-27 14:16:54
When trying to run either runserver or shell using manage.py I get an ImportError exception. I'm using Django 1.9. ImportError: No module named 'django.utils.importlib' django.utils.importlib is a compatibility library for when Python 2.6 was still supported. It has been obsolete since Django 1.7, which dropped support for Python 2.6, and is removed in 1.9 per the deprecation cycle. Use Python's import_module function instead: from importlib import import_module The reason you can import it from django.utils.module_loading is that importlib.import_module is imported in that module, it is not

Django 1.9 JSONField order_by

别等时光非礼了梦想. 提交于 2019-11-27 03:23:05
问题 I have the following django model that contains JSONField: class RatebookDataEntry(models.Model): data = JSONField(blank=True, default=[]) last_update = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = 'Ratebook data entries' And data field contains this json: { "annual_mileage": 15000, "description": "LEON DIESEL SPORT COUPE", "body_style": "Coupe", "range_name": "LEON", "co2_gkm_max": 122, "manufacturer_name": "SEAT" } Can I sort queryset by one of the data fields? This