dlamotte / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

utils.get_queryset_and_model breaks if Model contains a field named "model" #241

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
My model, "Server", contains a field called "model". Since this function
checks for the "model" attribute to determine if the object is a Queryset
it breaks.
A simple switch of the statements should work fine.

http://code.google.com/p/django-tagging/source/browse/trunk/tagging/utils.py#129
:

def get_queryset_and_model(queryset_or_model):
    """
    Given a ``QuerySet`` or a ``Model``, returns a two-tuple of
    (queryset, model).

    If a ``Model`` is given, the ``QuerySet`` returned will be created
    using its default manager.
    """
    try:
        return queryset_or_model, queryset_or_model.model
    except AttributeError:
        return queryset_or_model._default_manager.all(), queryset_or_model

Original issue reported on code.google.com by paul...@gmail.com on 19 Mar 2010 at 4:53