#17436: flag attempts to change signature of __init__ on Models
----------------------------------------------+--------------------
Reporter: straz | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: 1.3
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------------------+--------------------
As a relative Django newbie, I tried to redefine the __init__ method on my
Model classes to take additional parameters.
This failed silently - the objects were created but Model.save() did not
persist the objects to the database.
I didn't see anything in the Models documentation or FAQ about this,
either.
After some searching I found the answer here, namely, "don't do that":
http://stackoverflow.com/questions/843580/writing-a-init-function-to-be-
used-in-django-model
Feature request: add a warning which is thrown whenever you subclass
django.db.models.Model
with a nonstandard __init__ method. The wording could be something like:
"Changing the calling signature
of __init__ on subclasses of Model may prevent objects from being saved
correctly. Try using a
classmethod factory pattern to create objects instead."
Doc request: add this to the Models documentation
--
Ticket URL: <https://code.djangoproject.com/ticket/17436>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.