How to use the djangorestframework.reverse.reverse function in djangorestframework

To help you get started, we’ve selected a few djangorestframework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github encode / django-rest-framework / examples / pygments_api / views.py View on Github external
def get(self, request):
        """
        Return a list of all currently existing snippets.
        """
        unique_ids = [os.path.split(f)[1] for f in list_dir_sorted_by_ctime(HIGHLIGHTED_CODE_DIR)]
        return [reverse('pygments-instance', request=request, args=[unique_id]) for unique_id in unique_ids]
github encode / django-rest-framework / examples / sandbox / views.py View on Github external
def get(self, request):
        return [{'name': 'Simple Resource example', 'url': reverse('example-resource', request=request)},
                {'name': 'Simple ModelResource example', 'url': reverse('model-resource-root', request=request)},
                {'name': 'Simple Mixin-only example', 'url': reverse('mixin-view', request=request)},
                {'name': 'Object store API', 'url': reverse('object-store-root', request=request)},
                {'name': 'Code highlighting API', 'url': reverse('pygments-root', request=request)},
                {'name': 'Blog posts API', 'url': reverse('blog-posts-root', request=request)},
                {'name': 'Permissions example', 'url': reverse('permissions-example', request=request)}
                ]
github encode / django-rest-framework / examples / sandbox / views.py View on Github external
def get(self, request):
        return [{'name': 'Simple Resource example', 'url': reverse('example-resource', request=request)},
                {'name': 'Simple ModelResource example', 'url': reverse('model-resource-root', request=request)},
                {'name': 'Simple Mixin-only example', 'url': reverse('mixin-view', request=request)},
                {'name': 'Object store API', 'url': reverse('object-store-root', request=request)},
                {'name': 'Code highlighting API', 'url': reverse('pygments-root', request=request)},
                {'name': 'Blog posts API', 'url': reverse('blog-posts-root', request=request)},
                {'name': 'Permissions example', 'url': reverse('permissions-example', request=request)}
                ]
github encode / django-rest-framework / examples / blogpost / resources.py View on Github external
def url(self, instance):
        return reverse('blog-post',
                        kwargs={'key': instance.key},
                        request=self.request)
github encode / django-rest-framework / examples / sandbox / views.py View on Github external
def get(self, request):
        return [{'name': 'Simple Resource example', 'url': reverse('example-resource', request=request)},
                {'name': 'Simple ModelResource example', 'url': reverse('model-resource-root', request=request)},
                {'name': 'Simple Mixin-only example', 'url': reverse('mixin-view', request=request)},
                {'name': 'Object store API', 'url': reverse('object-store-root', request=request)},
                {'name': 'Code highlighting API', 'url': reverse('pygments-root', request=request)},
                {'name': 'Blog posts API', 'url': reverse('blog-posts-root', request=request)},
                {'name': 'Permissions example', 'url': reverse('permissions-example', request=request)}
                ]
github encode / django-rest-framework / examples / sandbox / views.py View on Github external
def get(self, request):
        return [{'name': 'Simple Resource example', 'url': reverse('example-resource', request=request)},
                {'name': 'Simple ModelResource example', 'url': reverse('model-resource-root', request=request)},
                {'name': 'Simple Mixin-only example', 'url': reverse('mixin-view', request=request)},
                {'name': 'Object store API', 'url': reverse('object-store-root', request=request)},
                {'name': 'Code highlighting API', 'url': reverse('pygments-root', request=request)},
                {'name': 'Blog posts API', 'url': reverse('blog-posts-root', request=request)},
                {'name': 'Permissions example', 'url': reverse('permissions-example', request=request)}
                ]
github encode / django-rest-framework / examples / sandbox / views.py View on Github external
def get(self, request):
        return [{'name': 'Simple Resource example', 'url': reverse('example-resource', request=request)},
                {'name': 'Simple ModelResource example', 'url': reverse('model-resource-root', request=request)},
                {'name': 'Simple Mixin-only example', 'url': reverse('mixin-view', request=request)},
                {'name': 'Object store API', 'url': reverse('object-store-root', request=request)},
                {'name': 'Code highlighting API', 'url': reverse('pygments-root', request=request)},
                {'name': 'Blog posts API', 'url': reverse('blog-posts-root', request=request)},
                {'name': 'Permissions example', 'url': reverse('permissions-example', request=request)}
                ]
github encode / django-rest-framework / examples / objectstore / views.py View on Github external
def get_file_url(key, request):
    """
    Given a stored object's key returns the URL for the object.
    """
    return reverse('stored-object', kwargs={'key': key}, request=request)
github encode / django-rest-framework / examples / permissionsexample / views.py View on Github external
def get(self, request):
        return [
            {
                'name': 'Throttling Example',
                'url': reverse('throttled-resource', request=request)
            },
            {
                'name': 'Logged in example',
                'url': reverse('loggedin-resource', request=request)
            },
github encode / django-rest-framework / examples / resourceexample / views.py View on Github external
def get(self, request):
        """
        Handle GET requests, returning a list of URLs pointing to 3 other views.
        """
        resource_urls = [reverse('another-example',
                                 kwargs={'num': num},
                                 request=request)
                         for num in range(3)]
        return {"Some other resources": resource_urls}