Online store on Steemit blockchain| Step four | Super user and admin panel, as well as template and git

in Steem Alliancelast year

Hello, friends!

Step 04.jpg

Today we will start by creating two directories. The first directory will be called template. And the second will be for static data.

Screenshot_24.png

Let's create a market folder in the statics directory. This name is the same as the name of our application. This is done on purpose so that the Django library does not get confused in applications and files in the future.

Screenshot_29.png

We will send all html files to the folder with the name templates, and send js and css to the static folder.

Screenshot_32.png

As we can see all the files are loaded, as well as the start page of our site.
Now we need to write a small view in the views file so that the Django library understands what needs to be displayed first.

Screenshot_33.png

I will not post the code because there is quite a lot of information. It will be at the link at the very bottom of git.
Now in the urls file we will write our path to the file, as well as import the desired function.

Screenshot_34.png

Now we write our html code in the index.html file.

Screenshot_35.png

I don't think much work needs to be done on the code. And to start with, it needs to be adapted to Django. And also not much to change the styles. Styles will change to our preferences.

Screenshot_36.png

This is a required adaptation. Without this adaptation, your application will not work. We will do the same a little later with js files.
Now let's get into the css bootstrap a little and change the color to the one that we prefer.

Screenshot_37.png

In our case, we need to replace the black background. Most likely banana. By creating a new style.

Screenshot_39.png

And don't forget to change our style in the index.html file.

Screenshot_40.png


Now let's add the logo. And for this we need the command:

python manage.py collectstatic

Screenshot_41.png

We can see that our static files were created in a separate folder from where Django will take all the media.

Screenshot_42.png

Now we can add our image to the main page.

Screenshot_43.png

And we get such a beautiful result.
Was

Screenshot_44.png

Became

Screenshot_45.png

Now our template is displayed and the paths are set. It remains to create a super user so that Django will create a default admin panel for us.

In order to create a super user, you need to register the following command in the terminal:

python manage.py createsuperuser

Screenshot_46.png

And fill in the fields that appear.

Screenshot_47.png

Now we can test our admin panel. By following the link:

http://127.0.0.1:8000/admin


And enter our username and password.

Screenshot_48.png

After passing the authorization, we will see such a panel. And at the moment there is really nothing in it. But soon we will add our model there and much more.

Screenshot_49.png



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.

This is the first part: Step one
This is the second part: Step two
This is the third part: Step three

To be continued...

Sincerely, your @HardPhotographer

Sort:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(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.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64303.16
ETH 3137.29
USDT 1.00
SBD 3.97