How to format Django views' docstring

8.8k views Asked by At

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 ?

1

There are 1 answers

0
Albert Tugushev On BEST ANSWER