Skip to content
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

Django 2.x models with choices cause exceptions #76

Open
dragonpaw opened this issue May 8, 2020 · 0 comments
Open

Django 2.x models with choices cause exceptions #76

dragonpaw opened this issue May 8, 2020 · 0 comments

Comments

@dragonpaw
Copy link

  • PrettyPrinter version:
  • Python version: 3.7
  • Operating System:

Description

Attempting to print a simple database object with choices on one field.

class User(models.Model):
    A = 'a'
    B = 'b'
    C = 'c'

    role = models.CharField(
        choices=(
            (A, "Alpha"),
            (B, "Beta"),
            (C, "Charlie"),
        ),
        default=A,
        max_length=20,
    )

Stack trace

Traceback (most recent call last):
  File "/Users/ash/src/xxx/.venv/lib/python3.7/site-packages/prettyprinter/prettyprinter.py", line 387, in _run_pretty
    doc = pretty_fn(value, ctx)
  File "/Users/ash/src/xxx/.venv/lib/python3.7/site-packages/prettyprinter/extras/django.py", line 169, in pretty_base_model
    display
  File "/Users/ash/src/xxx/.venv/lib/python3.7/site-packages/prettyprinter/prettyprinter.py", line 154, in comment_doc
    return annotate(CommentAnnotation(comment_text), doc)
  File "/Users/ash/src/xxx/.venv/lib/python3.7/site-packages/prettyprinter/prettyprinter.py", line 111, in __init__
    assert isinstance(value, str)
AssertionError
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

1 participant