
from django import template
from django.conf import settings
from admin_tools.utils import get_media_url

register = template.Library()

def render_theming_css():
    """
    Template tag that renders the needed css files for the theming app.
    """
    css = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS', False)
    if css:
        css = '/'.join([get_media_url(), css])
    else:
        css = '/'.join([get_media_url(), 'admin_tools', 'css', 'theming.css'])
    return '<link rel="stylesheet" type="text/css" media="screen" href="%s" />' % css
register.simple_tag(render_theming_css)


from django import template
from django.conf import settings
from admin_tools.utils import get_media_url

register = template.Library()

def render_theming_css():
    """
    Template tag that renders the needed css files for the theming app.

    If ADMIN_TOOLS_THEMING_CSS is explicitely defined to None, don't render
    anything.
    """
    rval = ''
    try:
        css_path = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS')
    except AttributeError:
        css_path = 'admin_tools/css/theming.css'

    if css_path is not None:
        css_url = '%s/%s' % (get_media_url(), css_path)
        rval = '<link rel="stylesheet" type="text/css" media="screen" href="%s" />' % css_url

    return rval

register.simple_tag(render_theming_css)

Enable not loading theming CSS by explicitely setting ADMIN_TOOLS_THEMING_CSS to None
Enable not loading theming CSS by explicitely setting ADMIN_TOOLS_THEMING_CSS to None

  
  from django import template
  from django.conf import settings
  from admin_tools.utils import get_media_url
  
  register = template.Library()
  
  def render_theming_css():
      """
      Template tag that renders the needed css files for the theming app.
+ 
+     If ADMIN_TOOLS_THEMING_CSS is explicitely defined to None, don't render
+     anything.
      """
+     rval = ''
+     try:
-     css = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS', False)
+         css_path = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS')
-     if css:
+     except AttributeError:
+         css_path = 'admin_tools/css/theming.css'
+ 
+     if css_path is not None:
-         css = '/'.join([get_media_url(), css])
+         css_url = '%s/%s' % (get_media_url(), css_path)
-     else:
-         css = '/'.join([get_media_url(), 'admin_tools', 'css', 'theming.css'])
-     return '<link rel="stylesheet" type="text/css" media="screen" href="%s" />' % css
+         rval = '<link rel="stylesheet" type="text/css" media="screen" href="%s" />' % css_url
+ 
+     return rval
+ 
  register.simple_tag(render_theming_css)
  
Enable not loading theming CSS by explicitely setting ADMIN_TOOLS_THEMING_CSS to None
## Code Before:

from django import template
from django.conf import settings
from admin_tools.utils import get_media_url

register = template.Library()

def render_theming_css():
    """
    Template tag that renders the needed css files for the theming app.
    """
    css = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS', False)
    if css:
        css = '/'.join([get_media_url(), css])
    else:
        css = '/'.join([get_media_url(), 'admin_tools', 'css', 'theming.css'])
    return '<link rel="stylesheet" type="text/css" media="screen" href="%s" />' % css
register.simple_tag(render_theming_css)

## Instruction:
Enable not loading theming CSS by explicitely setting ADMIN_TOOLS_THEMING_CSS to None
## Code After:

from django import template
from django.conf import settings
from admin_tools.utils import get_media_url

register = template.Library()

def render_theming_css():
    """
    Template tag that renders the needed css files for the theming app.

    If ADMIN_TOOLS_THEMING_CSS is explicitely defined to None, don't render
    anything.
    """
    rval = ''
    try:
        css_path = getattr(settings, 'ADMIN_TOOLS_THEMING_CSS')
    except AttributeError:
        css_path = 'admin_tools/css/theming.css'

    if css_path is not None:
        css_url = '%s/%s' % (get_media_url(), css_path)
        rval = '<link rel="stylesheet" type="text/css" media="screen" href="%s" />' % css_url

    return rval

register.simple_tag(render_theming_css)
