question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What 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:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ton77vcommented, Oct 27, 2019

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

0reactions
stale[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found