Closed mbourqui closed 6 years ago
Hey @mbourqui, I'm going to merge this but there are a couple of things I'll fix afterwards:
split()
call with maxsplit=1
argument is not working in py2, better call it without the parameter namecruds_adminlte/utils.py
And as I've seen it's working only in the list template, not in the edit either the detail. Do you think it's possible to extend it to the other templates? Thanks in advance and thank you so much for your work.
Hey @oscarmlage, Thanks for merging my PR! Sorry for the compatibility and pep8 issues. I'm currently on a short deadline and did not had the time to fully check outside my use case. You are correct, it works for lists. I have yet only the use in list views, but give me three weeks and I'll make it work for other views too.
Sure @mbourqui, don't worry at all!! we are not in a hurry or something similar :). The pep8
problems are already fixed. Please tell me if I can help you in anything. Thanks for your time and for contributing to this project too!.
There's a side effect of this now, if you have columns with the same name on two objects you can't display the real objects name.
For example:
class Author(models.Model):
name = models.CharField(max_length=100)
class Book(models.Model):
author = models.ForeignKey(Author)
name = models.CharField(max_length=100)
class BookCRUD(CRUDView):
model = Book
fields = ['name', 'author']
list_fields = ['name', 'author__name']
You get as a result list:
Name | Name Book Name | Author Name
Before this implementation you would get:
Name | Author Book Name | Author object (1)
When what would be preferred was: Name | Author Book Name | Author Name
The workaround for now is to rename column Author.name to Author.author.
It would be nice if we could display Name as Author without renaming columns in the database.
Hi,
This PR adds the possiblity to have fields from related models in CRUD views. For example, you can then have
where for example
where the
__
(double underscore) allows you to look for a fieldrelated_model_field
from a related model viamy_related_field
.