Comments (4)
Great - thanks for confirming.
from django-import-export.
Are you using v4.0.3? Are you using any third party plugins?
from django-import-export.
I couldn't reproduce this in the example app by declaring the following on the Book model:
name = models.CharField(
verbose_name=_("Name"),
max_length=80,
blank=True, # <--- I think problem is here
)
When we have seen this before it is because there is a custom field type (i.e. from a third party app) which is being identified as a CharField
or subclass, but then is not being created with the correct Widget type.
If you could reproduce in the example app, or provide a failing test case, that would be ideal.
The other thing to check is that you are declaring resources correctly in the Admin file:
# this is correct
resource_classes = [YourResource]
# this is not correct
resource_class = YourResource
In the latter case, we have seen that this can cause issues.
from django-import-export.
@matthewhegarty Sorry for late answer.
When we have seen this before it is because there is a custom field type (i.e. from a third party app) which is being identified as a CharField or subclass, but then is not being created with the correct Widget type.
You are right. Before v4 we added own CharWidget
where replace None
by empty strings.
Our solution:
class CharWidget(Widget):
"""Widget for converting text fields."""
def clean(
self,
value: str | None,
row: None = None,
*args,
**kwargs,
) -> str:
"""Return empty string for values which is None.
Since CharField can only be blank, when importing, it needs to be
convert none to an empty string.
"""
value = super().clean(value, row, *args, **kwargs)
return "" if value is None else value
But now as I can see it works out of the box: docstring and code
So I think we can just remove this part of code. Thank you for help!
from django-import-export.
Related Issues (20)
- delete field and skip_field = False do not seem to work together HOT 2
- `Resource.get_fields()` no longer called outside of tests HOT 1
- Incorrect configuration of `STORAGES`
- Importing AND displaying related models at importing preview HOT 1
- Export fields not shown if ModelField of different name defined in ModelResource HOT 4
- DateWidget render() gives empty string when handling DateTime HOT 1
- Widget ManyToManyWidget cannot find m2m connections HOT 2
- Docs: screenshot page shows duplicate image and not export form
- Handle confirm_form validation errors gracefully HOT 10
- Warn for declared fields not in Meta.fields
- Dataset Import Doesn't Validate Against Model Constraints HOT 2
- Hide resource field when only one resource? HOT 1
- `test_import.py` module is large and can be broken up into smaller modules HOT 1
- Set up `pre-commit.ci`
- `import_id_fields` as foreign key shows Update instead of New HOT 1
- Avoid thousand separators in NumberWidget HOT 3
- Set up ReadTheDocs PR previews? HOT 3
- Create m2m relations with existing data in the Database HOT 1
- Import fails hard for skipped rows HOT 4
- Autogenerated fields and dehydrate methods? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-import-export.