DEV Community

Cover image for Is it possible to code while learning something new? Of course, it’s more fun.
Nicholas
Nicholas

Posted on

Is it possible to code while learning something new? Of course, it’s more fun.

Hey guys;)
Long time no see.

General

Actually I wanna change my blog format. Now I’m planning to do a few posts on X, and then 1-2 times per week do a big post here. And I wanna try not only to show what I’ve done, but also how to do it. Some kind of teaching I don’t know yet.

New project. What is it about?

Okay, so since my last post I’ve finished Yakaboo Sales Analysis. You could check it here - Yakaboo Project.
The new project is basic - it’s Secret Santa. But if I wrote just an algorithm it wouldn't be so interesting. So I decided to add Django here and make some websites. But here was a problem, I’ve never worked with Django before. But thanks to Corey Schafer I learnt some basics and even built something. I’ll show the video in the end.

A bit about Django

So it’s a great framework which allows us to build websites using Python. In the beginning I thought that I’ll explain almost everything that I’ve learnt, but I don’t think it’s necessary. So in short, to begin writing you should do

  1. Create a project directory and venv (of course you could do it without venv).
  2. Install Django.
  3. Create the project using django-admin startproject name_of_project.
  4. Create an app using django-admin startapp name_of_app

After that we could do what we wanted.

Another amazing library

One of my favorite libraries is Faker, which allows generating data. I used it for creating participants (their full name, email and wishlist) for a party. That was the easiest part, after that I started exploring Django. So, I’ll skip all the theories and say only the most important.

  • To write html and css inside the app directory you need to create templates (for html) and static (for css and js, about js I’m not sure), and inside these directories create a folder with the same name as app name.
  • Inside the views.py file you create a function which returns html response and gives arguments which we could use inside html.
  • After creating views functions you could use it in the url of the app, add a pattern to the project and don’t forget to add the app into project settings.

Okay now it’s time to watch some results for now.
Link to video
See you in the next post. I hope it was interesting to read.

Top comments (1)

Collapse
 
technogamerz profile image
𝐓𝐡𝐞 𝐋𝐚𝐳𝐲 𝐆𝐢𝐫𝐥

Interesting 😎