Comments (3)
Please retry with this branch: https://github.com/jrief/django-formset/tree/releases/1.0.x
or https://pypi.org/project/django-formset/1.0.dev0/
There the problem with validating unique indices is solved.
Unfortunately it will take a few additional weeks until I can release an official version, because I have to rewrite parts of the documentation.
from django-formset.
Yes, that works for fields with unique=True
.
I think I noticed another related issue: collections for related models do not know their parent instance during validation.
Inline formsets are instantiated with the parent instance of the relation, and that instance is passed on to the model forms as data for the InlineForeignKeyField. This way, the parent id is available for validation - most notably unique_together
validation.
This does not happen for collections for related models.
You can work around this when editing existing relations of an existing parent: since model_to_dict
includes the parent in the initial data of the relation's model form, you just need to include the formfield for the parent in the model form and it validates properly.
However, this doesn't work when you are adding a 'new parent', or a new relation to an existing parent. You need to validate the model form of the parent first, and then you can grab the form's instance and pass it on to the related collections. For example like it is done in django admin.
Currently when adding a new related object that would violate unique constraints, the validation for unique_together
is skipped when the form of the new object is first validated, because the parent field is missing data. Later, when trying to save the duplicate object, the parent instance is available, and a second validation of the form in construct_instance
fails as expected due to the unique constraint. The duplicate object is never saved, but the user doesn't know about this, because they are never presented an error.
from django-formset.
Please handle separate issues as such, and do not use an existing one for adding new features, otherwise we get confused.
I'm going to close this. Please open a new issue with the new request.
from django-formset.
Related Issues (20)
- Editing model with many-to-one relationship HOT 15
- New release needed HOT 1
- Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. HOT 3
- Not possible to set custom classes on input fields with the tailwind renderer HOT 1
- Problem with cyrillic in selectize widget. HOT 1
- loosing borders in selectize widget after pressing button "Reset to initial" in bootstrap mode HOT 10
- Still have the problem with new release 1.3.9. It happened when I use selectize widget and when I use active search in the widget and it tries to get answer from backend to get new list of options. HOT 6
- ColorField Support HOT 2
- df-disable="true" being ignored HOT 2
- BooleanField shows label twice HOT 2
- Style problem in Selectize widget. HOT 2
- Selectize programmatic value selection. HOT 10
- Event listener for add sibling button HOT 4
- DualSelector regression on v1.3.10 HOT 8
- Submit button shows bummer symbol after okay symbol. HOT 3
- The size of the input window does not change as the window size changes HOT 1
- Selectize widget in sortable FormCollection
- Labels in widget FileUpload shall be configurable
- Render form will always render default template HOT 4
- FormCollections with RichtextArea not working
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-formset.