4

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!

gt565k
  • 7,755
  • 3
  • 16
  • 9

1 Answers1

3

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.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • it seems to work for one of my inlines, but it's because that model is a many2many field on the parent model, whereas the other 2 inlines are separate models that are not referenced in that parent model, but have a foreign key to it. – gt565k Aug 21 '12 at 22:19
  • blah so on the m2m field, it doesn't work with the related name, but it works with #modelname_set-group and on the other inlines whose models reference the parent model with a fkey, it works if i set a related name, but doesnt work otherwise... weird thanks for the help I got it working but like I pointed above it's kind of weird – gt565k Aug 21 '12 at 22:27