Online store on Steemit blockchain| Step nine | Full product card and activate absolute links.

in Steem Alliancelast year

Hello, friends!

Step 09.jpg

Today we will create a full description of the course, as well as write a small code on the backend in order to create links to our courses and make the menu work as it should.

Let's start by creating a file in which our full description of the course will be created. I have it called: views_product.html.

Screenshot_32.png

Now we add statistics and open the content block by which django will understand what exactly he needs to display on the page.

Screenshot_33.png

Now we move on to html and css adding markup and styles.

Screenshot_34.png

It is also worth paying attention to the fact that we start with container markup, and not with main. We do not add it because it is already in our default base template. This is done in order to have as little repetitive code as possible.

Now let's move on to adding django variables. Which were created in our model and will have to be worked out in the view. To do this, go to the file view.

Screenshot_35.png

Everything is standard. In parentheses, we enter the name of the model and then, through a dot, what we want to derive from this model.

Now let's move on to creating the view. And also create a link to the full description of the course.

Screenshot_36.png

We create a class in which we specify the model with which we will work. And also specify the html file template which we will use. And we pass the context itself.

Screenshot_37.png

We also use Django's standard DetailView function, which we import from django.views.generic import ListView, DetailView.

Now we create a link to our full course in the urls.py file.

Screenshot_39.png

And also do not forget to carry out the necessary view imports.

Screenshot_40.png

Ready!
Our static page of the full course is ready and now we can see the created courses at the link:
http://127.0.0.1:8000/market/category/course-for-beginner-python-developers

Screenshot_41.png

What do we have in the full version of the course?
Title
Short description
Course cover
Course Difficulty Level
Time to be spent on the course
Full course description
Course price
And the buy button

After we create another application that will contain users, a model will be created there, and then the teacher's card. Which we will also display on the full course page.
Let's go back a little to our backend and write a rather small piece of code there in order to make our title and more buttons active.
Go to the model and import the standard django library.

Screenshot_42.png

Next, we write get_absolute_url for all sections that need active links.

Screenshot_43.png

Screenshot_44.png

In the return itself, we write our model slug, as well as the context of the model.

Now in the files where active links are needed, we write our get_absolute_url. It looks like this.

Screenshot_45.png

After such simple manipulations, our cover, as well as the title and the more button become active and when you click on them, you can get to the full course description.

Screenshot_46.png


Now we create automatic links in our menu. Go to our navbar and iterate over our menu with the addition.

Screenshot_47.png

We also need to create a view. For our categories with the output of the data we need.

Screenshot_48.png

We create a class and specify the ListView in it, which was previously imported along with the DetailView.
In the class, we specify the html template, as well as the context.
Now let's go to the urls .py file to create the universal category link.

Screenshot_49.png

Ready! Our menu works, our links work. Now you can create and edit your product through the admin panel, and your users will be able to see all your menu categories, as well as see what is in the categories themselves and a full description of your course or product.

Screenshot_50.png

As we can see the link has changed when clicking on: http://127.0.0.1:8000/category/python
Which tells us that now only products from the Python category are displayed.

Screenshot_51.png


In the next post, we will create user applications in order to provide more advanced features. Since the standard features of Django will not suit us and there is no way to supplement the functionality.

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.

steem blockchain.jpg

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

Sort:  

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.033
BTC 64243.42
ETH 3152.93
USDT 1.00
SBD 4.28