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

FieldDoesNotExist is raised when declaring custom form field in modelform #32

Open
nortigo opened this issue Jul 2, 2021 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@nortigo
Copy link
Contributor

nortigo commented Jul 2, 2021

I found a bug at line:

field_object = model._meta.get_field(name)

How to reproduce:

  1. Create a modelform
  2. Add a custom field not related to the model
  3. Try changing some of the fields and save

Actual result:

A FieldDoesNotExists exception is raised:

django.core.exceptions.FieldDoesNotExist: AidRequest has no field named 'resubmit'

Expected result:

Custom field should be ignored.

@DonKannalie
Copy link

Did you find a workaround?

@nortigo
Copy link
Contributor Author

nortigo commented Mar 24, 2022

Dirty workaround would be adding a try...except.

Clean workaround would be having meta fields such as excluded and fields so we can skip non model fields, something similar to forms.

@TrangPham
Copy link
Owner

:) I'd be very happy to review a PR that adds the excluded and fields.

@nortigo
Copy link
Contributor Author

nortigo commented Mar 25, 2022

I don't have the time at the moment but if someone wants to jump on it, be my guest :)

@TrangPham TrangPham added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants