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

Annotated fields messing with ListViews #1346

Closed
gythaogg opened this issue Nov 5, 2024 · 1 comment · Fixed by #1357 or #1350
Closed

Annotated fields messing with ListViews #1346

gythaogg opened this issue Nov 5, 2024 · 1 comment · Fixed by #1357 or #1350
Assignees
Labels
bug Something isn't working (properly, as expected, at all)

Comments

@gythaogg
Copy link
Contributor

gythaogg commented Nov 5, 2024

Can be reproduced in PR #1345 using the following steps

  1. Visit Person list view (should load fine)
  2. Visit Place list view (you'll see a column called resident_name in the columns dropdown, it does not matter whether this is selected or not, but it is worth noting that this column points to "forename" column in Person)
  3. Visit Person list view

You'll see this error - the mixup seems to arise from the new meaning of this column forename, it expects the column resident_name now in the Person view

TypeError at /sample_project.person/
'Meta.fields' must not contain non-model field names: resident_name
Request Method: GET
Request URL: http://127.0.0.1:8001/sample_project.person/
Django Version: 5.1.2
Exception Type: TypeError
Exception Value:
'Meta.fields' must not contain non-model field names: resident_name
Exception Location: /.cache/pypoetry/virtualenvs/apis-core-rdf-vnNGgzXk-py3.12/lib/python3.12/site-packages/django_filters/filterset.py, line 367, in get_filters
Raised during: apis_core.generic.views.List
Python Executable: /.cache/pypoetry/virtualenvs/apis-core-rdf-vnNGgzXk-py3.12/bin/python
Python Version: 3.12.3
Python Path:
['/usr/lib/python312.zip',
'/usr/lib/python3.12',
'/usr/lib/python3.12/lib-dynload',
'/.cache/pypoetry/virtualenvs/apis-core-rdf-vnNGgzXk-py3.12/lib/python3.12/site-packages']
Server time: Tue, 05 Nov 2024 05:58:05 -0600

@gythaogg
Copy link
Contributor Author

gythaogg commented Nov 5, 2024

It seems to have been introduced in eaef405 while fixing #735
Reverting this seems to make this problem go away (but then probably reopens #735)

@gythaogg gythaogg added the bug Something isn't working (properly, as expected, at all) label Nov 5, 2024
b1rger added a commit that referenced this issue Nov 11, 2024
If we create `fake_field` by simply using `getattr` on the
`annotations.items()` we actually get the original field and then change
its name in the next line. But thats not what we want, because that
changes the field for the model it belongs to. We only want a temporary
field, so we can add it to the `extra_columns`.

Closes: #1346
b1rger added a commit that referenced this issue Nov 11, 2024
If we create `fake_field` by simply using `getattr` on the
`annotations.items()` we actually get the original field and then change
its name in the next line. But thats not what we want, because that
changes the field for the model it belongs to. We only want a temporary
field, so we can add it to the `extra_columns`.

Closes: #1346
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (properly, as expected, at all)
Projects
None yet
2 participants