Code

Opened 5 years ago

Closed 5 years ago

#11062 closed (wontfix)

Problem with django/forms/models.py

Reported by: beaver Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hi!
When I describe my own model field I can return value of any kind. In my own widget I can process that value
But if I want to describe a field inherits from ManyToManyField I can't do this because of that code (forms.models.py):

        if isinstance(f, ManyToManyField):
            if instance.pk is None:
                data[f.name] = []
            else:
                data[f.name] = [obj.pk for obj in f.value_from_object(instance)]
        else:
	    data[f.name] = f.value_from_object(instance)

When I trying pass my own value (not sequence of models) this code prevents this.
I offer to change method value_from_object for ManyToManyField, that it returns not list of models but list of identifiers.
And above-cited code changes to

        data[f.name] = f.value_from_object(instance)

But I think it damages other parts of Django.

Please solve this problem and send me an email.
Sorry for my bad English.
Kirill

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

You probably shouldn't be using ManyToManyField as your base class then.

If you want to discuss this more, feel free to bring this up in the google dev group. It could even get the ticket re-opened if you have a good case.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.