Opened 16 years ago

Last modified 3 years ago

#9107 new New feature

URL arguments to set values of fields in admin don't work for inlines

Reported by: josh@… Owned by:
Component: contrib.admin Version: dev
Severity: Normal Keywords: admin inline
Cc: Carlton Gibson Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Though it works just fine to set the value of a field in the admin with URL arguments (i.e. adding '?title=foo' to your URL sets the value of the field 'title' to 'foo'), this doesn't work if the field you're trying to set is in an inline. In such a case the syntax would presumably be something along the lines of '?inlinemode_set-0-fieldname' if you were trying to set the value fo the first instance of the inline model. This, however, doesn't work nor does any other variation I was able to think of.

Change History (11)

comment:1 by Jacob, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Luke Plant, 13 years ago

Severity: Normal
Type: New feature

comment:3 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:4 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:5 by TapanGujjar, 4 years ago

Owner: changed from nobody to TapanGujjar
Status: newassigned

comment:6 by TapanGujjar, 4 years ago

For this feature, the correct query parameter for inline models according to me should look something as inlinemode_set-[inline model index]-[index of the inline model form in the inline formset]-[fieldname]. Also, should the inline parameters override the extra parameter in the custom inline Model as if we have more inline query parameters means for the inline model we will have to show more inline form just to show those more query parameters?

for e.g.

class choiceInline(admin.TabularInline):
    model=Choice
    extra=2
    # exclude=['votes']

class QuestionAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,               {'fields': ['question_text']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]    
    inlines=[choiceInline]

query parameter can be like
inlinemode_set-0-0-choiceModelField where the first 0 points to the first element in the inlines array (choiceInline) and the second 0 is the first form in inline formset.

The issue here is that if the query parameter is inlinemode_set-0-3-choiceModelField , this points to the 4th form in the choiceinline formset, this will need to override the extra parameter.

Should we override the extra parameter through the query parameter?
Any ideas for this.

Last edited 4 years ago by TapanGujjar (previous) (diff)

comment:7 by Carlton Gibson, 4 years ago

Cc: Carlton Gibson added

Any ideas for this.

Easier to see in code, I think.

After 12 years, you're free to implement your idea. (It sounds generally reasonable.)

If you can open a PR with the easier cases handled and then perhaps failing test cases for the more difficult examples it will be easier to comment sensibly.
Does that seems an OK plan?

comment:8 by TapanGujjar, 4 years ago

Hi Carlton please check the pull request for this. I have created two tests to demonstrate my solutions. One of the test will fail.

https://github.com/django/django/pull/12882

comment:9 by Carlton Gibson, 4 years ago

Has patch: set
Patch needs improvement: set

comment:10 by Carlton Gibson, 4 years ago

Needs documentation: set
Needs tests: set

comment:11 by TapanGujjar, 3 years ago

Owner: TapanGujjar removed
Status: assignednew
Note: See TracTickets for help on using tickets.
Back to Top