1๐
โ
I think, what you are looking for is the prepend_url
function, see here. You could use it like this:
class AuthenticateUser(Resource)
class Meta:
resource_name = "authenticateUser"
def prepend_urls(self):
#add the cancel url to the resource urls
return [
url(r"^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/register%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('register'), name="api_authenticate_register"),
]
def register(self, request, **kwargs):
# check request
self.method_check(request, allowed=['post'])
# handle your request here, register user
return self.create_response(request, <some method>)
With this, you could call it like this:
http://localhost:8000/authenticateUser # to authenticate
http://localhost:8000/authenticateUser/register # to register
Another option would be, to just create two resources (on inheriting from the other) and just change the resource_name
in the meta class
๐คRemi Smirra
Source:stackexchange.com