Django Unleashed Framework
1.42K subscribers
2.21K photos
1 video
2.64K links
Лучшие материалы по разработке на фреймворке Django на русском и английском языке

Разместить рекламу: @tproger_sales_bot

Правила общения: https://tprg.ru/rules

Другие каналы: @tproger_channels

Другие наши проекты: https://tprg.ru/media
Download Telegram
Flask vs Django: Which Python framework is right for you?

What are web frameworks?
Like other major programming languages, Python employs software platforms unique to it called web frameworks. Web frameworks act as the premade skeleton of a website because developers, both front-end and back-end, do not wan...

Read: https://rahul7171.hashnode.dev/flask-vs-django-which-python-framework-is-right-for-you
Introducing Myself

Hey There! Welcome to my blog. My name is Tosin, a student in the Department of Computer Science at the University of Lagos, Nigeria, and someone who is passionate about technology.
How I started
My journey with technology started a lot of time ago....

Read: https://tosin1.hashnode.dev/introducing-myself
Material Kit - Open-Source Django Starter

Hello Coders!
This article presents an open-source Django Starter crafted on top of Material Kit, a really nice Bootstrap 5 design (also free). The product can be downloaded from Github (MIT License) and used for commercial projects or eLearning act...

Read: https://app-generator.hashnode.dev/material-kit-open-source-django-starter
👍1
Django News - Integrating Zapier and Django and Django Unicorn 0.45 - Apr 22nd 2022

Read: https://django-news.com/issues/124
👍1
Парсинг для взрослых или Инфраструктура для промышленного парсинга

В студенческие годы я написал на заказ много парсеров магазинов и социальных сетей. Со временем парсеры усложнялись и из скриптов превращались в полноценные веб-приложения c базой данных и Rest API. В статье описан шаблон веб-приложения, который использую для создания парсеов.


Читать: https://habr.com/ru/post/662928/
👍3
Handle Timezone with Django

A truth for people all around the world is that we experience time differently.
Trying to have the same time in your application for all users will not reflect real-time in their zone and mostly trying to register their different times in your datab...

Read: https://koladev.hashnode.dev/handle-timezone-with-django-cl2fqx37b01rxy8nvbnj5df3z
👍1
Django 4.1 adds async-compatible interface to QuerySet

The much-awaited pull request for an async-compatible interface to Queryset just got merged into the main branch of Django.

Pull Request - https://github.com/django/django/pull/14843
The Django core team has been progressively adding async support to the framework. Asynchronous views and middlewares were part of the Django 3.1 release and with the latest changes now Django ORM will be …

Read: http://djangocentral.com/django-adds-async-compatible-interface-to-queryset/
👍4
Electron + Django, desktop app integrate JavaScript & Python

Introduction & Concept
Building a desktop app from Electron and Django is actually building a web application, which uses Electron as the front-end by a local browser and Django as the backend.

Then, why do we need to build the desktop application i...

Read: https://ivanyu2021.hashnode.dev/electron-django-desktop-app-integrate-javascript-and-python
10 лучших фреймворков для веб-разработки на Python

Евгений Бартенев, автор курса по Python в Яндекс Практикуме, подготовил список лучших Python-фреймворков для веб-разработки в 2022 году.

Читать: «10 лучших фреймворков для веб-разработки на Python»
‘The client noticed that the server is not a supported distribution of Elasticsearch‘ error and solution

The django project is running very well, but suddenly the interface query error.
{
“code”: 400102,
“message”: “请求错误”,
“data”: {
“detail”: “The client noticed that the server is not a supported distribution of Elasticsearch”
}
}

Search Baidu the...

Read: https://keithblog.io/the-client-noticed-that-the-server-is-not-a-supported-distribution-of-elasticsearch-error-and-solution-1
Django News - Asynchronous QuerySets coming to Django 4.1 and PyCon US - Apr 29th 2022

Read: https://django-news.com/issues/125
Django News - Asynchronous QuerySets coming to Django 4.1 and PyCon US - Apr 29th 2022

Read: https://django-news.com/issues/125
👍2
Introduction to building web application with Django

Django is a Python-based web framework aimed at building web apps quickly and error-free. Built with ready-made components (saving you from the hassle of installation and dependencies problems that come with other frameworks) and a massive community,...

Read: https://tosin1.hashnode.dev/introduction-to-building-web-application-with-django
👍1
Creating A Custom User Model In Django

from django.contrib.auth.models import User
The Python framework Django, has a built in user model as shown above which comes with a number of features making development faster and easier but in my opinion isn't very useful, this model has a number ...

Read: https://lyrx.hashnode.dev/creating-a-custom-user-model-in-django
👍6
How to Deploy Your Django App To PythonAnywhere

Pythonanywhere allows you to host your python web apps at low costs. It provides beginner features which allows you to test run your web application on a live server.
Go to www.pythonanywhere.com

Now Proceed to create a new beginner's account, thi...

Read: https://steelthedev.hashnode.dev/how-to-deploy-your-django-app-to-pythonanywhere
Django Charts via DRF and Chart.js - Step-by-Step Tutorial

Hello Coders!
Django is a powerful web framework built with Python that you can use to create fully functional web applications or web APIs. This article explains step-by-step how to showcase three different charts (pie, line, and bar chart) using D...

Read: https://app-generator.hashnode.dev/django-charts-via-drf-and-chartjs-step-by-step-tutorial
👍1
Jobs At * ReadTheDocs * April 2022 * Product-focused Application Developer

Job Posting: Product-focused Application Developer
Location: Fully remote
Timezone: UTC-8 to UTC+1
Schedule: 4 or 5 days
Salary: $60,000-$90,000
Status: Contractor
Experience: 3+ years in a software-related job
Thanks for your interest in working at ...

Read: https://kb.mdmdm.org/jobs-at-readthedocs-april-2022-product-focused-application-developer
Django Cheat Sheet

Here are some common commands you'll use while working with Django. If you can think of anything I should add, let me know!
Creating a New Project
django-admin startproject projectname

Read: https://chuckygari.hashnode.dev/django-cheat-sheet
👍3
Как загружать файлы и изображения в приложении Django

Подготовка проекта

Для начала создайте каталог, в котором будут находиться проект и виртуальная среда (она нужна, чтобы отделять проектные зависимости от операционной системы).

Теперь выполните команду cdна этот каталог и сформируйте виртуальную среду:
mkdir filesDjango
cd filesDjango
python3.8 -m venv env

Активируйте ее и туда же установите Django:
source env/bin/activate

pip install Django

Создайте новый проект Django и назовите его file uploads:
django-admin startproject fileuploads
В каталоге данного проекта создайте приложение с именем files. Приложения в Django используются для разделения различных компонентов и необходимы для масштабирования самих приложений. Они также являются перемещаемыми элементами и их можно перетащить в другой проект Django, не ломая код.
django-admin startapp files
Добавьте файлы приложения к списку установленного софта в файле settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'files',
]

Django сохраняет файлы локально с помощью параметров MEDIA_ROOTи MEDIA_URL.

Определим эти константы в файле settings.py.:
import os

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

MEDIA_ROOTбудет использоваться для управления сохраненными данными, а MEDIA_URL—  как url данных, которые требуется предоставить.

Загрузка данных

Самый простой вариант  —  загружать файлы с помощью FileFields. Начните с создания простой модели в файле models.py, которая будет содержать три поля: имя, электронную почту и файл для загрузки.
from django.db import models

# Создайте модели здесь.

class Resume(models.Model):
email = models.EmailField()
name = models.CharField(max_length= 255, blank=False, null=False)
file = models.FileField(upload_to= 'files/',null=True)

def __repr__(self):
return 'Resume(%s, %s)' % (self.name, self.file)

def __str__ (self):
return self.name

Параметр upload_toуказывает, куда будут перемещены файлы.

Запуск миграций

Миграции создадут актуальные таблицы в базе данных.
python3.8 manage.py migrate
Формы

Django имеет встроенный класс ModelForm, позволяющий легко создавать формы из модельных полей. Создайте новый файл forms.pyи добавьте код:
from django import forms
from .models import Resume

class ResumeForm(forms.ModelForm):

class Meta:
model = Resume
fields = ['email','name','file']

Определив форму, вы получите данные из нее с помощью request.FILES, используя запрос POSTв представлении. Чтобы получить данные, содержащиеся в форме, откройте файл view.pyи напишите следующий код:
from django.shortcuts import render
from django.http import HttpResponseRedirect
from .forms import ResumeForm

# Создайте здесь представления.

def upload_resume(request):
if request.method == 'POST':
form = ResumeForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return HttpResponseRedirect("/")
else:
form = ResumeForm
return render(request, 'files/resume.html', {'form':form})

В вышеизложенном коде проверьте, чтобы метод запроса был POST, затем получите данные из формы, проверьте их и сохраните в базе данных. Если метод запроса  — GET, то отобразите форму в шаблоне.

Мы еще не создали шаблон upload.html(Django автоматически найдет его в соответствующем каталоге), с помощью которого будет отображена форма, так что давайте приступим. Создайте файлы, как показано ниже:
templates/
files/
-upload.html

Для отп[...]
👍3
HTML Template to PDF in Django

In this tutorial you will learn how to create a pdf from a HTML template using Django.
This may be very useful if you need to create an app that automize pdf generation. For this you can create a Django form, pass as context all the variables you wan...

Read: https://carlosenriquesalas.hashnode.dev/html-template-to-pdf-in-django
A simple approach for background task in Django

Introductino & Proof-Of-Concept
When there is a long running task, there are usually below 2 requirements:

As a user, I want to know the progress of the task
As a user, I want to get the output of the task if it is finished

We will use the out of t...

Read: https://ivanyu2021.hashnode.dev/a-simple-approach-for-background-task-in-django