django-jsonfield

JsonEditor integration with Django Admin

女生的网名这么多〃 提交于 2019-11-30 07:29:17
I am working on integrating JSONEditor into the Django admin. There is one field in my model that uses the Postgres JSON and the Tree editor in this library is perfect. models.py class Executable(models.Model): """ Simplified model for sake of the question.""" recipe = JSONField(null=True, blank=True) I've made decent progress (I think) integrating the JSONEditor library within the appropriate create/edit screen in the Django Admin. The data is displayed correctly upon loading but for some reason when I make edits within the JSONEditorWidget the changes are not saved. I'm sure there is some

JsonEditor integration with Django Admin

◇◆丶佛笑我妖孽 提交于 2019-11-29 10:31:52
问题 I am working on integrating JSONEditor into the Django admin. There is one field in my model that uses the Postgres JSON and the Tree editor in this library is perfect. models.py class Executable(models.Model): """ Simplified model for sake of the question.""" recipe = JSONField(null=True, blank=True) I've made decent progress (I think) integrating the JSONEditor library within the appropriate create/edit screen in the Django Admin. The data is displayed correctly upon loading but for some

Django filter JSONField list of dicts

泪湿孤枕 提交于 2019-11-29 09:31:14
I run Django 1.9 with the new JSONField and have the following Test model : class Test(TimeStampedModel): actions = JSONField() Let's say the action JSONField looks like this : [ { "fixed_key_1": "foo1", "fixed_key_2": { "random_key_1": "bar1", "random_key_2": "bar2", } }, { "fixed_key_1": "foo2", "fixed_key_2": { "random_key_3": "bar2", "random_key_4": "bar3", } } ] I want to be able to filter the foo1 and foo2 keys for every item of the list. When I do : >>> Test.objects.filter(actions__1__fixed_key_1="foo2") The Test is in the queryset. But when I do : >>> Test.objects.filter(actions__0_

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

Django filter JSONField list of dicts

早过忘川 提交于 2019-11-27 06:41:11
问题 I run Django 1.9 with the new JSONField and have the following Test model : class Test(TimeStampedModel): actions = JSONField() Let's say the action JSONField looks like this : [ { "fixed_key_1": "foo1", "fixed_key_2": { "random_key_1": "bar1", "random_key_2": "bar2", } }, { "fixed_key_1": "foo2", "fixed_key_2": { "random_key_3": "bar2", "random_key_4": "bar3", } } ] I want to be able to filter the foo1 and foo2 keys for every item of the list. When I do : >>> Test.objects.filter(actions__1_

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