Code

Opened 7 years ago

Closed 7 years ago

#5634 closed (wontfix)

Queryset in newform: form_for_model()

Reported by: MarioGonzalez <gonzalemario @…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: gonzalemario@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hello:

I usually show forms using form_for_model(), however there's something I think is missing. My model is something like:

class TransferFile(models.Model):
        file = models.FileField(upload_to="/some/path/in/my/system/")
        owner = models.ForeignKey(User, db_column="owner", db_index=True)
        authorized_account = models.ManyToManyField(User,
related_name="authorized_account")

        class Admin:
                pass

        class Meta:
                permissions = (
                        ('send_file', 'Can send files'),

In my DB I've got lot of users, each one with different groups and permissions, and I don't want to show them in my form. So, I want to pass a parameter in form_for_model() to change the queryset. I wrote a patch for that, I know it needs improvements but it's for explain my idea.
Please see the talk we're having in http://groups.google.com/group/django-developers/t/1e4714a469a1a814

Attachments (1)

django.newforms.models.py.diff (1.4 KB) - added by MarioGonzalez <gonzalemario @…> 7 years ago.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by MarioGonzalez <gonzalemario @…>

comment:1 Changed 7 years ago by MarioGonzalez <gonzalemario @…>

  • Cc gonzalemario@… added
  • Component changed from Uncategorized to django.newforms
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by brosner

  • Resolution set to wontfix
  • Status changed from new to closed

This can be easily accomplished with just using the formfield_callback. form_for_* helper functions are not meant for special cases, thats why formfield_callback exists.

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.