JSONField import
See original GitHub issueWhat i need do, than import data in FSONField?
I use:
class ProductResource(resources.ModelResource):
category = fields.Field(attribute='category', column_name='category',
widget=ForeignKeyWidget(Category, 'name'))
brand = fields.Field(attribute='brand', column_name='brand',
widget=ForeignKeyWidget(Producer, 'name'))
properties = fields.Field(attribute='properties', column_name='properties', widget=JSONWidget)
class Meta:
model = Product
fields = ('id', 'name', 'price', 'category', 'brand', 'properties', 'description')
export_order = ('id', 'name', 'price', 'category', 'brand', 'properties', 'description')
And i have Error:
Object of type Product is not JSON serializable
As I understand, need point field name, but JSONWidget not takes arguments.
If i not use JSONWidget. Export works great, but import as string data in JSONField.
May be you can help me, what should i use to fix it, if this is possible?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
jsonfield - PyPI
jsonfield is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database.
Read more >Migrating to the Django 3.1 JSON Field - Oak-Tree Technologies
In this blog post, we take a look at migrating to JSONField in an existing project ... from django.db.models import TextField, JSONField, ...
Read more >Django 1.9 - JSONField in Models - Stack Overflow
UPDATE: Django 3.1 now supports JSONField natively for multiple databases: ... from django.db import models from django_mysql.models import JSONField class ...
Read more >Django jsonfield | Learn the process of creating a JSON field ...
This is how the import process works for the models. Very importantly, the JSON field is allocated with a nullable value which allows...
Read more >Adding JSON field in Django models - Tutorialspoint
import jsonfield from django.db import models # Create your models here. class StudentData(models.Model): name=models.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works for me: https://github.com/django-import-export/django-import-export/issues/285#issuecomment-312020642
Although I had so switch from CSV to TSV because otherwise commas inside JSON raise InvalidDimensions exception during the import
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.