Ticket #13241: t13241.diff

File t13241.diff, 3.3 KB (added by Alex Gaynor, 14 years ago)

A few line length fixes.

  • AUTHORS

    diff --git a/AUTHORS b/AUTHORS
    index bf63b10..7741fa6 100644
    a b answer newbie questions, and generally made Django that much better:  
    197197    David Gouldin <dgouldin@gmail.com>
    198198    pradeep.gowda@gmail.com
    199199    Collin Grady <collin@collingrady.com>
     200    Gabriel Grant <g@briel.ca>
    200201    Simon Greenhill <dev@simon.net.nz>
    201202    Owen Griffiths
    202203    Espen Grindhaug <http://grindhaug.org/>
  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index b3deda1..1fc3609 100644
    a b import django.db.models.manager # Imported to register signal handler.  
    55from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS
    66from django.core import validators
    77from django.db.models.fields import AutoField, FieldDoesNotExist
    8 from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField
     8from django.db.models.fields.related import (OneToOneRel, ManyToOneRel,
     9    OneToOneField, add_lazy_relation)
    910from django.db.models.query import delete_objects, Q
    1011from django.db.models.query_utils import CollectedObjects, DeferredAttribute
    1112from django.db.models.options import Options
    class ModelBase(type):  
    223224        if opts.order_with_respect_to:
    224225            cls.get_next_in_order = curry(cls._get_next_or_previous_in_order, is_next=True)
    225226            cls.get_previous_in_order = curry(cls._get_next_or_previous_in_order, is_next=False)
    226             setattr(opts.order_with_respect_to.rel.to, 'get_%s_order' % cls.__name__.lower(), curry(method_get_order, cls))
    227             setattr(opts.order_with_respect_to.rel.to, 'set_%s_order' % cls.__name__.lower(), curry(method_set_order, cls))
     227            # defer creating accessors on the foreign class until we are
     228            # certain it has been created
     229            def make_foreign_order_accessors(field, model, cls):
     230                setattr(
     231                    field.rel.to,
     232                    'get_%s_order' % cls.__name__.lower(),
     233                    curry(method_get_order, cls)
     234                )
     235                setattr(
     236                    field.rel.to,
     237                    'set_%s_order' % cls.__name__.lower(),
     238                    curry(method_set_order, cls)
     239                )
     240            add_lazy_relation(
     241                cls,
     242                opts.order_with_respect_to,
     243                opts.order_with_respect_to.rel.to,
     244                make_foreign_order_accessors
     245            )
    228246
    229247        # Give the class a docstring -- its definition.
    230248        if cls.__doc__ is None:
  • tests/modeltests/order_with_respect_to/models.py

    diff --git a/tests/modeltests/order_with_respect_to/models.py b/tests/modeltests/order_with_respect_to/models.py
    index 99c9f13..64a0a7c 100644
    a b class Answer(models.Model):  
    1717    def __unicode__(self):
    1818        return unicode(self.text)
    1919
     20class Post(models.Model):
     21    title = models.CharField(max_length=200)
     22    parent = models.ForeignKey("self", related_name="children", null=True)
     23
     24    class Meta:
     25        order_with_respect_to = "parent"
     26
     27    def __unicode__(self):
     28        return self.title
     29
    2030__test__ = {'API_TESTS': """
    2131>>> q1 = Question(text="Which Beatle starts with the letter 'R'?")
    2232>>> q1.save()
Back to Top