Opened 18 years ago
Closed 18 years ago
#6328 closed (invalid)
ModelForm doc mistake?
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Documentation | Version: | dev |
| Severity: | Keywords: | newforms | |
| Cc: | alx.gsv@…, thejaswi.puthraya@… | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I read that i can create form to add an article with no parameters:
# Create the form class. >>> class ArticleForm(ModelForm): ... class Meta: ... model = Article # Creating a form to add an article. >>> form = ArticleForm()
But, newforms/models.py
class BaseModelForm(BaseForm):
def __init__(self, instance, data=None, files=None, auto_id='id_%s', prefix=None,
initial=None, error_class=ErrorList, label_suffix=':'):
...
requires 1 argument — instance. So i got an error:
File "/home/longman/workspace/youssr/youssr/../youssr/posting/views.py" in post_edit 66. form = EntryForm() Exception Type: TypeError at /posts/write/ Exception Value: __init__() takes at least 2 arguments (1 given)
Change History (1)
comment:1 by , 18 years ago
| Cc: | added |
|---|---|
| Keywords: | newforms added |
| Resolution: | → invalid |
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Replying to LongMan <alx.gsv@gmail.com>:
[snipped]
I guess you are using an older version of svn pre r6915. The signature of the BaseModelForm's init was changed post r6915.
Here is the new signature.
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', instance=None):Your ticket is invalid. There are no mistakes in the documentation and it works without even providing for an instance.