Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#18528 closed Bug (fixed)

Field.value_to_string documentation broken

Reported by: anuraguniyal Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

See https://docs.djangoproject.com/en/1.4/howto/custom-model-fields/#django.db.models.Field.value_to_string , it gives a sample as

class HandField(models.Field):
    # ...

    def value_to_string(self, obj):
        value = self._get_val_from_obj(obj)
        return self.get_db_prep_value(value)

but it will not work in 1.4 due to TypeError: get_db_prep_value() takes at least 3 arguments (2 given)

Change History (4)

comment:1 Changed 4 years ago by Claude Paroz

Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: Cleanup/optimizationBug

I would use get_prep_value instead of get_db_prep_value. Opinions?

comment:2 Changed 4 years ago by Claude Paroz

No opinion? I will assume mine is correct :-)

comment:3 Changed 4 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In [b9ecbedb31375a887d100ccf550a091c8d5d4fd7]:

Fixed #18528 -- Fixed custom field value_to_string example

Thanks anuraguniyal for the report.

comment:4 Changed 4 years ago by Claude Paroz <claude@…>

In [d92c38a28177f4cad91c1921ca2b621d3af01912]:

[1.4.x] Fixed #18528 -- Fixed custom field value_to_string example

Thanks anuraguniyal for the report.

Note: See TracTickets for help on using tickets.
Back to Top