Skip to content

Unable to get repr for <class 'mongoengine.queryset.QuerySet'> #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nuklea opened this issue Sep 14, 2012 · 1 comment
Closed

Unable to get repr for <class 'mongoengine.queryset.QuerySet'> #133

nuklea opened this issue Sep 14, 2012 · 1 comment
Milestone

Comments

@nuklea
Copy link

nuklea commented Sep 14, 2012

My document:

class Article(Document):
    title = StringField(verbose_name=u'Заголовок', max_length=127)

    def __unicode__(self):
        return self.title

I use Django and append queryset into template:

def article_links(request):
    return {'articles_link': Article.objects.all()[:8]}

Attention! Title field contains unicode string, for example u'заголовок статьи'.

And get:

File "/home/nuklea/.virtualenvs/project/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  188.                 response = middleware_method(request, response)
File "/home/nuklea/.virtualenvs/project/src/django-debug-toolbar/debug_toolbar/panels/template.py" in process_response
  118.                     pformat(k(self.request))) for k in get_standard_processors()
File "/usr/lib/python2.7/pprint.py" in pformat
  60.     return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(object)
File "/usr/lib/python2.7/pprint.py" in pformat
  119.         self._format(object, sio, 0, 0, {}, 0)
File "/usr/lib/python2.7/pprint.py" in _format
  137.         rep = self._repr(object, context, level - 1)
File "/usr/lib/python2.7/pprint.py" in _repr
  230.                                                 self._depth, level)
File "/usr/lib/python2.7/pprint.py" in format
  242.         return _safe_repr(object, context, maxlevels, level)
File "/usr/lib/python2.7/pprint.py" in _safe_repr
  286.             vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
File "/usr/lib/python2.7/pprint.py" in _safe_repr
  327.     rep = repr(object)
File "/home/nuklea/.virtualenvs/project/lib/python2.7/site-packages/mongoengine/queryset.py" in __repr__
  1899.         return repr(data)

Exception Type: UnicodeEncodeError at /
Exception Value: 'ascii' codec can't encode characters in position 10-17: ordinal not in range(128)```
@rozza
Copy link
Contributor

rozza commented Oct 1, 2012

Fixed in 0.7 / master

@rozza rozza closed this as completed Oct 1, 2012
samuelclay added a commit to samuelclay/mongoengine that referenced this issue Oct 29, 2012
* 'master' of https://github.com/MongoEngine/mongoengine: (24 commits)
  Fixing py3 compat
  Added chaining regression test (MongoEngine#135)
  Updated test
  Unicode fix for repr (MongoEngine#133)
  Allow updates with match operators (MongoEngine#144)
  Unicode fix reverted but can have custom validator
  Fix loop
  Updated URLField
  Added Garry Polley to contributors list
  can now use AuthenticationBackends with permissions.
  Updates to the readme
  Added CONTRIBUTING.rst
  Updated docs thanks @mitar
  Moved injection of Exceptions to top level
  Fixed reload issue with ReferenceField where dbref=False (MongoEngine#138)
  Improved import cache
  Fixed objectId for DBRef
  Updated travis.yml
  Fix ReferenceField dbref = False
  Updated docs
  ...
samuelclay added a commit to samuelclay/mongoengine that referenced this issue Jan 28, 2013
* 'master' of github.com:samuelclay/mongoengine: (227 commits)
  Adding QuerySet(read_preference=pymongo.ReadPreference.X) and QuerySet().read_preference() method to override connection-level read_preference on a per-query basis.
  Fixing py3 compat
  Added chaining regression test (MongoEngine#135)
  Updated test
  Unicode fix for repr (MongoEngine#133)
  Allow updates with match operators (MongoEngine#144)
  Unicode fix reverted but can have custom validator
  Fix loop
  Updated URLField
  Added Garry Polley to contributors list
  can now use AuthenticationBackends with permissions.
  Updates to the readme
  Added CONTRIBUTING.rst
  Updated docs thanks @mitar
  Moved injection of Exceptions to top level
  Fixed reload issue with ReferenceField where dbref=False (MongoEngine#138)
  Improved import cache
  Fixed objectId for DBRef
  Updated travis.yml
  Fix ReferenceField dbref = False
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants