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

Error when viewing categorizations #158

Closed
khatchad opened this issue Dec 10, 2021 · 9 comments
Closed

Error when viewing categorizations #158

khatchad opened this issue Dec 10, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@khatchad
Copy link
Member

khatchad commented Dec 10, 2021

I logged in as myself and tried to view categorizations, but I get the following error:

Environment:


Request Method: GET
Request URL: https://fathomless-inlet-57767.herokuapp.com/categorizations

Django Version: 3.2.10
Python Version: 3.7.8
Installed Applications:
['ponder.apps.BugFixesConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_tables2',
 'debug_toolbar',
 'crispy_forms',
 'django_filters',
 'bootstrap3',
 'widget_tweaks',
 'bootstrap_modal_forms',
 'rest_framework',
 'pytz']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware']


Template error:
In template /app/.heroku/python/lib/python3.7/site-packages/django_tables2/templates/django_tables2/bootstrap.html, error at line 29
   __str__ returned non-string (type User)
   19 :                     {% endfor %}
   20 :                     </tr>
   21 :                 </thead>
   22 :             {% endif %}
   23 :             {% endblock table.thead %}
   24 :             {% block table.tbody %}
   25 :                 <tbody {{ table.attrs.tbody.as_html }}>
   26 :                 {% for row in table.paginated_rows %}
   27 :                     {% block table.tbody.row %}
   28 :                     <tr {{ row.attrs.as_html }}>
   29 :                          {% for column, cell in row.items %} 
   30 :                             <td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
   31 :                         {% endfor %}
   32 :                     </tr>
   33 :                     {% endblock table.tbody.row %}
   34 :                 {% empty %}
   35 :                     {% if table.empty_text %}
   36 :                     {% block table.tbody.empty_text %}
   37 :                         <tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr>
   38 :                     {% endblock table.tbody.empty_text %}
   39 :                     {% endif %}


Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/app/ponder/views.py", line 211, in categorizations_by_userID
    return render(request, 'ponder/categorizations_by_userID.html', {"table_by_userID": table_by_userID, "table_by_round": table_by_round, "table_by_round_userID": table_by_round_userID, "rounds": filter_by_round, "users": filter_by_user})
  File "/app/.heroku/python/lib/python3.7/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py", line 281, in render
    return self.nodelist_false.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py", line 312, in render
    return nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py", line 312, in render
    return nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/templatetags/django_tables2.py", line 167, in render
    return template.render(context={"table": table}, request=request)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 988, in render
    output = self.filter_expression.resolve(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 858, in _resolve_lookup
    current = current()
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 76, in super
    return mark_safe(self.render(self.context))
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py", line 211, in render
    nodelist.append(node.render_annotated(context))
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py", line 167, in render
    values = list(values)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/rows.py", line 244, in items
    column.current_value = self.get_cell(column.name)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/rows.py", line 198, in get_cell
    bound_column, render_func=self._call_render, default=bound_column.default
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/rows.py", line 173, in _get_and_render_with
    return render_func(bound_column, value)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/rows.py", line 208, in _call_render
    return bound_column.link(content, **render_kwargs) if bound_column.link else content
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/columns/base.py", line 152, in __call__
    attrs = self.get_attrs(**kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/columns/base.py", line 147, in get_attrs
    attrs["href"] = self.compose_url(**kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/columns/base.py", line 97, in compose_url
    return call_with_appropriate(self.url, kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django_tables2/utils.py", line 572, in call_with_appropriate
    return fn(**kwargs)
  File "/app/ponder/tables.py", line 77, in <lambda>
    categorizer = tables.Column(linkify=lambda record: record.email_categorizer())
  File "/app/ponder/models.py", line 58, in email_categorizer
    user = User.objects.get(username=self.categorizer)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 424, in get
    clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 941, in filter
    return self._filter_or_exclude(False, args, kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1393, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1415, in _add_q
    split_subq=split_subq, check_filterable=check_filterable,
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1347, in build_filter
    condition = self.build_lookup(lookups, col, value)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1193, in build_lookup
    lookup = lookup_class(lhs, rhs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/lookups.py", line 25, in __init__
    self.rhs = self.get_prep_lookup()
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/lookups.py", line 77, in get_prep_lookup
    return self.lhs.output_field.get_prep_value(self.rhs)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 1074, in get_prep_value
    return self.to_python(value)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 1070, in to_python
    return str(value)

Exception Type: TypeError at /categorizations
Exception Value: __str__ returned non-string (type User)
@khatchad khatchad added the bug Something isn't working label Dec 10, 2021
@khatchad
Copy link
Member Author

@ZhongweiL, is this coming from your code?

Exception Type: TypeError at /categorizations
Exception Value: __str__ returned non-string (type User)

@ZhongweiL
Copy link
Contributor

I don't think it's from my code.

@khatchad
Copy link
Member Author

Give me a full investigation, please.

@khatchad
Copy link
Member Author

By Monday. Thanks.

@khatchad
Copy link
Member Author

khatchad commented Dec 13, 2021 via email

@khatchad
Copy link
Member Author

khatchad commented Dec 14, 2021

The problem is with this line. That field used to be a string. Now it is a User object.

@khatchad
Copy link
Member Author

To make that work correctly, we would need to update every reference to that field and replace it with a call to the appropriate accessor method that retrieves what we had before.

@khatchad
Copy link
Member Author

khatchad commented Dec 14, 2021

That's why we are getting:

__str__ returned non-string (type User)

@ZhongweiL
Copy link
Contributor

#147 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants