Re: Ticket #34646 Ordering a Django admin column based on multiple model fields

2023-06-18 Thread Mark Niehues
I also lately stumbled across this and was a little surprised that it could not 
handle multiple fields, as it is the case in other places.

So +1 for fixing this from me :)

Am 19. Juni 2023 03:05:41 MESZ schrieb David Sanders 
:
>Mariusz is a developer, so that's at least 1 developer's opinion :)
>
>Unless anybody else pipes up to counter this I'd consider it to be a nice 
>solution.
>
>On Monday, 19 June 2023 at 05:01:52 UTC+10 Mubarak Alrashidi wrote:
>
>> Can we at least know what the developers think about it?
>>
>>
>> On Sunday, June 11, 2023 at 1:28:58 AM UTC+3 Mubarak Alrashidi wrote:
>>
>>> Hello,
>>>
>>> I posted this StackOverflow question 
>>> , and @Willem Van Onsem 
>>>  
>>> tried 
>>> to help by opening a ticket numbered #34646 
>>> , and creating a patch for 
>>> supporting the order by multiple fields in admin.display decorator.
>>>
>>> But it got closed as a duplicate of #31975 
>>>  which was reported about 3 
>>> years ago, and it got closed as wontfix by @Mariusz Felisiak 
>>>  because he said: *"We don't want to add 
>>> unnecessary complexity to the API.".*
>>>
>>> And I agree with what @Petr Dlouhý 
>>> 
>>>  says: *"it is small modification of Django code and small increase in 
>>> API complexity (which is consistent with the logic of other order fields, 
>>> BTW)."**.*
>>>
>>> The inconsistency is when somewhere we're able to order by multiple 
>>> fields, and somewhere else we can't.
>>>
>>> If we can order by multiple fields in the modelAdmin classes, why can't 
>>> we do so in the admin.display decorator?
>>>
>>> So, I do hope to reconsider implementing the patch 
>>> 
>>>  that @Willem Van Onsem 
>>> 
>>>  created.
>>>
>>> Thanks
>>>
>>
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django developers  (Contributions to Django itself)" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-developers+unsubscr...@googlegroups.com.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-developers/02535619-27e9-40ec-835b-1ea1c5a08315n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5D677F69-2F6F-480C-8657-F1851B175E4A%40posteo.de.


Re: Model icons

2023-02-19 Thread Mark Niehues
If we are talking only about icons in Django Admin: Wagtail (a CMS based 
on Django) solves it for their custom Admin Views in a similar way to 
your proposed Meta attribute [0].


The analog solution for django admin would be, that the ModelAdmin gets 
an 'icon' attribute, which does not contain the whole html-snippet, but 
instead only the icon specific class name:


For Example:

from django.contrib import admin
from .models import Author

@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
   icon = 'fa-user'

That would be a nicer solution in my point of view, especially I find 
this level of coupling acceptable.


Cheers,

Mark

[0] 
https://docs.wagtail.org/en/stable/reference/contrib/modeladmin/index.html#a-more-complicated-example



Am 18.02.23 um 21:31 schrieb Marty:

Yeah, I've tried to create templatetag like this:

@register.simple_tag
def get_module_icon(model, app):
    if app == 'auth':
        if model == 'Groups':
            return ''
        elif model == 'Users':
            return ''
    elif app == 'core':
        elif model == 'Generations':
            return ''
        elif model == 'Product models':
            return ''
    elif app == 'bto':
        if model == 'Components':
            return ''
        elif model == 'Layouts':
            return ''
        elif model == 'SKU configurations':
            return ''
        elif model == 'XML component definitions':
            return ''
    return ''

I don't like this way so much and I thought it would be easier even 
for other potentional developers who would like to use icons so it 
seemed putting it to Meta would be better. However I get mixing HTML 
to model is not good. 

What would be the most clean way to use icons like that?

On Saturday, February 18, 2023 at 8:23:28 PM UTC+1 Arthur Pemberton wrote:

I too find the idea of hard coded HTML in a Python file to be
inelegant, for what it's worth.

Arthur Pemberton

On Sat, 18 Feb 2023 at 08:12, 'Adam Johnson' via Django developers
(Contributions to Django itself)  wrote:

Putting HTML for the admin in model definitions is a bit too
coupled.

I think you may be able to add icons already by overriding the
admin template - can you try playing around with that?

On Mon, Feb 6, 2023 at 12:07 AM Yeonggwang Yang
 wrote:

that sounds good with me

2023년 2월 5일 일요일 오전 9시 36분 17초 UTC+9에 Marty님이
작성:

Hi all,

Recently, it's trend to use icons or emoji before menu
items and I like this idea because IMHO people orient
better and more quickly when they see picture.

What about to add this feature to native django? I
thought the easiest way would be to add new Meta
option to Model. The default Meta icon would be empty
string so everything would work like now. If I want to
make menu more readable, I just add emoji () or html
(Awesome font - ** ,
Bootstrap icon - **, etc.)
to Meta icon.

Code example:

_Model:_
class Hammer(models.Model):
    ...

    Meta:
        icon = ''

_app_list.html template:_
...
{{model.icon}} {{model.name
}}
...

Final result:
admin navbar.png

Maybe own icon could have even the parent app
(AppConfig). And the model icon could be in breadcrumbs.

What do you think about this idea? 

-- 
You received this message because you are subscribed to

the Google Groups "Django developers (Contributions to
Django itself)" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-developers/6c859cc5-ea41-4695-9fcf-5cd435310364n%40googlegroups.com

.

-- 
You received this message because you are subscribed to the

Google Groups "Django developers (Contributions to Django
itself)" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to django-develop...@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/django-developers/CAMyDDM1L4rmQ3qomxOqD%2BmugXcsmx7NrOPAh8a53wR9G5q%3D3Gw%40mail.gmail.com