Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20140 closed Bug (invalid)

core/validators.py treats string as integer an throws TypeError

Reported by: stadtpirat11@… Owned by: nobody
Component: Core (Other) Version: 1.5
Severity: Release blocker Keywords: core, python3, validators
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Implement django.contrib.gis.admin

Run your Project with Django
$ python3 manage.py runserver

Visit http://localhost:8000/admin/stadtpirat_climbs/fels/add/

Add data to fels
Code is

class Fels(models.Model):
    name = models.CharField(max_length="255")
    beschreibung = models.TextField()
    polygon = models.PolygonField()
    punkt   = models.PointField()
    objects = models.GeoManager()
Environment:


Request Method: POST
Request URL: http://localhost:8000/admin/ stadtpirat_climbs/fels/add/

Django Version: 1.5
Python Version: 3.2.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.gis',
 ' stadtpirat_climbs')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python3.2/dist-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/contrib/admin/options.py" in wrapper
  372.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/contrib/admin/sites.py" in inner
  202.             return view(request, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/usr/local/lib/python3.2/dist-packages/django/db/transaction.py" in inner
  223.                 return func(*args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/django/contrib/admin/options.py" in add_view
  989.             if form.is_valid():
File "/usr/local/lib/python3.2/dist-packages/django/forms/forms.py" in is_valid
  126.         return self.is_bound and not bool(self.errors)
File "/usr/local/lib/python3.2/dist-packages/django/forms/forms.py" in _get_errors
  117.             self.full_clean()
File "/usr/local/lib/python3.2/dist-packages/django/forms/forms.py" in full_clean
  272.         self._clean_fields()
File "/usr/local/lib/python3.2/dist-packages/django/forms/forms.py" in _clean_fields
  287.                     value = field.clean(value)
File "/usr/local/lib/python3.2/dist-packages/django/forms/fields.py" in clean
  156.         self.run_validators(value)
File "/usr/local/lib/python3.2/dist-packages/django/forms/fields.py" in run_validators
  135.                 v(value)
File "/usr/local/lib/python3.2/dist-packages/django/core/validators.py" in __call__
  166.         if self.compare(cleaned, self.limit_value):
File "/usr/local/lib/python3.2/dist-packages/django/core/validators.py" in <lambda>
  194.     compare = lambda self, a, b: a > b

Exception Type: TypeError at /admin/ stadtpirat_climbs/fels/add/
Exception Value: unorderable types: int() > str()

Change History (4)

comment:1 Changed 2 years ago by stadtpirat11@…

  • Component changed from GIS to Core (Other)
  • Keywords core validators added; admin gis removed
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Admin breaks with python3 when adding data. to core/validators.py treats string as integer an throws TypeError

I change this because I have more details.

Changing line 194 in /usr/local/lib/python3.2/dist-packages/django/core/validators.py from

    compare = lambda self, a, b: a > b

to

    compare = lambda self, a, b: a > b

is a quick fix.

comment:2 Changed 2 years ago by anonymous

Typo in my previous post.
From ... to

    compare = lambda self, a, b: a > int(b)

My bad :)

comment:3 Changed 2 years ago by claudep

  • Resolution set to invalid
  • Status changed from new to closed

max_length="255" -> max_length=255

comment:4 Changed 2 years ago by anonymous

sorry.

Note: See TracTickets for help on using tickets.
Back to Top