Online store on Steemit blockchain| Step seventeen | Templates: Add Curses Button
Hello, friends!
Today we will add the code for our button. So that we can create our course. Or rather, so that users of your online store can create kurs. And in the next post we will add editing and deleting the created post.
And we will start by writing the path for our button. Rather, the button will refer to this path and further to the view.
Now we need to create views on which this path will be accessed. We create it in the market application in the views.
Important!
I fixed one of the bugs that I made earlier. Namely, I added the Author to the model and already connected the user to it. Without this, django will not understand who created this or that content.
Also, after you have registered the author, you should pay attention that he is not yet in the database. So it must be added there with two commands.
python manage.py makemigrations
python manage.py migrate
After you run all the migrations correctly and you will succeed. Subsequent courses created will be owned by a specific author. This is a very important fix if you want to expose your site to other course or product creators as well.
Let's go back to our button. And now let's add our author to our form. But so that users do not see it, but at the same time, the author is added to the database when creating content. This is done quite simply.
The author is present in the widgets but not in the fields. This gives us the ability to hide the fillable field from users.
Now we need to display the field data in the html file, which will be launched when the form is accessed.
Let's start by integrating our base template into our html. We also integrate our forms through crispy forms. Well, without fail, we will load static files.
By default, we open the content block. And already in it we create our html markup.
Important! In our form, use this particular version of the form.
Also, in all forms, I would recommend adding a csrf token, as it will allow you to exclude data spoofing.
And of course, our forms. Which will help us display the fields to fill.
And the last thing we need to add is a button to send our information to the database. For checking and recording. And in the future, changes or removals.
Now I propose to test our button and our form. Also create a course. But not through the administrator, but from the user side.
After clicking on the button in the profile, add the course. We get to the form for adding a course. And we can fill in our fields.
I randomly fill in the fields. To add a test course.
After clicking on the add course button, we are sent to the page of the course itself. And we see it just like other users.
Great!
We succeeded and in the next post we will make it possible to correct or delete our data from the user's side.
Thanks for supporting the project.
@rme , @rex-sumon , @shy-fox , @hungry-griffin, @pennsif
The project is being created in partnership with @steemit-market.
Above may be wrong. Since I wrote the code from memory and then corrected it. But git will have no errors.
Link to the git.
You can get acquainted with the project here.
You can find all parts of the projects by the tag: #storeonsteemit
To be continued...
Sincerely, your HardPhotographer
Thank you, friend!


I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
please click it!
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)
The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.
Upvoted! Thank you for supporting witness @jswit.