1

We are having two python apps with same database, one is running on python 2 and the other on python 3. We are accessing python 2 app models in python 3 app. While all other models work fine. One model is throwing error when queried :

Traceback:

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.6/contextlib.py" in inner 52. return func(*args, **kwds)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/contrib/admin/options.py" in wrapper 551. return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/contrib/admin/sites.py" in inner 224. return view(request, *args, **kwargs)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper 67. return bound_func(*args, **kwargs)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func 63. return func.get(self, type(self))(*args2, **kwargs2)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/contrib/admin/options.py" in changelist_view 1662. selection_note=_('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/db/models/query.py" in len 232. self._fetch_all()

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/db/models/query.py" in _fetch_all 1118. self._result_cache = list(self._iterable_class(self))

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/db/models/query.py" in iter 62. for row in compiler.results_iter(results):

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in results_iter 847. row = self.apply_converters(row, converters)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in apply_converters 832. value = converter(value, expression, self.connection, self.query.context)

File "/home/pulkit/.local/share/virtualenvs/morpheus-NvWJB9pm/lib/python3.6/site-packages/django/db/backends/mysql/operations.py" in convert_uuidfield_value 244. value = uuid.UUID(value)

File "/usr/local/lib/python3.6/uuid.py" in init 137. hex = hex.replace('urn:', '').replace('uuid:', '')

Exception Type: AttributeError at /admin/orders/gmasorder/ Exception Value: 'int' object has no attribute 'replace'

Rakesh
  • 81,458
  • 17
  • 76
  • 113
pulkit
  • 11
  • 5
  • How is hex being set? The error is saying it's an int, and the int type has no replace() method. Looking at the syntax that looks like a str.replace() call. I suspect something that sets hex returns an int where you expected it to return a string. – codingatty Mar 01 '19 at 06:15
  • https://stackoverflow.com/a/41390420/4758119 – Deepak Mahakale Mar 01 '19 at 06:36
  • Seems like the value you have in hex is `int`. You might need to convert it to string first – Deepak Mahakale Mar 01 '19 at 06:36
  • Thanks DeepakMahakale and codingatty but I am not sure from where this function is being called. I have defined __str__ function under model which returns string but no idea what is invoking convert_uuidfield_value function. – pulkit Mar 01 '19 at 06:42
  • 1
    Can you show your model that is throwing this exception? – GwynBleidD Mar 01 '19 at 10:53

0 Answers0