from django.conf import settings


def _build_flag_url():
    if hasattr(settings, 'COUNTRIES_FLAG_URL'):
        url = settings.COUNTRIES_FLAG_URL
    else:
        url = 'flags/%(code)s.gif'
    prefix = getattr(settings, 'STATIC_URL', '') or settings.MEDIA_URL
    if not prefix.endswith('/'):
        prefix = '%s/' % prefix
    return '%s%s' % (prefix, url)


FLAG_URL = _build_flag_url()

from django.conf import settings


def _build_flag_url():
    if hasattr(settings, 'COUNTRIES_FLAG_URL'):
        url = settings.COUNTRIES_FLAG_URL
    else:
        url = 'flags/%(code)s.gif'

    prefix = getattr(settings, 'STATIC_URL', '') or \
        getattr(settings, 'STATICFILES_URL', '') or \
        settings.MEDIA_URL

    if not prefix.endswith('/'):
        prefix = '%s/' % prefix
    return '%s%s' % (prefix, url)


FLAG_URL = _build_flag_url()

Add django 1.3 staticfiles compatibility
Add django 1.3 staticfiles compatibility

  from django.conf import settings
  
  
  def _build_flag_url():
      if hasattr(settings, 'COUNTRIES_FLAG_URL'):
          url = settings.COUNTRIES_FLAG_URL
      else:
          url = 'flags/%(code)s.gif'
+ 
-     prefix = getattr(settings, 'STATIC_URL', '') or settings.MEDIA_URL
+     prefix = getattr(settings, 'STATIC_URL', '') or \
+         getattr(settings, 'STATICFILES_URL', '') or \
+         settings.MEDIA_URL
+ 
      if not prefix.endswith('/'):
          prefix = '%s/' % prefix
      return '%s%s' % (prefix, url)
  
  
  FLAG_URL = _build_flag_url()
  
Add django 1.3 staticfiles compatibility
## Code Before:
from django.conf import settings


def _build_flag_url():
    if hasattr(settings, 'COUNTRIES_FLAG_URL'):
        url = settings.COUNTRIES_FLAG_URL
    else:
        url = 'flags/%(code)s.gif'
    prefix = getattr(settings, 'STATIC_URL', '') or settings.MEDIA_URL
    if not prefix.endswith('/'):
        prefix = '%s/' % prefix
    return '%s%s' % (prefix, url)


FLAG_URL = _build_flag_url()

## Instruction:
Add django 1.3 staticfiles compatibility
## Code After:
from django.conf import settings


def _build_flag_url():
    if hasattr(settings, 'COUNTRIES_FLAG_URL'):
        url = settings.COUNTRIES_FLAG_URL
    else:
        url = 'flags/%(code)s.gif'

    prefix = getattr(settings, 'STATIC_URL', '') or \
        getattr(settings, 'STATICFILES_URL', '') or \
        settings.MEDIA_URL

    if not prefix.endswith('/'):
        prefix = '%s/' % prefix
    return '%s%s' % (prefix, url)


FLAG_URL = _build_flag_url()
