Error with rules on CreateView introduced in 1.4
dyve opened this issue · comments
https://github.com/dfunckt/django-rules/blob/master/rules/contrib/views.py#L37
Using self.get_object
will introduce an error when using rules
on a view that inherits from CreateView
. This is because CreateView
does inherit SingleObjectMixin
and does have a get_object
callable, but it will throw an exception when its get_object
is called:
AttributeError: Generic detail view {InheritsFromCreateView} must be called with either an object pk or a slug.
Might even be a bug in Django. For rules, a (temporary) solution might be to make an exception for CreateView
.
PoC for the error in my fork: https://github.com/dyve/django-rules/tree/createview-bug
It only seems to happen with a rules that only takes 1 argument.
Oh, ouch, this is affecting me on rules==2.0
with a CreateView
as well.
Going to investigate a fix for this.
Oh, this #39 (comment) solved it for me!
I think the solution should be in django-rules
@dfunckt Any chance of a new release with this fix pulled in?