I have a class:
class Holiday(ActivitiesBaseClass):
"""Holiday is an activity that involves taking time off work"""
Hotel = models.CharField(max_length=255)
""" Name of hotel """
I can print the class docstring by typing:
print(Holiday.__doc__)
This outputs as:
Holiday is an activity that involves taking time off work
How can I print the docstring for Hotel which is a Class attribute/element?
print(Holiday.Hotel.__doc__)
returns:
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
I've also tried the help()
function to no avail.
Sphinx seems to be able to extract the docstrings of class attributes and include them in readthedocs so I’m hoping there’s a way
Don't think it's possible to add docstring for specific field, but you can use field's help_text
argument instead:
Hotel = models.CharField(max_length=255, help_text="Name of hotel")