Drop support for Django <1.8, Python <2.7
This commit is contained in:
@@ -2,22 +2,16 @@
|
||||
Automatically mention all model fields as parameters in the model construction.
|
||||
Based on http://djangosnippets.org/snippets/2533/
|
||||
"""
|
||||
import django
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.encoding import force_text
|
||||
import inspect
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.html import strip_tags
|
||||
|
||||
|
||||
def improve_model_docstring(app, what, name, obj, options, lines):
|
||||
from django.db import models # must be inside the function, to allow settings initialization first.
|
||||
|
||||
if inspect.isclass(obj) and issubclass(obj, models.Model):
|
||||
if django.VERSION >= (1,8):
|
||||
model_fields = obj._meta.get_fields()
|
||||
elif django.VERSION >= (1,6):
|
||||
model_fields = obj._meta.fields
|
||||
else:
|
||||
model_fields = obj._meta._fields()
|
||||
model_fields = obj._meta.get_fields()
|
||||
|
||||
for field in model_fields:
|
||||
help_text = strip_tags(force_text(field.help_text))
|
||||
@@ -39,9 +33,9 @@ def improve_model_docstring(app, what, name, obj, options, lines):
|
||||
# Return the extended docstring
|
||||
return lines
|
||||
|
||||
|
||||
# Allow this module to be used as sphinx extension:
|
||||
def setup(app):
|
||||
# Generate docstrings for Django model fields
|
||||
# Register the docstring processor with sphinx
|
||||
app.connect('autodoc-process-docstring', improve_model_docstring)
|
||||
|
||||
|
||||
+1
-2
@@ -23,8 +23,7 @@ sys.path.insert(0, os.path.abspath('_ext'))
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'djangodummy.settings'
|
||||
|
||||
if django.VERSION >= (1, 8):
|
||||
django.setup()
|
||||
django.setup()
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ Django as automatic manager for several purposes, including accessing
|
||||
related objects. It must not filter objects and it's safest to use
|
||||
the plain ``PolymorphicManager`` here.
|
||||
|
||||
Note that get_query_set is deprecated in Django 1.8 and creates warnings in Django 1.7.
|
||||
|
||||
Manager Inheritance
|
||||
-------------------
|
||||
|
||||
@@ -69,8 +67,6 @@ regarding their start time and ``ArtProject.objects_ordered.most_recent()``
|
||||
will return the ten most recent art projects.
|
||||
.
|
||||
|
||||
Note that get_query_set is deprecated in Django 1.8 and creates warnings in Django 1.7.
|
||||
|
||||
Using a Custom Queryset Class
|
||||
-----------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user