Ticket #5968: 5968-2.diff
File 5968-2.diff, 2.2 KB (added by , 16 years ago) |
---|
-
django/contrib/databrowse/sites.py
1 1 from django import http 2 2 from django.db import models 3 from django.db.models.base import ModelBase 3 4 from django.contrib.databrowse.datastructures import EasyModel 4 5 from django.shortcuts import render_to_response 5 6 from django.utils.safestring import mark_safe … … 85 86 If a model is already registered, this will raise AlreadyRegistered. 86 87 """ 87 88 databrowse_class = databrowse_class or DefaultModelDatabrowse 88 if is subclass(model_or_iterable, models.Model):89 if isinstance(model_or_iterable, ModelBase): 89 90 model_or_iterable = [model_or_iterable] 90 91 for model in model_or_iterable: 91 92 if model in self.registry: … … 98 99 99 100 If a model isn't already registered, this will raise NotRegistered. 100 101 """ 101 if is subclass(model_or_iterable, models.Model):102 if isinstance(model_or_iterable, ModelBase): 102 103 model_or_iterable = [model_or_iterable] 103 104 for model in model_or_iterable: 104 105 if model not in self.registry: -
docs/ref/contrib/databrowse.txt
41 41 2. Register a number of models with the Databrowse site:: 42 42 43 43 from django.contrib import databrowse 44 from myapp.models import SomeModel, SomeOtherModel 44 from myapp.models import SomeModel, SomeOtherModel, YetAnotherModel 45 45 46 46 databrowse.site.register(SomeModel) 47 databrowse.site.register( SomeOtherModel)47 databrowse.site.register([SomeOtherModel, YetAnotherModel]) 48 48 49 49 Note that you should register the model *classes*, not instances. 50 50 51 The register function accepts an individual model class or a list of classes. 52 51 53 It doesn't matter where you put this, as long as it gets executed at some 52 54 point. A good place for it is in your :ref:`URLconf file 53 55 <topics-http-urls>` (``urls.py``).