Skip to content

Commit aed181d

Browse files
committed
edits
1 parent dbd3de7 commit aed181d

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ repos:
4444
hooks:
4545
- id: rstcheck
4646
additional_dependencies: [sphinx]
47-
args: ["--ignore-directives=fieldlookup", "--ignore-roles=djadmin,lookup,setting"]
47+
args: ["--ignore-directives=django-admin,fieldlookup,setting", "--ignore-roles=djadmin,lookup,setting"]
4848

4949
# We use the Python version instead of the original version which seems to require Docker
5050
# https://github.com/koalaman/shellcheck-precommit

django_mongodb_backend/fields/embedded_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def formfield(self, **kwargs):
135135
**{
136136
"form_class": forms.EmbeddedModelField,
137137
"model": self.embedded_model,
138-
"name": self.name,
138+
"prefix": self.name,
139139
**kwargs,
140140
}
141141
)

django_mongodb_backend/forms/fields/embedded_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class EmbeddedModelField(forms.MultiValueField):
3232
"incomplete": _("Enter all required values."),
3333
}
3434

35-
def __init__(self, model, name, *args, **kwargs):
35+
def __init__(self, model, prefix, *args, **kwargs):
3636
form_kwargs = {}
3737
# The field must be prefixed with the name of the field.
38-
form_kwargs["prefix"] = name
38+
form_kwargs["prefix"] = prefix
3939
self.form_kwargs = form_kwargs
4040
self.model_form_cls = modelform_factory(model, fields="__all__")
4141
self.model_form = self.model_form_cls(**form_kwargs)

docs/source/fields.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
3636
:class:`~django.db.models.OneToOneField` and
3737
:class:`~django.db.models.ManyToManyField`) and file fields (
3838
:class:`~django.db.models.FileField` and
39-
:class:`~django.db.models.ImageField`).
39+
:class:`~django.db.models.ImageField`). :class:`EmbeddedModelField` is
40+
also not (yet) supported.
4041

4142
It is possible to nest array fields - you can specify an instance of
4243
``ArrayField`` as the ``base_field``. For example::

docs/source/forms.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ Forms API reference
55

66
Some MongoDB-specific fields are available in ``django_mongodb_backend.forms``.
77

8+
``EmbeddedModelField``
9+
----------------------
10+
11+
.. class:: EmbeddedModelField(model, prefix, **kwargs)
12+
13+
A field which maps to a model. The field will render as a
14+
:class:`~django.forms.ModelForm`.
15+
16+
.. attribute:: model
17+
18+
This is a required argument that specifies the model class.
19+
20+
.. attribute:: prefix
21+
22+
This is a required argument that specifies the prefix that all fields
23+
in this field's subform will have so that the names don't collide with
24+
fields in the main form.
25+
826
``ObjectIdField``
927
-----------------
1028

0 commit comments

Comments
 (0)