oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 82 forks source link

Support fields from related models in CRUD views #76

Closed mbourqui closed 6 years ago

mbourqui commented 6 years ago

Hi,

This PR adds the possiblity to have fields from related models in CRUD views. For example, you can then have

from cruds_adminlte.crud import CRUDView

class MyView(CRUDView):
    from .models import MyModel
    model = MyModel
    list_fields =  ['my_related_field__related_model_field',]

where the __ (double underscore) allows you to look for a field related_model_field from a related model via my_related_field.

oscarmlage commented 6 years ago

Sorry for the delay @mbourqui but I want to test it a little more (had almost no time the last days) and even fix some pep8 cosmetics stuff. Thanks for the work.

mbourqui commented 6 years ago

Hi, No worries. Sure, take your time. I tried it with one-to-one fields, it works pretty well. You're welcome, thanks for your app!

mbourqui commented 6 years ago

Sorry, I messed up the PR, Will do some cleaning.