-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Fixed #10403 -- Added a declarative syntax for FormSet, ModelFormSet & InlineFormSet. #17905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…nlineFormSet This patch inlcude the classes FormSet, ModelFormSet and InlineFormSet from which other class can be directly inherited to create a formset class instead of using the default factory functions.
Added the references on how to create Formsets using the declarative syntax which is an alternative method to using formset_factory functions
Improved the topics page for the FormSet
…sing a declarative syntax
…g a declarative syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! Thank you for your contribution 💪
As it's your first contribution be sure to check out the patch review checklist.
If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!
If you have any design or process questions then you can ask in the Django forum.
Welcome aboard ⛵️!
Thanks @Mitchina, for taking the time to work on this ancient PR. |
Hi @Parth1811, thank you for the encouragement! I'm glad to hear that you find the changes promising. Your changes and @carltongibson directions have been fundamental to me and I truly appreciate the opportunity to build upon them. I hope we can get it in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Mitchina 👋 thank you for being patient waiting for a review
I recommend that you squash these commits into one and add a commit message that is described in the committing guidelines.
It might make sense to turn this into a couple of commits and we might recommend to separate some stuff out later but for now, I think one commit is cleaner.
This is going to take quite a while to review and for us to work together to get it ready to merge. Just to manage your expectations, we already have a few PRs which have been in progress for quite some time that we are trying to push into 5.1 (the alpha freeze deadline is 22nd May). As this is unlikely to meet that deadline, we will aim to give this a more thorough review after the alpha freeze and hope to progress this for 5.2.
@@ -1,3 +1,5 @@ | ||
from typing import Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Django is not using type annotations, please remove each of these ❤️
missing required argument and sets them to default values. | ||
""" | ||
if "form" not in set(attrs): | ||
raise TypeError("FormSet() missing 1 required positional argument: 'form'.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a test
def __init__( | ||
self, | ||
queryset=None, | ||
): | ||
"""Initialize ModelFormSet.""" | ||
super().__init__( | ||
queryset, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__( | |
self, | |
queryset=None, | |
): | |
"""Initialize ModelFormSet.""" | |
super().__init__( | |
queryset, | |
) | |
def __init__(self, queryset=None): | |
super().__init__(queryset) |
(nit)
def __init__( | ||
self, | ||
instance=None, | ||
): | ||
"""Initialize ModelFormSet.""" | ||
super().__init__( | ||
instance, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__( | |
self, | |
instance=None, | |
): | |
"""Initialize ModelFormSet.""" | |
super().__init__( | |
instance, | |
) | |
def __init__(self, instance=None): | |
super().__init__(instance) |
"""Meta class for creating inlineformset using Declarative Syntax.""" | ||
|
||
def __new__(cls, name, bases, attrs): | ||
"""Initialize the attributes given to the InlineFormSet class.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Initialize the attributes given to the InlineFormSet class.""" |
I would say some of these comments are not needed as the code is self explanatory
Only users with view or change model permissions can access. Thank you to Sarah Boyce for the review.
I was confused by this for a second, the Trac ID is the same as this PR number. Though not sure if this is still being worked on. |
Only users with view or change model permissions can access. Thank you to Sarah Boyce for the review.
Only users with view or change model permissions can access. Thank you to Sarah Boyce for the review.
This patch is an update of @Parth1811 's closed PR.
It includes classes for FormSet, ModelFormSet, and InlineFormSet, allowing for the creation of formsets using a declarative syntax instead of a factory.