Passing a QR code as an SVG code
This tiny project will generate a QR code for any text and pass it to the HTML template as an SVG code.
SVG is a very convenient medium for URLs or other text. This small demo demonstrates a few things:
In this tutorial, we will create several cards with Bootstrap and allow some commands such as changing color and deleting.
What you will learn:
We assume you have Python 3 and Django installed on your computer, and start by creating a new Django project using well-known commands:
django-admin startproject cards
python manage.py startapp app
In this tutorial, we don’t care about databases, so we don’t need to migrate or something like that. …
Learn by doing
We will write a Sales Orders Management System using Django REST for the back-end, and React JS for the front-end. We will add authentication with JWT and will cover the back-end with tests.
We will also use the CDN version of React JS, not the “create-react-app”. This will simplify the development, as we WILL NOT need to run two servers: one for Django and one for React.
Of course, we will be using Functional Components in React.
Bonus: Sweet Alerts for beautiful animation :)
Takeaways: complete project source code on GitHub
Even “Senior” developers often forget to use indexes in Django. You can’t imagine how faster it can get if you simply add two lines of code into your model!
In this article we will take measurements together: with and without indexes.
Our patient will be a small Django application with just 7 fields.
I will just show the model here:
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
code0 = models.CharField(max_length=100, blank=True)
code1 = models.CharField(max_length=100, blank=True)
code2 = models.CharField(max_length=100, blank=True)
code3 = models.CharField(max_length=100, blank=True)
code4 = models.CharField(max_length=100, blank=True)
We have a lot of CharFields. No indexes.
We will be testing…
Step by step guide to writing Tetris in Python with PyGame
In this tutorial, we will write a simple Tetris using the PyGame library in Python. The algorithms inside are pretty simple but can be a little challenging for the beginners. We will not concentrate on PyGame mechanics too much, but rather focus on the game logic. If you are too lazy to read all the stuff, you may simply copy and paste the code in the end.
In this tutorial, we will generate a PDF report and serve it to the front end.
We start by creating a Django project:
// create a Django project named pdfreport:
django-admin startproject pdfreport
// go to the new folder
// create a new environment
python3 -m venv venv
// activate this environent
// create an App for our project
python manage.py startapp app
// Install Django and FPDF2 in this environment
pip install django
pip install fpdf2
Open this folder in your IDE and create some initial functions.
First, we want to use HTML templates, so…
Server-side rendered charts without API complications
What makes your Django project more beautiful? Charts!
We start by templating one of my GitHub repo that was mentioned in my other article https://github.com/timurbakibayev/django_bootstrap_admin
By doing so, we immediately get a beautiful bootstrap template with login functionality. Chart.js is already included in the package.
After templating it, we need to:
pip install -r requirements.txt --upgrade
This will guarantee your success
I am a professor at the university, and students often ask me, how to become a Senior Developer. The answer is complicated, but there are 3 Tools that help you achieve this.
Every time you start a new Django project, what you do is:
And then you create your models etc.
I did this project init for you :)
As a basis, I have taken a free Bootstrap template SB Admin 2 from here: https://startbootstrap.com/theme/sb-admin-2
It’s a free beautiful template that is suitable in most cases when you write a Django project.
What you get for free there is:
A quick tip: How to reuse the Django built-in authentication forms
Do you need to authenticate your users but don’t want to write HTML with CSS, add views for that, and add that view to the urls.py?
I know this feeling, and I am here to help you!
Most probably, you already have this path in your url patterns:
And now, just add this to any of your views:
So, if the user is not authenticated, he/she will be redirected to the default login view of the Django system, and then…
Professor, Ph.D. in CS, Almaty Management University