# Path: native_tags/decorators.py
# def tag(bucket, doc):
#     def wrapped(inner, **options):


from django.db.models import get_model
from django.template import TemplateSyntaxError
from native_tags.decorators import function
        {% get_latest_object [app_name].[model_name] [field] as [varname] %}
    
    Example::
    
        {% get_latest_object comments.freecomment submitted_date as latest_comment %}
    
    """
    return _get_model(model)._default_manager.latest(field)
get_latest_object = function(get_latest_object)    


def get_latest_objects(model, num, field='?'):
    """
    Retrieves the latest ``num`` objects from a given model, in that
    model's default ordering, and stores them in a context variable.
    The optional field argument specifies which field to get_latest_by, otherwise the model's default is used
    
    Syntax::
    
        {% get_latest_objects [app_name].[model_name] [num] [field] as [varname] %}
    
    Example::
    
        {% get_latest_objects comments.freecomment 5 submitted_date as latest_comments %}
    
    """
    model = _get_model(model)
    if field == '?':
        field = model._meta.get_latest_by and '-%s' % model._meta.get_latest_by or field
    return model._default_manager.order_by(field)[:int(num)]

# Path: native_tags/decorators.py
# def tag(bucket, doc):
#     def wrapped(inner, **options):


# Path: native_tags/contrib/generic_content.py
from django.db.models import get_model
from django.template import TemplateSyntaxError
from native_tags.decorators import function

        {% get_latest_object [app_name].[model_name] [field] as [varname] %}
    
    Example::
    
        {% get_latest_object comments.freecomment submitted_date as latest_comment %}
    
    """
    return _get_model(model)._default_manager.latest(field)
get_latest_object = function(get_latest_object)    


def get_latest_objects(model, num, field='?'):
    """
    Retrieves the latest ``num`` objects from a given model, in that
    model's default ordering, and stores them in a context variable.
    The optional field argument specifies which field to get_latest_by, otherwise the model's default is used
    
    Syntax::
    
        {% get_latest_objects [app_name].[model_name] [num] [field] as [varname] %}
    
    Example::
    
        {% get_latest_objects comments.freecomment 5 submitted_date as latest_comments %}
    
    """
    model = _get_model(model)
    if field == '?':
        field = model._meta.get_latest_by and '-%s' % model._meta.get_latest_by or field
    return model._default_manager.order_by(field)[:int(num)]

get_latest_objects = function(get_latest_objects)