Cannot overwrite default views in ModelAdmin2 subclasses
tyrion opened this issue · 0 comments
tyrion commented
I have an admin2.py file that looks like this:
import djadmin2
from djadmin2 import views
from .models import MyModel
class CustomView(views.ModelAddFormView):
def get(self, *args, **kwargs):
raise Exception("we don't get here")
class MyModelAdmin(djadmin2.ModelAdmin2):
create_view = views.AdminView(r'^create/$', CustomView, name='create')
custom_view = views.AdminView(r'^custom/$', CustomView, name='custom')
djadmin2.default.register(MyModel, MyModelAdmin)
Trying to add a new "MyModel" does not trigger the exception.
Going to "custom/" instead seems to work.
I think this is because in self.views there are all the views of djadmin2.ModelAdmin2 and so my "create_view" won't get matched because there is already djadmin2.ModelAdmin2 declared before.