from django import template

register = template.Library()


@register.filter
def dimension(value, arg):
    """
    Dimension integers

    If value, append arg, otherwise output nothing
    """
    if value:
        return str(value) + " " + arg
    return ""


@register.filter
def verbose_name(obj):
    """
    Return the verbose name of a model
    """
    return obj._meta.verbose_name


@register.filter
def pdb(element):
    """
    Inside a template do {{ template_var|pdb }}
    """
    import ipdb
    ipdb.set_trace()
    return element


from cat.models import Category
from location.models import Country


@register.inclusion_tag('snippets/advanced_search_fields.html')
def advanced_search_fields():
    categories = Category.objects.all()
    places = Country.objects.all()

    return {
        'categories': categories,
        'places': places,
    }

from django import template

register = template.Library()


@register.filter
def dimension(value, arg):
    """
    Dimension integers

    If value, append arg, otherwise output nothing
    """
    if value:
        return str(value) + " " + arg
    return ""


@register.filter
def verbose_name(obj):
    """
    Return the verbose name of a model
    """
    return obj._meta.verbose_name


@register.filter
def pdb(element):
    """
    Inside a template do {{ template_var|pdb }}
    """
    import ipdb
    ipdb.set_trace()
    return element


from cat.models import Category
from location.models import Country


@register.inclusion_tag('snippets/advanced_search_fields.html')
def advanced_search_fields():
    categories = Category.objects.all().order_by('name')
    places = Country.objects.all()

    return {
        'categories': categories,
        'places': places,
    }

Order categories in search fields
Order categories in search fields

  from django import template
  
  register = template.Library()
  
  
  @register.filter
  def dimension(value, arg):
      """
      Dimension integers
  
      If value, append arg, otherwise output nothing
      """
      if value:
          return str(value) + " " + arg
      return ""
  
  
  @register.filter
  def verbose_name(obj):
      """
      Return the verbose name of a model
      """
      return obj._meta.verbose_name
  
  
  @register.filter
  def pdb(element):
      """
      Inside a template do {{ template_var|pdb }}
      """
      import ipdb
      ipdb.set_trace()
      return element
  
  
  from cat.models import Category
  from location.models import Country
  
  
  @register.inclusion_tag('snippets/advanced_search_fields.html')
  def advanced_search_fields():
-     categories = Category.objects.all()
+     categories = Category.objects.all().order_by('name')
      places = Country.objects.all()
  
      return {
          'categories': categories,
          'places': places,
      }
  
Order categories in search fields
## Code Before:
from django import template

register = template.Library()


@register.filter
def dimension(value, arg):
    """
    Dimension integers

    If value, append arg, otherwise output nothing
    """
    if value:
        return str(value) + " " + arg
    return ""


@register.filter
def verbose_name(obj):
    """
    Return the verbose name of a model
    """
    return obj._meta.verbose_name


@register.filter
def pdb(element):
    """
    Inside a template do {{ template_var|pdb }}
    """
    import ipdb
    ipdb.set_trace()
    return element


from cat.models import Category
from location.models import Country


@register.inclusion_tag('snippets/advanced_search_fields.html')
def advanced_search_fields():
    categories = Category.objects.all()
    places = Country.objects.all()

    return {
        'categories': categories,
        'places': places,
    }

## Instruction:
Order categories in search fields
## Code After:
from django import template

register = template.Library()


@register.filter
def dimension(value, arg):
    """
    Dimension integers

    If value, append arg, otherwise output nothing
    """
    if value:
        return str(value) + " " + arg
    return ""


@register.filter
def verbose_name(obj):
    """
    Return the verbose name of a model
    """
    return obj._meta.verbose_name


@register.filter
def pdb(element):
    """
    Inside a template do {{ template_var|pdb }}
    """
    import ipdb
    ipdb.set_trace()
    return element


from cat.models import Category
from location.models import Country


@register.inclusion_tag('snippets/advanced_search_fields.html')
def advanced_search_fields():
    categories = Category.objects.all().order_by('name')
    places = Country.objects.all()

    return {
        'categories': categories,
        'places': places,
    }
