Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize URL #96

Open
fjbardelli opened this issue Feb 15, 2019 · 8 comments
Open

Customize URL #96

fjbardelli opened this issue Feb 15, 2019 · 8 comments

Comments

@fjbardelli
Copy link

It is possible to customize the URL, to give a complete form to the root, for example instead of

127.0.0.1:8000/app_two/model_1/list

to be

127.0.0.1:8000/api/list

Thank you so much

@oscarmlage
Copy link
Owner

I think so but Instead of defining the urls for the whole app like this:

urlpatterns += crud_for_app('testapp')

You should define the urls for every CRUD resource like this:

    url(r'/api/author', include(authorcrud.get_urls())),
    url(r'/api/invoice', include(invoicecrud.get_urls())),
    url(r'/api/customer', include(customercrud.get_urls())),

And you will get urls like:

  • api/author/list
  • api/author/create
  • ...

Please take a look to the documentation and the testapp sample in the repo:

Dunno if it fits for you, feedback is always welcome ;)

@oscarmlage
Copy link
Owner

Maybe a good idea is be able to pass the url you want to get_urls() method to customize not only at model level but at resource level too. i.e.:

url(r'/my/custom/list', include(authorcrud.get_urls('list'))),
url(r'/my/custom/del', include(authorcrud.get_urls('delete'))),

What do you think guys? @luisza @migue56 @mbourqui

@fjbardelli
Copy link
Author

this solution does not work, gives the following error and the server does not sell

path('api/ina/', include(MotivoInasistenciaCRUDView().get_urls('list'))),

path('api/ina/', include(MotivoInasistenciaCRUDView().get_urls('list'))),

TypeError: get_urls() takes 1 positional argument but 2 were given

in this other

path('api/ina/', include(MotivoInasistenciaCRUDView().get_urls())),

I form this url

api/ina/

@oscarmlage
Copy link
Owner

this solution does not work, gives the following error and the server does not sell

No, I don't mean it's working now like that, I mean that could be a good idea to extend the functionality -as a new feature- if you call get_urls() with an extra argument.

@fjbardelli
Copy link
Author

Ok, sorry yes that great

Thanks

@mbourqui
Copy link
Contributor

From a conceptual point of view, I think it makes sense, as you may not want to expose the full CRUD urls. Or as mentioned, customize only one or the other resource.
But I haven't check how feasible it would be.

@Seykotron
Copy link

I think that it could be nice to customize the URL and the URL name we can achieve this by making a dict attribute.

If dict is None then the "normal" behavior, else if the dict have the key "list" : { "name" = "auth_group_list", "url" : "/auth/group/list" }

It would be nice and easy I think :)

@chavanmahi
Copy link

s

I'm just getting this page it's something wrong in URL can u plz solve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants