Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format Django views' docstring

I use simple views in my project, and now my project begin to be bigger, I'm writing a sphinx doc and use objects docstrings with sphinx.ext.autodoc for inclusion.

My trouble is: How to greatly format view's docstring ?

  • Document GET/POST and more behavior.
  • Template(s) used
  • Context content

For example, I'm using:

def my_view(request):
    """
    Do something depending of HTTP method.

    In GET: Returns a page
    IN POST: Make something and redirect

    GET parameters:
    GET['next'] : URL to redirect to after submit form

    POST parameters:
    POST['action'] : Action
    """

I'm self-asking if there is a better way to do this ? Is there any consensus about it ?

like image 497
Zulu Avatar asked Nov 28 '14 11:11

Zulu


1 Answers

A few examples you can find here: https://docs.djangoproject.com/en/1.8/ref/contrib/admin/admindocs/

like image 141
Albert Tugushev Avatar answered Sep 28 '22 00:09

Albert Tugushev