How to create anchor on django admin page to scroll down to an inline or field automatically from a url

931 views Asked by At

I have a fairly big model and on the admin page for that model I have a few inlines that show up at the bottom. I want to be able to link to the admin page for a model instance, and automatically scroll down to an inline so something like /admin/myapp/modelname/pk/#inlinename

I'm not even remotely sure where to start? If anyone can even point me in the right direction that would be great.

Thanks!

1

There are 1 answers

2
Chris Pratt On BEST ANSWER

Every inline has an id in the form of [related_name]-group. If you didn't specify a related_name on the relationship then the default related name would be in the form of [lowercase model name]_set.

So, let's say you had a relationship to model, Foo, with no related_name specified. The inline's id would be #foo_set-group, which you can link to as anchor.