Ticket #5968: allowiterable.diff

File allowiterable.diff, 1.3 KB (added by Anders Olsson, 17 years ago)
  • django/contrib/databrowse/sites.py

     
    33from django.contrib.databrowse.datastructures import EasyModel, EasyChoice
    44from django.shortcuts import render_to_response
    55from django.utils.safestring import mark_safe
     6import types
    67
    78class AlreadyRegistered(Exception):
    89    pass
     
    8586        If a model is already registered, this will raise AlreadyRegistered.
    8687        """
    8788        databrowse_class = databrowse_class or DefaultModelDatabrowse
    88         if issubclass(model_or_iterable, models.Model):
     89        if isinstance(model_or_iterable, types.TypeType) and issubclass(model_or_iterable, models.Model):
    8990            model_or_iterable = [model_or_iterable]
    9091        for model in model_or_iterable:
    9192            if model in self.registry:
     
    9899
    99100        If a model isn't already registered, this will raise NotRegistered.
    100101        """
    101         if issubclass(model_or_iterable, models.Model):
     102        if isinstance(model_or_iterable, types.TypeType) and issubclass(model_or_iterable, models.Model):
    102103            model_or_iterable = [model_or_iterable]
    103104        for model in model_or_iterable:
    104105            if model not in self.registry:
Back to Top