Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 901
gt565k Avatar asked Oct 27 '25 07:10

gt565k


1 Answers

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.

like image 52
Chris Pratt Avatar answered Oct 28 '25 21:10

Chris Pratt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!