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

Any accessor with joined table returns a blank value #717

Closed
dgmdan opened this issue Nov 27, 2019 · 5 comments · Fixed by #722
Closed

Any accessor with joined table returns a blank value #717

dgmdan opened this issue Nov 27, 2019 · 5 comments · Fixed by #722

Comments

@dgmdan
Copy link

dgmdan commented Nov 27, 2019

Consider that you have a column where the accessor uses a joined table:

name = tables.Column(accessor='foo__name')

The value for this field will always show blank. I believe this is a regression starting in version 2.2.0. I went back to 2.1.1 to work around it.

@jieter
Copy link
Owner

jieter commented Nov 29, 2019

Can you share a bit about the data passed to the table (i.e. how the queryset looks)?

@tfbrito
Copy link

tfbrito commented Dec 12, 2019

I can confirm this.

With version 2.2.1 if we have a queryset that used values, for example the record is:

obj = { 'data_ok': 'value, 'invalid__key': 'invalid'}
from django_tables2 import A
A("invalid__key").resolve(obj, quiet=True)

We get empty value. If we call it with quiet=False we get the errors:

KeyError: 'invalid'
AttributeError: 'dict' object has no attribute 'invalid'
ValueError: invalid literal for int() with base 10: 'invalid'

The "solution" for now is to rollback to 2.1.1

@jieter
Copy link
Owner

jieter commented Dec 12, 2019

I think we will have to check if top level obj contains a key equal to the accessor value.

@jieter
Copy link
Owner

jieter commented Dec 18, 2019

@tfbrito I've added a fix for this in #722, can you have a look?

@LukeWUK
Copy link

LukeWUK commented Jan 16, 2020

Hello sorry if this is not the right place, but I have noticed a strange issue which also present this behavior.

I downloaded this package using pip install django_tables2 on a machine about a month ago, and it works great.

However I have downloaded it using pip on 3x other machines in the last couple of weeks, using the same command, and in all of these versions, it does not have the correct code. I know this because my joined accessors dont work, and also because I get "cannot import module django.stuff.six"

I also checked the version by attempting a pip--upgrade and it says its on 2.2.1, but the code is definately different than my other 2.2.1 version on the other pc. (I just copied that package into my other pcs to fix my issue)

Am I being really silly? Ive installed 1000s of packages and never had anything like this before.

Image below shows exerpt of the source with a monkey patch to import six, and me trying to update the package using pypi and it showing my version.

image

EDIT - Further testing, it seems that only 64 bit pythons versions, still have old references to django.six when installed via pip install django-tables2.

32 bit versions, you get the latest code without this issue.

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

Successfully merging a pull request may close this issue.

4 participants