anschelburk / simple_planner

Apache License 2.0
0 stars 0 forks source link

Configure `update_events` View #12

Closed anschelburk closed 4 months ago

anschelburk commented 4 months ago

Spent today working on this. Having some trouble uploading my code, but used the following ChatGPT Threads, and wasn’t able to get the code working:

Part of the issue I’m running into is that I’m not sure what needs to link to the API endpoint - is it the Javascript? Do I need to add some HTMX to calendar_modal.html, and target the specific URLConfig leading to that view? Not exactly sure which parts of the code need to connect to the view described in the ChatGPT thread, and would love some guidance so I can work more on this tomorrow.

bbelderbos commented 4 months ago

The threads describe clear Django steps to follow, did you try those? Can you send me a pull request of the code you have so far so I can guide you from there?

Basically you have the code in your calendar javascript which is doing an (HTTP) PUT call a Django route, indeed you will have to setup that route in urls.py and link to a view there, then write the view to handle the put request = a. parse the input parameters sent along in the request, and b. retrieve + update a calendar record in the db - does that make sense?

Thanks

anschelburk commented 4 months ago

Got my code up! And, submitted a pull request (#13). I'm unsure of what I'm doing wrong - would appreciate any thoughts you have. Appreciate it.

bbelderbos commented 4 months ago

ok thanks, I will try it out now ...

anschelburk commented 4 months ago

Thanks for catching my mistakes on Pull Request #13. Before you caught my mistake, I did some research of my own; and while I ultimately didn't catch the mistake, I still found it really interesting, and want to log it here!

Also, in response to this comment (posting here for the sake of organization, since it relates to this issue) - one question I kept running into was the difference between a put request and a post request (hence the links above). One thing I tested was just using the create_event view for both creating and updating events. It ultimately didn't work, but that's where that piece of code came from. (My understanding of why, per this thread, is that you can post a piece of data once, but put it many times, though please correct me if that's wrong!)

bbelderbos commented 4 months ago

yeah this goes into APIs and http methods a bit which is important to know as a developer - this can help: https://chatgpt.com/share/724516aa-204f-4ec4-afee-b3745dde7923

anschelburk commented 4 months ago

yeah this goes into APIs and http methods a bit which is important to know as a developer - this can help: https://chatgpt.com/share/724516aa-204f-4ec4-afee-b3745dde7923

Thank you! Very helpful.