daniyalzade / django_reverse_admin

Django Reverse Admin
BSD 3-Clause "New" or "Revised" License
198 stars 54 forks source link

How to respect both the 'fields' and the 'admin_class' attributes? #305

Open intrepidclass opened 1 month ago

intrepidclass commented 1 month ago

Hello,

If I write:

    inline_type = 'tabular'
    person_field_list = ('id', 'first_name', 'inix', 'last_name',
                                                 'birthday', 'zip_code', 'street', 'house_number', 'house_suffix',
                                                 'place', 'email', 'email_2', 'phone_number', 'phone_number_2')
    inline_reverse = [{'field_name': 'old_person',
                                        'fields': person_field_list,
                                      'admin_class': PersonInline},
                      ('new_person', {'fields': person_field_list,
                                      'admin_class': PersonInline})
                      ]

Then for old_person it ignores the field list and shows all the fields. But for new_person it does show the correct fields but it ignores the admin_class (i think) because it is still showing the delete checkbox.

Am I missing something?

Context:

class PotentialPersonDuplicate(models.Model):
    old_person = models.ForeignKey(Person, related_name='possible_newer_duplicates', on_delete=models.CASCADE)
    new_person = models.ForeignKey(Person, related_name='possible_older_duplicates', on_delete=models.CASCADE)

class PersonInline(admin.TabularInline):
    model = Person

    def has_delete_permission(self, request, obj=None):
        return False
intrepidclass commented 1 month ago

I'm working with Django 4.2.3