Search code examples
djangodjango-grappelli

Django Grappelli Rearrange Inlines id override


According to the docs:

http://django-grappelli.readthedocs.org/en/latest/customization.html#rearrange-inlines

The two classes for the placeholder are important. First, you need a class placeholder. The second class has to match the id of the inline–group.

All's well and good, I was able to set up my inlines fine, my issue is now - where does grappelli get the "id of the inline group" I can't find any reference, and pouring through the source code is offering me no solace.

Simply, I want to change the element-id that grappelli is using. Currently, it looks to me that it is taking the object name itself and converting to a lowercase name and appending set to the end. Do we have access to override the "id of the inline-group"?

Also, I am not 100% sure exactly how (or where) grappelli is doing this, it is definitely not documented... at all in fact.

Any help would be much appreciated.


Solution

  • It is the id of the inline element on HTML page. You can check the id of the default HTML inline element.

     <div id="[related_name of ForeignKey]-group">
    

    For example: If in model "MyModel2", you have a ForeignKey like this:

    my_model_1 = models.ForeignKey(MyModel1, related_name='my_model_2')
    

    Then the id should be "my_model_2-group".