Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Custom Response Header in Django
So I was wondering on how to build a habit of writing blogs daily, and my friend suggested that we could write about the little things we learn everyday, so we decided to start a series called Today I Learned where we will write about the little things we learn everyday, and thus build a habit I was creating this REST API for one of my clients and I was thinking what is the proof that I made this app, and I was totally blank because only proof I will have is the payment I will be receiving from the client. So I thought, what if I implant something in the response header that will scream that I have created this API or web-app or whatever. In this post, I will be documenting how we can create our own header attribute to responses in Django. Method 1 - Local Header In this you can add a custom header attribute to one response. For example, imaging you are creating an auth APi and you want to send an encrypted token as a response header. For that the view function will be something like this. def auth(req): # DO AUTH RELATED STUFF … -
Deploying and Hosting a Machine Learning Model with FastAPI and Heroku
This tutorial looks at how to deploy a machine learning model, for predicting stock prices, into production on Heroku as a RESTful API using FastAPI. -
Django News - New Django & Python Releases - Jul 3rd 2020
News Django bugfix releases issued: 3.0.8 and 2.2.14 Another bugfix release for Django 3.0 and 2.2. Django 3.1 comes out in August! djangoproject.com Python 3.7.8 and 3.6.11 released The 3.7.8 is expected to be the last bugfix release for the 3.7.x series. Future releases will focus on security fixes. blogspot.com Python Software Foundation News: 2020 Python Software Foundation Board of Directors Election Retrospective and Next Steps blogspot.com Articles Making Django App Publicly Accessible With Ngrok Ngrok is a great way to share your local Django runserver with anyone you give the link to. It makes having demo or testing webhooks locally possible. dev.to Python async frameworks - Beyond developer tribalism From Tom Christie, creator of Django REST Framework, a thoughtful overview of the async Python landscape. encode.io Store Data With Models See how to take data and store it into a database so that your application can use that data or display it later. mattlayman.com How to add a .well-known URL to your Django site A quick guide to what /.well-known/ URLs are and how to create them. adamj.eu How to find what you want in the Django documentation Many beginner programmers find the Django documentation overwhelming. mattsegal.dev Lack of … -
I'm Teaching A Live Online Django Crash Course
Course Announcement On July 16th and 17th of 2020, I'll be running a live instruction of my beginner-friendly Django Crash Course. This is a live interactive class conducted via Zoom conferencing software. We're going to walk through the book together with students. If you get stuck, there will be at least two members of the Feldroy team available to help. Each course day will have two sessions each 3 hours long, as well as an hour-long break between sessions. Attendees Receive Hours of instruction in building web apps by noted authors and senior programmers An invite to both July 16th and July 17th class days The Django Crash Course e-book (if you already bought one, we'll send you a discount code for $19.99 off the online class) Membership in our forthcoming online forums when they are activated Class Prerequisites Basic knowledge of the Python programming language Computer where you are allowed to install software (No work restrictions) Internet fast enough to join online meetings Topics Covered Setting up a development environment Cookiecutter for rapidly accelerating development Django Forms Class-Based Views Models Templates Admin Writing Django tests PyTest Factories Best practices per Two Scoops of Django Proven patterns for avoiding duplication … -
I'm Teaching A Live Online Django Crash Course
Course Announcement On July 16th and 17th of 2020, starting at 9AM PST (4PM UTC), I'll be running a live instruction of my beginner-friendly Django Crash Course. This is a live interactive class conducted via Zoom conferencing software. We're going to walk through the book together with students. If you get stuck, there will be at least two members of the Feldroy team available to help. Each course day will have two sessions each 3 hours long, as well as an hour-long break between sessions. Attendees Receive Hours of instruction in building web apps by noted authors and senior programmers An invite to both July 16th and July 17th class days starting at 9AM PST (4PM UTC) The Django Crash Course e-book (if you already bought one, we'll send you a discount code for $19.99 off the online class) Membership in our forthcoming online forums when they are activated Class Prerequisites Basic knowledge of the Python programming language Computer where you are allowed to install software (No work restrictions) Internet fast enough to join online meetings Topics Covered Setting up a development environment Python 3.8 Django 3.0 Database VS Code Cookiecutter for rapidly accelerating development Django Forms Class-Based Views Models … -
Django Login and Logout Tutorial
In this tutorial we'll learn how to configure login/logout functionality with Django's the built-in [user authentication system](https://docs.djangoproject.com/en/4.0/topics/auth/). This is the first in a three-part series that also covers [signup](https://learndjango.com/tutorials/django-signup-tutorial) and … -
Django File (and Image) Uploads Tutorial
This tutorial shows how to implement file and then image uploading with Django. We'll build a basic Instagram clone. ## Setup Whether you're on a Windows or Mac laptop the … -
Django Markdown Tutorial
[Markdown](https://daringfireball.net/projects/markdown/) is a popular text-to-HTML conversion tool for web writers. It is far easier to use than plain old HTML. Many/most static site generators provide a built-in way to write … -
Django Slug Tutorial
In this tutorial we will add slugs to a Django website. As noted in the [official docs](https://docs.djangoproject.com/en/dev/ref/models/fields/#slugfield): "Slug is a newspaper term. A slug is a short label for something, … -
Django Best Practices: Function-Based Views vs Class-Based Views
Django's use of both function-based views (FBVs) and class-based views (CBVs) causes a lot of confusion for newcomers. Why have multiple ways to do the same thing? And which one … -
The Home Stretch - Building SaaS #63
In this episode, we return to the homeschool application that I’m building. I’m in the final stretch of changes that need to happen to make the product minimally viable. We worked on a template, wrote some model methods, and did a bunch of automated testing. We started by adding students to the context of the students index page. With the students in the context, we updated the index page to display the list of students. -
Do you need a task queue in your web app?
Within your web application, some operations, or “tasks”, take an unpredictable time to run. Others take too long to have them executed within the web application’s request/response cycle. Adding a task queue will allow you to: Run longer-running tasks outside the request-response cycle handled by web framework. Actually gunicorn or uwsgi in a production Django1 setup. Run scheduled tasks by not relying on crontab. This usually entails management commands or other forms of standalone scripts. Each needing all environment variables loaded correctly. Without a task queue Let’s say you want to send an email to a user when they submit a form. The process is shown below2: Figure 1. View sends email directly. No queue. This adds an unpredictable time to the expected response time. I.e. those 1-2 seconds taken to: talk to the email provider, over the network receive a response from the email provider, again over the network With a task queue With the task queue in place, the email sending part is done asynchronously. I.e. The unpredictable part is shifted onto the queue. And we don’t really care how long that takes; that is, for returing a response to the user. In case it fails, many task … -
Giving Django Project a “Two Scoops” Configuration
Years back I bought a physical copy of Two Scoops of Django 1.11 after seeing it highly recommended in a book called Hello Web App by Tracy Osborn.… -
Speed Up Your Django Tests - Adam Johnson
Adam Johnson personal siteSpeed Up Your Django TestsPyCon UK 2016: Cleaner unit testing with the Arrange Act Assert patternDjango Software Foundation Teamstime-machineSHAMELESS PLUGSLearnDjango - Free tutorials and premium books -
[Django Tutorial] Connect MySQL Database in Django Framework
If you are looking forward to connect your MySQL database with python code that check the following guide: In order to connect your MySQL Database in Django Framework, you should do the following: Install MySQL package Configure your settings.py Make Migrations Install MySQL Package First install MySQL via pip from your terminal with the following -
Django Static Files
Static files like CSS, JavaScript, and fonts are a core piece of any modern web application. They are also typically confusing for Django newcomers since Django provides tremendous flexibility around … -
Giving Django Project a “Two Scoops” Configuration
Years back I bought a physical copy of Two Scoops of Django 1.11 after seeing it highly recommended in a book called Hello Web App by Tracy Osborn. Little did I know it was way over my head at the time. With the release of Two Scoops of Django 3.X, and with a lot of recent practice, the book is now only slightly over my head, so I’ve been trying to implement more of the practices recommended in the book. I’ve also been continuing to use Docker and Docker Compose after learning the basics in Django for Professionals by Will Vincent. Fixing Problems? Early on in Two Scoops, the authors discuss how the standard project layout from django-admin startproject leaves a lot to be desired. I definitely have NOT experienced that pain because I don’t have the skills to make any complex projects. I do, however, see the value in getting comfortable with a new layout. It teaches you how some of the module inheritance in Django works. Python import statements are one of the most challenging things for me, personally, so this is a good way to train your coding skills. Let’s talk about two different project layouts. Standard … -
Huey as a minimal task queue for Django
Are you considering adding a task quee to your Django project? Then this article should be useful to you. Adding a task queue will allow you to: Run longer-running processes outside the request-response cycle handled by Django. Actually gunicorn or uwsgi in production. Run scheduled tasks by not relying on crontab. This usually entails management commands or other forms of standalone scripts. Each needing all environment variables loaded correctly. When I was “younger” task queue with Django project meant celery task queue. Now that I’m “older” there are simpler alternatives. The simplest I found was Huey. But the ideas presented here apply to evaluating all task queues for your Django project. Background Frustrated with celery and django-celery In December 2019 I was taking a Django project from Python 2 to 3. This project relied on celery and its integration for Django for asynchronous task processing. Github project link here. This work was mostly done back in 2012-2015. celery’s “Django integration” part was the first problematic part. “Problematic” in the sense that it was not being actively maintained. And Python 3 support was only “planned” at the time. Besides, by testing celery with my Python3 setup I realised how “heavy” it … -
July 16th and 17 Live Instruction of our Django Crash Course
The authors of Two Scoops of Django are offering live instruction of the Django Crash Course. This isn't a live stream, but a Zoom-powered class that isn't going to be recorded. We're going to walk-through the book together with students. If you get stuck, there will be at least two members of the Feldroy team available to help. Each course day will be seven hours long, including an hour-long break for lunch. Attendees will receive: Hours of instruction in building web apps by noted authors and senior programmers An invite to both July 16th and July 17 class days The Django Crash Course e-book (if you already bought one, we'll send you a discount code for $19.99 off the online class) Membership in our forthcoming online forums Class prerequisites: Basic knowledge of the Python programming language Computer with permissions to install software Internet fast enough to join online meetings We're selling the course for the introductory price of just $99 and space is limited, so register today! -
July 16th and 17th Live Instruction of our Django Crash Course
The authors of Two Scoops of Django are offering live instruction of the Django Crash Course. This is a live interactive class conducted via Zoom conferencing software. We're going to walk-through the book together with students. If you get stuck, there will be at least two members of the Feldroy team available to help. Each course day will have two sessions each 3 hours long, as well as an hour long break between sessions. Attendees will receive: Hours of instruction in building web apps by noted authors and senior programmers An invite to both July 16th and July 17th class days, starting at 9AM PST (4PM UTC) The Django Crash Course e-book (if you already bought one, we'll send you a discount code for $19.99 off the online class) Membership in our forthcoming online forums when they are activated Class prerequisites: Basic knowledge of the Python programming language Computer where you are allowed to install software (No work restrictions) Internet fast enough to join online meetings Topics Covered: Setting up a development environment Cookiecutter for rapidly accelerating development Django Forms Class-Based Views Models Templates Admin Writing Django tests PyTest Factories Best Practices the Two Scoops of Django Way Proven patterns … -
July 15th, 16th and 17th Live Instruction of our Django Crash Course
The authors of Two Scoops of Django are offering live instruction of the Django Crash Course. This is a live interactive class conducted via Zoom conferencing software. We're going to walk-through the book together with students. If you get stuck, there will be at least two members of the Feldroy team available to help. Each course day will have two sessions each 3 hours long, as well as an hour long break between sessions. Attendees will receive: Hours of instruction in building web apps by noted authors and senior programmers An invite to both July 16th and July 17th class days, starting at 9AM PST (4PM UTC) The Django Crash Course e-book (if you already bought one, we'll send you a discount code for $19.99 off the online class) Membership in our forthcoming online forums when they are activated Class prerequisites: Basic knowledge of the Python programming language Computer where you are allowed to install software (No work restrictions) Internet fast enough to join online meetings Topics Covered: Setting up a development environment Cookiecutter for rapidly accelerating development Django Forms Class-Based Views Models Templates Admin Writing Django tests PyTest Factories Best Practices the Two Scoops of Django Way Proven patterns … -
Where Does the Data Go?
Full show notes are available at https://www.mattlayman.com/django-riffs/6. -
Episode 6 - Where Does the Data Go?
On this episode, we will learn about storing data and how Django manages data using models. Listen at djangoriffs.com. Last Episode On the last episode, we saw Django forms and how to interact with users to collect data. Setting Up A relational database is like a collection of spreadsheets. Each spreadsheet is actually called a table. A table has a set of columns to track different pieces of data. Each row in the table would represent a related group. -
Deploying Django to AWS with Docker and Let's Encrypt
In this tutorial, we'll deploy a Django app to AWS EC2 with Docker and Let's Encrypt. -
Why does Python raise ModuleNotFoundError when modifying Django's INSTALLED_APPS?
Imagine we are installing the third party package django-cors-headers, which I maintain. Step one in its installation process is to install the package, so we run the command: python -m pip install django-cors-headers Step two is to add the module to our settings file’s INSTALLED_APPS. We might add it between the the Django contrib apps and our project’s own core app: INSTALLED_APPS = [ # Django contrib apps "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.sites", "django.contrib.humanize", # Third-party apps "corsheaders" # Project apps "example.core" ] Unfortunately with the above INSTALLED_APPS has a bug. Can you spot it? It causes Python to raise the following ModuleNotFoundError when trying to run the server: $ python manage.py runserver Exception in thread django-main-thread: Traceback (most recent call last): File "/.../python3.8/threading.py", line 932, in _bootstrap_inner self.run() ... File "/.../site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/.../site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) File "/.../site-packages/django/apps/config.py", line 116, in create mod = import_module(mod_path) File "/.../python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1014, …