Django: python manage.py runserver gives RuntimeError: maximum recursion depth exceeded in cmp

前端 未结 4 1832
长情又很酷
长情又很酷 2020-11-30 10:24

I am trying to learn Django form the 1st tutorial on the Django project website. I might be missing something obvious but, after following all the instructions when I come

相关标签:
4条回答
  • 2020-11-30 10:37

    I had this problem here, today.

    We were using django1.5.1 and python2.7.2 too.

    At first we were installed django1.4 and it worked, but the project has django1.5 features, so it's not a total solution.

    To solve this we installed python2.7.5 and it worked fine!

    0 讨论(0)
  • 2020-11-30 10:37

    just use this : python manage.py migrate

    0 讨论(0)
  • 2020-11-30 10:43

    The problem is in functools.py file. This file is from Python. I have just installed a new version of python 2.7.5 and this file is wrong (I have another - older installation of python 2.7.5 and there the file functools.py is correct)

    To fix the problem replace this (about line 56 in python\Lib\fuctools.py):

    convert = {
        '__lt__': [('__gt__', lambda self, other: other < self),
                   ('__le__', lambda self, other: not other < self),
                   ('__ge__', lambda self, other: not self < other)],
        '__le__': [('__ge__', lambda self, other: other <= self),
                   ('__lt__', lambda self, other: not other <= self),
                   ('__gt__', lambda self, other: not self <= other)],
        '__gt__': [('__lt__', lambda self, other: other > self),
                   ('__ge__', lambda self, other: not other > self),
                   ('__le__', lambda self, other: not self > other)],
        '__ge__': [('__le__', lambda self, other: other >= self),
                   ('__gt__', lambda self, other: not other >= self),
                   ('__lt__', lambda self, other: not self >= other)]
    }
    

    to that:

    convert = {
        '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
                   ('__le__', lambda self, other: self < other or self == other),
                   ('__ge__', lambda self, other: not self < other)],
        '__le__': [('__ge__', lambda self, other: not self <= other or self == other),
                   ('__lt__', lambda self, other: self <= other and not self == other),
                   ('__gt__', lambda self, other: not self <= other)],
        '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
                   ('__ge__', lambda self, other: self > other or self == other),
                   ('__le__', lambda self, other: not self > other)],
        '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
                   ('__gt__', lambda self, other: self >= other and not self == other),
                   ('__lt__', lambda self, other: not self >= other)]
    }
    

    Read also: http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

    0 讨论(0)
  • 2020-11-30 10:49

    You have likely run into this bug: http://bugs.python.org/issue10042

    Exactly what happens is hard to tell without debugging, bit I'd guess one of the things that should be a field isn't in this line:

    self.local_fields.insert(bisect(self.local_fields, field), field)
    
    0 讨论(0)
提交回复
热议问题