I’m trying to create a primitive online store functionality, and I want the end user to be able to input the number of items they want to order in one “front page” view and display that data in a second “basket” view. Should I just rebuild my code using forms, or is it possible to do this in default Django code? Here is the code for my current (unsuccessful) attempt: am I on the right track?
Django models page that gives context for the templates:
First note: When you post code snippets here, please insert them between lines containing only 3 backticks - ```. (Make sure you use the backtick - ` and not the apostrophe - '.) That means you would have one line with the 3 backticks, your code, and then one more line with just the 3 backticks. That allows this forum software to format your code nicely:
# The line above this is just ```
def function(parm):
return parm
# The line after this is just ```
If you want, you can edit your post to put the backticks before and after each of the code blocks you’ve posted - that’ll make it all easier for everyone to read.
Using forms is “default Django code”. That’s part of what makes Django such a usable system. You can get started without using them, but if you work on anything other than a “toy” project, you’ll find that you’re doing a lot of work that forms would do for you.
If you haven’t already done so, I always recommend people start with working their way through either (or both!) of the Official Django Tutorial and the Django Girls Tutorial . There’s a lot of useful information contained in them demonstrating how the different Django components all work together as an effective system.
I’d read the official tutorial already, so I just assumed that whatever was covered in that was the default way of doing things. Thanks for putting me on the right track. I can’t seem to be able to edit the OP anymore, though.
The tutorial is just an introduction to help get you started. There are many features within Django not covered within it, which is one reason why I also recommend the Django Girls Tutorial.