Hi i am wondering how i can reverse a urlpattern path that uses include pattern. Since there is no namespace i don't know how to reverse it. Also i am new to Django so all this is a little bizarre to me.
v1_api = Api(api_name='v1')
urlpatterns = [path('', include(v1_api.urls))] + restless.get_urls()
I want to use reverse('something') from django.urls import reverse
class SiteResource(ModelResource):
baselayer = fields.ToOneField(
'DataLayerResource',
'baselayer',
null=True)
class Meta(ModelResource.Meta):
queryset = models.Site.objects.all()
resource_name = 'site'
authorization = SiteAuthorization()
validation = CleanedDataFormValidation(form_class=SiteForm)
detail_allowed_methods = ['get', 'post', 'put', ]
list_allowed_methods = ['get', 'post']
excludes = []
abstract = False
filtering = {
'site_name': ALL,
'verbose_site_name': ALL,
'site_id': ALL,
'site_path': ALL,
'extent': ALL,
}
As per Tastypie's source code there are a few standard methods which are implemented which you can find over here
The basic pattern to reverse a URL in Tastypie is
In your case, let's assume you want the URL for
api_dispatch_list. Your name of the resource issiteand api_name isv1So the URL in this case would be
and would come out to
/api/v1/site/