oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 81 forks source link

TypeError when using namespaces with inlines. #124

Closed A4TIF closed 4 years ago

A4TIF commented 4 years ago

I can't seem to figure out this error, is there something I'm doing wrong?

Error: TypeError: 'MessageImage_AjaxCRUD' object is not callable

class MessageImage_AjaxCRUD(InlineAjaxCRUD):
    namespace = 'backend'
    check_perms = True
    check_login = True
    model = MessageImage
    base_model = Message
    inline_field = 'message'
    fields = ['image', ]
    title = _("Images")

class MessageCRUD(CRUDView):
    namespace = 'backend'
    check_perms = True
    check_login = True
    model = Message
    inlines = [MessageImage_AjaxCRUD]
    list_fields = ['product', 'message']
    list_filter = ['product']

In project urls.py: re_path(r'^', include('backend.urls')),

In my app backend/urls.py:

app_name = 'backend'

message_view = crud_views.MessageCRUD()

urlpatterns = [
    ...
    path('', include(message_view.get_urls())),
    ...
]

Using: Python 3.7.4 Django version 2.2.4

If I remove the namespace from views, the action links are not visible and get 404 errors in update pages :(

A4TIF commented 4 years ago

Looks like moving my app's urlpattern to project url.py and removing namespaces worked. Not sure if this is how it was designed to work.