morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
204 stars 64 forks source link

Does the second URL need to start with ajax_datatable? #102

Closed michaeldacanay closed 1 year ago

michaeldacanay commented 1 year ago

So far, in the documentation, most paths had ajax_datatable/ in the URL path. Is this arbitrarily named or does that path need to start with that? For example, could I name the url path name ajax-datatable/tracks?

urlpatterns = [
    ...
    path('tracks/', views.tracks_list_view, name="tracks-list"),
    path('ajax_datatable/tracks/', ajax_datatable_views.TrackAjaxDatatableView.as_view(), name="ajax_datatable_track"),
    ...
cnagytcorp commented 1 year ago

they can be named anyway you like long as they are the same in the path and the table

"{% url 'ajax_datatable_permissions' %}" is the endpoint to the specialized view

urlpatterns = [ path('ajax_datatable/permissions/', ajax_datatable_views.PermissionAjaxDatatableView.as_view(), name="ajax_datatable_permissions"), ]

morlandi commented 1 year ago

Yes, any path will do as long as you're consistent in registering it with initialize_table():

        AjaxDatatableViewUtils.initialize_table(
            $('#datatable_permissions'),
            "{% url 'ajax_datatable_permissions' %}",
             ...
michaeldacanay commented 1 year ago

Sorry if I wasn't clear. I was referring more to the first parameter of the path (function?). But I think it can also be named anything, although I don't think it has a match anywhere else in the code.

morlandi commented 1 year ago

you can either write:

"{% url 'ajax_datatable_permissions' %}"

or

/ajax_datatable/permissions/