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

Update Profile Form Issues #16

Closed
WayneLambert opened this issue Jun 8, 2020 · 6 comments
Closed

Update Profile Form Issues #16

WayneLambert opened this issue Jun 8, 2020 · 6 comments
Assignees
Labels
app: blog Issues relating to the `blog` app app: users Issues relating to the `users` app post deploy activity Items requiring attention once site has been deployed refactor candidate Items that could be refactored at a later stage

Comments

@WayneLambert
Copy link
Owner

The form has a multiple form setup involving one for the Django User model and the other a Profile model connected using signals.

There are 3 problems with the form that need to be resolved.

  1. The form does not post successfully

  2. The form doesn't prepopulate for the fields which are from the profile form such as the author view radio buttons.

  3. The form also doesn't pre-populate the image being used in the custom bootstrap file image box.

@WayneLambert WayneLambert added bug Something isn't working app: blog Issues relating to the `blog` app labels Jun 8, 2020
@WayneLambert WayneLambert self-assigned this Jun 8, 2020
@WayneLambert
Copy link
Owner Author

The form now posts successfully with changes reflected in the database and the success URL being implemented.

Due to the form spanning across both Django's User model and my custom Profile model, the controls relating to the Profile form do not seem to be instantiating with the model's value.

@WayneLambert
Copy link
Owner Author

The form now pre-populates the current image being used in the custom Bootstrap file field. When the form is instantiated, it displays the image being used according to the model. Upon using the input picker, it displays the image selected from the hard drive.

@WayneLambert
Copy link
Owner Author

WayneLambert commented Jun 17, 2020

The form now GETs and POSTs successfully instantiating the fields as expected. I had to resolve the issue using a function-based view because it was proving challenging validating multiple forms within the UpdateView.

At a later stage, I may choose to rewrite the view with a class-based view. I believe it may need a parent class writing too which will include a function that validates multiple forms.

@WayneLambert WayneLambert added refactor candidate Items that could be refactored at a later stage and removed bug Something isn't working labels Jun 17, 2020
WayneLambert added a commit that referenced this issue Jun 17, 2020
Correct custom Bootstrap file upload widget
@WayneLambert WayneLambert added post deploy activity Items requiring attention once site has been deployed app: users Issues relating to the `users` app labels Jun 18, 2020
@WayneLambert
Copy link
Owner Author

Profile updates successfully. Issue resolved for now. At a later date, an aspirational item may be to change the view from function-based to class-based.

@WayneLambert
Copy link
Owner Author

This Django package may be able to assist in converting the profile_update view from function-based to class-based.

https://github.com/kennethlove/django-shapeshifter

@WayneLambert WayneLambert reopened this Jul 29, 2020
WayneLambert added a commit that referenced this issue Jul 30, 2020
@WayneLambert
Copy link
Owner Author

Used Django Shapeshifter to use a CBV approach to the UserUpdateForm and ProfileUpdateForm.

Updated tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app: blog Issues relating to the `blog` app app: users Issues relating to the `users` app post deploy activity Items requiring attention once site has been deployed refactor candidate Items that could be refactored at a later stage
Projects
None yet
Development

No branches or pull requests

1 participant