{{{
class ArticleForm(ModelForm):
class Meta:
model = Article
fields = ['author', 'date']
def clean_date(self):
...
class ArticleCreateView(CreateView):
form_class = ArticleForm
model = Article # Redundant
}}}
A PoC to fix this is available here:
https://github.com/nim65s/django/commit/614dae5022bb5c7d8ad0336e17ef1e0c84b9dbbf
--
Ticket URL: <https://code.djangoproject.com/ticket/26220>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 1
* needs_docs: => 0
* has_patch: 0 => 1
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:1>
* cc: berker.peksag@… (added)
Comment:
Should we also make `model` optional for `UpdateView` and `DeleteView`?
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:2>
Comment (by Nim65s):
Replying to [comment:2 berkerpeksag]:
> Should we also make `model` optional for `UpdateView` and `DeleteView`?
What do you mean ? Is there any code that prevents you not to add a
`model` on an `UpdateView` or a `DeleteView` ?
In my case, I tested my PoC without any `model` and it worked… So it
''is'' optionnal, isn't it ?
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:3>
Comment (by Nim65s):
So I've checked tests. `SingleObjectMixin.get_queryset` needed the same
kind of modification.
Here is the updated commit:
https://github.com/nim65s/django/commit/3fca6100e573315169281ad15a513e8841791bfc
Tests are passing and coverage is green on my modifications.
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:4>
Comment (by timgraham):
Could you please create a patch following our PatchReviewChecklist and
send a pull request against master?
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:5>
* status: new => assigned
* owner: nobody => nim65s
Comment:
Here it is: https://github.com/django/django/pull/6311
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:6>
* needs_better_patch: 0 => 1
* needs_tests: 1 => 0
Comment:
Left a few comments for improvement. Please uncheck "Patch needs
improvement" after you update it. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:7>
* owner: Guilhem Saurel => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/26220#comment:8>