I'm tyring to override the url to call specific methods for different types of urls. Code below
Resources.py
class LCUserResource(ModelResource):
class Meta:
queryset = LCUser.objects.all()
resource_name= 'lcuser'
authorization = Authorization()
def override_urls(self):
return [
url(r'^register/'%
(self._meta.resource_name, trailing_slash()), self.wrap_view('register_user'), name="api_register_user"),
]
urls.py
v1_api = Api(api_name='v1')
v1_api.register(LCUserResource())
urlpatterns = [
url(r'^api/', include(v1_api.urls)),
]
I'm trying to access the api via http://localhost:8000/api/v1/lcuser/register/
But i'm getting the error global name urls is not defined.
I tried importing from django.conf.urls.defaults import *
Then I get No module named defaults
You need to import url
from django.conf.urls import url