Sunday, September 20, 2020

Help with form rendering

Hello all!

I'm starting developer and i have webapp project where users can register and participate in guessing the results of football matches. Users accumulate points from correct guesses. I'm having problems rendering the guessing view to templates the way i want it to display. I'm using SQLite 3 and my database model for this project looks like this: https://docs.google.com/spreadsheets/d/1mqJjzcbmCwr2orMCiqOVbd61b_357ewENEq3TpODdog/edit#gid=0


My models.py looks like following: https://pastebin.com/mZZk1zgN. It has 3 classes, Profile, Results and Guesses. Profile has foreign key to User model and Guesses has foreign key to Profile and Results. Is this okay?


My guess view takes ModelForm from Guesses model and renders it to the template but here is the problem. How do i render the form so that it would show all matches that i have put in the database and after each match a "guess" textbox where users put their guess(ex. 2-1, 0-0, 0-2 etc.).


My view and template looks like this: https://pastebin.com/VtTrt9hS. It works but user can save only one guess to database at time while i want user to be able to guess multiple matches at the same time before hitting submit(to make it simple only one guess per match is allowed).


Hopefully someone can help and if you have comments about my code, feedback is much appreciated! Though remember that i started Django only at this year so try to keep the answers simple :)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5b82b9f3-37d4-4370-928d-1595a471d051n%40googlegroups.com.

No comments:

Post a Comment