original_docstring: Render returned context in an item view.
docstring: Render returned context in an item view.
docstring_tokens: Render returned context in an item view .
code: def render_with_item_view(
      func: Callable[..., ItemContext],
  ) -> Callable[..., TemplateResponse]:
      """Render returned context in an item view."""
  
      @wraps(func)
      def wrapper(*args: Any, **kwargs: Any) -> TemplateResponse:
          request: HttpRequest = args[0]
          context = func(*args, **kwargs)
          func_name = f"{func.__module__}.{func.__qualname__}"  # noqa
  
          for item in admin_data_settings.URLS:
              # Allow item views separately
              view_name = f"{item['view'].__module__}.{item['view'].__qualname__}"
              if view_name == func_name:
                  if context.get("slug") is None:
                      context["slug"] = item["route"]  # type: ignore
                  break
  
              # Item view inside table view definition
              if item["items"] is not None:
                  view_name = f"{item['items']['view'].__module__}.{item['items']['view'].__qualname__}"
                  if view_name == func_name:
                      if context.get("slug") is None:
                          context["slug"] = item["items"]["route"]  # type: ignore
                      context["category_slug"] = item["route"]  # type: ignore
                      context["category_url"] = reverse(  # type: ignore
                          viewname=f"admin:{item['name']}",
                          current_app=admin_site.name,
                      )
                      break
          else:
              raise ValueError(f"Cannot find '{func_name}' in ADMIN_DATA_VIEWS setting.")
  
          context.update(admin_site.each_context(request))
          context["app_label"] = AdminConfig.verbose_name  # type: ignore
          request.current_app = admin_site.name
          return TemplateResponse(request, "admin_data_views/admin_data_item_page.html", context)
  
      return wrapper
code_tokens: def render_with_item_view ( func : Callable [ ... , ItemContext ] , ) -> Callable [ ... , TemplateResponse ] : @ wraps ( func ) def wrapper ( * args : Any , ** kwargs : Any ) -> TemplateResponse : request : HttpRequest = args [ 0 ] context = func ( * args , ** kwargs ) func_name = f"{func.__module__}.{func.__qualname__}" for item in admin_data_settings . URLS : view_name = f"{item['view'].__module__}.{item['view'].__qualname__}" if view_name == func_name : if context . get ( "slug" ) is None : context [ "slug" ] = item [ "route" ] break if item [ "items" ] is not None : view_name = f"{item['items']['view'].__module__}.{item['items']['view'].__qualname__}" if view_name == func_name : if context . get ( "slug" ) is None : context [ "slug" ] = item [ "items" ] [ "route" ] context [ "category_slug" ] = item [ "route" ] context [ "category_url" ] = reverse ( viewname = f"admin:{item['name']}" , current_app = admin_site . name , ) break else : raise ValueError ( f"Cannot find '{func_name}' in ADMIN_DATA_VIEWS setting." ) context . update ( admin_site . each_context ( request ) ) context [ "app_label" ] = AdminConfig . verbose_name request . current_app = admin_site . name return TemplateResponse ( request , "admin_data_views/admin_data_item_page.html" , context ) return wrapper
short_docstring: Render returned context in an item view.
short_docstring_tokens: Render returned context in an item view .
comment: """Render returned context in an item view."""$SEP$# noqa
  $SEP$# Allow item views separately
  $SEP$# type: ignore
  $SEP$# Item view inside table view definition
  $SEP$# type: ignore
  $SEP$# type: ignore
  $SEP$# type: ignore
  $SEP$# type: ignore
  