@@ -610,35 +610,45 @@ def querystring_params(
610610@register .simple_tag (takes_context = True )
611611def header_title (context : RequestContext ) -> str :
612612 parts = []
613+ opts = context .get ("opts" )
613614
614- if opts := context . get ( "opts" ) :
615+ if opts :
615616 parts .append (
616617 {
617618 "link" : reverse_lazy ("admin:app_list" , args = [opts .app_label ]),
618619 "title" : opts .app_config .verbose_name ,
619620 }
620621 )
621622
622- parts .append (
623- {
624- "link" : reverse_lazy (
625- f"admin:{ opts .app_label } _{ opts .model_name } _changelist"
626- ),
627- "title" : opts .verbose_name_plural ,
628- }
629- )
630-
631623 if (original := context .get ("original" )) and not isinstance (original , str ):
632624 parts .append (
633625 {
634626 "link" : reverse_lazy (
635- f"admin:{ opts .app_label } _{ opts .model_name } _change" ,
627+ f"admin:{ original ._meta .app_label } _{ original ._meta .model_name } _changelist"
628+ ),
629+ "title" : original ._meta .verbose_name_plural ,
630+ }
631+ )
632+
633+ parts .append (
634+ {
635+ "link" : reverse_lazy (
636+ f"admin:{ original ._meta .app_label } _{ original ._meta .model_name } _change" ,
636637 args = [original .pk ],
637638 ),
638639 "title" : original ,
639640 }
640641 )
641642 elif object := context .get ("object" ):
643+ parts .append (
644+ {
645+ "link" : reverse_lazy (
646+ f"admin:{ object ._meta .app_label } _{ object ._meta .model_name } _changelist"
647+ ),
648+ "title" : object ._meta .verbose_name_plural ,
649+ }
650+ )
651+
642652 parts .append (
643653 {
644654 "link" : reverse_lazy (
@@ -648,6 +658,15 @@ def header_title(context: RequestContext) -> str:
648658 "title" : object ,
649659 }
650660 )
661+ else :
662+ parts .append (
663+ {
664+ "link" : reverse_lazy (
665+ f"admin:{ opts .app_label } _{ opts .model_name } _changelist"
666+ ),
667+ "title" : opts .verbose_name_plural ,
668+ }
669+ )
651670 elif object := context .get ("object" ):
652671 parts .append (
653672 {
@@ -689,7 +708,7 @@ def header_title(context: RequestContext) -> str:
689708 "link" : reverse_lazy (
690709 f"admin:{ model_admin .model ._meta .app_label } _{ model_admin .model ._meta .model_name } _changelist" ,
691710 ),
692- "title" : model_admin .model ._meta .verbose_name ,
711+ "title" : model_admin .model ._meta .verbose_name_plural ,
693712 }
694713 )
695714
@@ -704,7 +723,7 @@ def header_title(context: RequestContext) -> str:
704723 username = (
705724 context .request .user .get_short_name () or context .request .user .get_username ()
706725 )
707- parts .append ({"title" : f"{ _ ('Welcome' )} <strong> { username } </strong> " })
726+ parts .append ({"title" : f"{ _ ('Welcome' )} { username } " })
708727
709728 return render_to_string (
710729 "unfold/helpers/header_title.html" ,
0 commit comments