Skip to content

Commit 3e91ce2

Browse files
committed
Fix example and documentation
1 parent 1129e8d commit 3e91ce2

File tree

14 files changed

+46
-156
lines changed

14 files changed

+46
-156
lines changed
File renamed without changes.

docs/source/_static/.gitkeep

Whitespace-only changes.

docs/source/ref/fields.rst

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,7 @@
22
Fields
33
======
44

5-
.. py:module:: osm_field.fields
6-
7-
8-
OSMField
9-
========
10-
11-
.. autoclass:: OSMField
12-
:members:
13-
14-
15-
LatitudeField
16-
=============
17-
18-
.. autoclass:: LatitudeField
5+
.. automodule:: osm_field.fields
196
:members:
20-
21-
22-
LongitudeField
23-
==============
24-
25-
.. autoclass:: LongitudeField
26-
:members:
27-
28-
29-
Utilities
30-
=========
31-
32-
Location
33-
--------
34-
35-
.. autoclass:: Location
36-
:members: __str__
7+
:undoc-members:
8+
:show-inheritance:

docs/source/ref/forms.rst

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,7 @@
22
Forms
33
=====
44

5-
.. py:module:: osm_field.forms
6-
7-
OSMBoundField
8-
=============
9-
10-
.. autoclass:: OSMBoundField
11-
:members:
12-
:show-inheritance:
13-
14-
15-
OSMFormField
16-
============
17-
18-
.. autoclass:: OSMFormField
19-
:members:
20-
:show-inheritance:
5+
.. automodule:: osm_field.forms
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

docs/source/ref/validators.rst

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
Validators
33
==========
44

5-
.. py:module:: osm_field.fields
6-
7-
validate_latitude
8-
=================
9-
10-
.. autofunction:: validate_latitude
11-
12-
13-
validate_longitude
14-
==================
15-
.. autofunction:: validate_longitude
5+
.. automodule:: osm_field.validators
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

docs/source/ref/widgets.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
Widgets
33
=======
44

5-
.. py:module:: osm_field.widgets
6-
7-
OSMWidget
8-
=========
9-
10-
.. autoclass:: OSMWidget
11-
:members:
12-
:show-inheritance:
5+
.. automodule:: osm_field.widgets
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

docs/source/usage.rst

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You need to add three model fields to your model:
1212
1. :class:`~fields.OSMField`
1313
2. :class:`~fields.LatitudeField`
1414
3. :class:`~fields.LongitudeField`
15-
15+
1616
**django-osm-field** expects them to have a certain name schema: The
1717
:class:`~fields.OSMField` defines the base name, the
1818
:class:`~fields.LatitudeField` and :class:`~fields.LongitudeField` have the
@@ -60,55 +60,6 @@ Form Layer
6060
model = MyModel
6161
6262
63-
Formset Layer
64-
=============
65-
66-
To use OSMField with formsets with Django < 1.9, you must mixin the
67-
:class:`~forms.OSMFormMixin` to your child form class:
68-
69-
``models.py``:
70-
71-
.. code-block:: python
72-
73-
from django.db import models
74-
75-
from osm_field.fields import LatitudeField, LongitudeField, OSMField
76-
77-
78-
class ParentModel(models.Model):
79-
name = models.CharField(max_length=31)
80-
81-
82-
class ChildModel(models.Model):
83-
parent = models.ForeignKey(ParentModel, related_name='children')
84-
location = OSMField()
85-
location_lat = LatitudeField()
86-
location_lon = LongitudeField()
87-
88-
``forms.py``:
89-
90-
.. code-block:: python
91-
92-
from django import forms
93-
94-
from osm_field.forms import OSMFormMixin
95-
96-
from .models import ChildModel, ParentModel
97-
98-
99-
class ChildModelInlineForm(OSMFormMixin, forms.ModelForm):
100-
class Meta:
101-
fields = ('location', 'location_lat', 'location_lon', )
102-
model = ChildModel
103-
104-
ChildModelFormset = forms.models.inlineformset_factory(
105-
ParentModel, ChildModel, form=ChildModelInlineForm
106-
)
107-
108-
Note that you ONLY need to do this for Django < 1.9, but this will still work
109-
without modification (but is unnecessary) for Django >= 1.9.
110-
111-
11263
View Layer
11364
==========
11465

@@ -130,7 +81,7 @@ View Layer
13081
Template Layer
13182
==============
13283

133-
**django-osm-field** shipps with a minimized `jQuery`_ version. To access it in a template use the ``static`` templatetag from the ``staticfiles`` Django app:
84+
**django-osm-field** shipps with a minimized `jQuery`_ version. To access it in a template use the ``static`` templatetag:
13485

13586
.. code-block:: django
13687
@@ -156,7 +107,7 @@ In the end your template should look similar to this:
156107

157108
.. code-block:: django
158109
159-
{% load static from staticfiles %}<!DOCTYPE HTML>
110+
{% load static %}<!DOCTYPE HTML>
160111
<html>
161112
<head>
162113
<title></title>
@@ -174,6 +125,6 @@ In the end your template should look similar to this:
174125
<input type="submit" value="Save" />
175126
</form>
176127
</body>
177-
</html>
128+
</html>
178129
179130
.. _jQuery: http://jquery.com/download/

example/example/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from django.core.urlresolvers import reverse
21
from django.db import models
2+
from django.urls import reverse
33

44
from osm_field.fields import LatitudeField, LongitudeField, OSMField
55

example/example/settings.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,14 @@
3030
# Application definition
3131

3232
INSTALLED_APPS = (
33-
'django.contrib.admin',
34-
'django.contrib.auth',
35-
'django.contrib.contenttypes',
36-
'django.contrib.sessions',
37-
'django.contrib.messages',
3833
'django.contrib.staticfiles',
3934
'osm_field',
4035
'example',
4136
)
4237

4338
MIDDLEWARE_CLASSES = (
44-
'django.contrib.sessions.middleware.SessionMiddleware',
4539
'django.middleware.common.CommonMiddleware',
4640
'django.middleware.csrf.CsrfViewMiddleware',
47-
'django.contrib.auth.middleware.AuthenticationMiddleware',
48-
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
49-
'django.contrib.messages.middleware.MessageMiddleware',
5041
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5142
)
5243

@@ -83,3 +74,16 @@
8374
# https://docs.djangoproject.com/en/dev/howto/static-files/
8475

8576
STATIC_URL = '/static/'
77+
78+
TEMPLATES = [
79+
{
80+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
81+
'APP_DIRS': True,
82+
'OPTIONS': {
83+
'context_processors': [
84+
'django.template.context_processors.debug',
85+
'django.template.context_processors.request',
86+
],
87+
},
88+
},
89+
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load static from staticfiles %}<!DOCTYPE HTML>
1+
{% load static %}<!DOCTYPE HTML>
22
<html>
33
<head>
44
<title></title>
@@ -8,4 +8,4 @@
88
<body>
99
{% block content %}{% endblock %}
1010
</body>
11-
</html>
11+
</html>

0 commit comments

Comments
 (0)