Skip to content

Commit cd02028

Browse files
Merge branch 'master' into maintenance/python-itertools-20260918
2 parents 55fa111 + 051c133 commit cd02028

176 files changed

Lines changed: 10653 additions & 967 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎celery-async-tasks/README.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,28 @@
33
Example project for integrating Celery and Redis into a Django application.
44
This repository holds the code for the Real Python [Asynchronous Tasks With Django and Celery](https://realpython.com/asynchronous-tasks-with-django-and-celery/) tutorial.
55

6-
## Setup (macOS)
6+
## Setup
77

8-
To try the project, set up a virtual environment and install the listed dependencies:
8+
The project targets Linux and macOS. Celery doesn't support Windows.
9+
10+
To try the project, set up a virtual environment with Python 3.12 or newer and install the listed dependencies:
911

1012
```sh
1113
$ python -m venv venv
1214
$ source venv/bin/activate
1315
(venv) $ python -m pip install -r requirements.txt
1416
```
1517

16-
You'll also need to install Redis on your system:
18+
You'll also need to install Redis on your system.
19+
20+
On Linux (Debian or Ubuntu):
21+
22+
```sh
23+
$ sudo apt update
24+
$ sudo apt install redis
25+
```
26+
27+
On macOS with [Homebrew](https://brew.sh/):
1728

1829
```sh
1930
$ brew install redis
@@ -46,4 +57,4 @@ $ redis-server
4657
(venv) $ python -m celery -A django_celery worker -l info
4758
```
4859

49-
When all three processes are running, you can go to `localhost:8000/` and submit a feedback response. Celery will simulate a work-intensive process and send an email at the end of it. You'll see the email message show up in the log stream on the terminal window where the Celery worker is running.
60+
When all three processes are running, you can go to `http://localhost:8000/` and submit a feedback response. Celery will simulate a work-intensive process and send an email at the end of it. You'll see the email message show up in the log stream on the terminal window where the Celery worker is running.
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
amqp==5.3.1
2-
asgiref==3.8.1
3-
billiard==4.2.1
4-
celery==5.4.0
5-
click==8.1.7
1+
amqp==5.4.0
2+
asgiref==3.12.1
3+
billiard==4.3.0
4+
celery==5.6.3
5+
click==8.5.0
66
click-didyoumean==0.3.1
7-
click-plugins==1.1.1
8-
click-repl==0.3.0
9-
Django==5.1.3
10-
kombu==5.4.2
11-
prompt_toolkit==3.0.48
7+
click-plugins==1.1.1.2
8+
click-repl==0.4.0
9+
Django==6.1.1
10+
kombu==5.6.2
11+
packaging==26.3
12+
prompt_toolkit==3.0.53
1213
python-dateutil==2.9.0.post0
13-
redis==5.2.0
14-
six==1.16.0
15-
sqlparse==0.5.2
16-
tzdata==2024.2
14+
redis==8.1.0
15+
six==1.17.0
16+
sqlparse==0.6.0
17+
typing_extensions==4.16.0
18+
tzdata==2026.4
19+
tzlocal==5.4.4
1720
vine==5.1.0
18-
wcwidth==0.2.13
21+
wcwidth==0.9.1
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
amqp==5.3.1
2-
asgiref==3.8.1
3-
billiard==4.2.1
4-
celery==5.4.0
5-
click==8.1.7
1+
amqp==5.4.0
2+
asgiref==3.12.1
3+
billiard==4.3.0
4+
celery==5.6.3
5+
click==8.5.0
66
click-didyoumean==0.3.1
7-
click-plugins==1.1.1
8-
click-repl==0.3.0
9-
Django==5.1.3
10-
kombu==5.4.2
11-
prompt_toolkit==3.0.48
7+
click-plugins==1.1.1.2
8+
click-repl==0.4.0
9+
Django==6.1.1
10+
kombu==5.6.2
11+
packaging==26.3
12+
prompt_toolkit==3.0.53
1213
python-dateutil==2.9.0.post0
13-
redis==5.2.0
14-
six==1.16.0
15-
sqlparse==0.5.2
16-
tzdata==2024.2
14+
redis==8.1.0
15+
six==1.17.0
16+
sqlparse==0.6.0
17+
typing_extensions==4.16.0
18+
tzdata==2026.4
19+
tzlocal==5.4.4
1720
vine==5.1.0
18-
wcwidth==0.2.13
21+
wcwidth==0.9.1

‎create-django-project/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "django-setup"
33
version = "0.1.0"
44
requires-python = ">=3.12"
55
dependencies = [
6-
"django>=6.0",
6+
"django>=6.1",
77
]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
asgiref==3.11.0
2-
django==6.0
3-
sqlparse==0.5.4
1+
asgiref==3.12.1
2+
django==6.1.1
3+
sqlparse==0.6.0

‎create-django-project/setup/setup/asgi.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the ASGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/
7+
https://docs.djangoproject.com/en/6.1/howto/deployment/asgi/
88
"""
99

1010
import os

‎create-django-project/setup/setup/settings.py‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
22
Django settings for setup project.
33
4-
Generated by 'django-admin startproject' using Django 6.0.
4+
Generated by 'django-admin startproject' using Django 6.1.1.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/6.0/topics/settings/
7+
https://docs.djangoproject.com/en/6.1/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/6.0/ref/settings/
10+
https://docs.djangoproject.com/en/6.1/ref/settings/
1111
"""
1212

1313
from pathlib import Path
@@ -17,7 +17,7 @@
1717

1818

1919
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
2323
SECRET_KEY = (
@@ -72,7 +72,7 @@
7272

7373

7474
# Database
75-
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
75+
# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
7676

7777
DATABASES = {
7878
"default": {
@@ -83,7 +83,7 @@
8383

8484

8585
# Password validation
86-
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
86+
# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
8787

8888
AUTH_PASSWORD_VALIDATORS = [
8989
{
@@ -102,7 +102,7 @@
102102

103103

104104
# Internationalization
105-
# https://docs.djangoproject.com/en/6.0/topics/i18n/
105+
# https://docs.djangoproject.com/en/6.1/topics/i18n/
106106

107107
LANGUAGE_CODE = "en-us"
108108

@@ -114,6 +114,16 @@
114114

115115

116116
# Static files (CSS, JavaScript, Images)
117-
# https://docs.djangoproject.com/en/6.0/howto/static-files/
117+
# https://docs.djangoproject.com/en/6.1/howto/static-files/
118118

119119
STATIC_URL = "static/"
120+
121+
122+
# Email
123+
# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
124+
125+
MAILERS = {
126+
"default": {
127+
"BACKEND": "django.core.mail.backends.console.EmailBackend",
128+
},
129+
}

‎create-django-project/setup/setup/urls.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
URL configuration for setup project.
33
44
The `urlpatterns` list routes URLs to views. For more information please see:
5-
https://docs.djangoproject.com/en/6.0/topics/http/urls/
5+
https://docs.djangoproject.com/en/6.1/topics/http/urls/
66
Examples:
77
Function views
88
1. Add an import: from my_app import views

‎create-django-project/setup/setup/wsgi.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/6.1/howto/deployment/wsgi/
88
"""
99

1010
import os

‎generate-images-openai/README.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generate Images in Python With OpenAI's GPT Image API
2+
3+
Learn to use the OpenAI Python library to create images with the GPT Image models. In the associated tutorial on [generating images with the OpenAI API](https://realpython.com/generate-images-openai/), you'll create images from text prompts, tune the size and quality of your results, and edit an image with a follow-up prompt. You'll learn how to interact with the Images API and incorporate this functionality into your Python scripts.
4+
5+
## Setup
6+
7+
Create and activate a virtual environment, then install the `openai` package:
8+
9+
```console
10+
$ python --version
11+
Python 3.14.6
12+
$ python -m venv venv
13+
$ source venv/bin/activate
14+
(venv) $ python -m pip install openai==3.13.0
15+
```
16+
17+
You need to be on Python 3.10 or higher.
18+
19+
The scripts read your API key from the `OPENAI_API_KEY` environment variable:
20+
21+
```console
22+
(venv) $ export OPENAI_API_KEY="<your-key-value-here>"
23+
```
24+
25+
## Create and Edit Images
26+
27+
Follow the instructions in [the tutorial](https://realpython.com/generate-images-openai/) to create images from text prompts, edit an image with a follow-up prompt, and convert a Base64 JSON response to a PNG image file.
28+
29+
You can find the code for each of these steps in dedicated scripts:
30+
31+
- `create_png.py`: Create an image from a text prompt and write it straight to a PNG file.
32+
- `create.py`: Create an image from a text prompt and save the whole JSON response to a file.
33+
- `convert.py`: Convert a Base64-encoded PNG image delivered in a JSON response to a PNG image file.
34+
- `edit.py`: Read Base64-encoded image data and make an API request to edit that image with a prompt.
35+
36+
In the tutorial, you'll walk through each of these scripts and their functionality and output in more detail.
37+
38+
Note that `convert.py` and `edit.py` read a saved response from the `responses/` directory. Run `create.py` first, then update the `JSON_FILE` and `SOURCE_FILE` constants to match the filename that it wrote.
39+
40+
## A Note on Models
41+
42+
The GPT Image models replaced DALL·E, which OpenAI [retired on May 12, 2026](https://developers.openai.com/api/docs/deprecations) along with the image variations endpoint. These scripts call `gpt-image-2.5-flare`.
43+
44+
OpenAI retires image models on a regular schedule, so if a script starts failing with a message like `The model 'gpt-image-2.5-flare' does not exist`, then check the deprecations page and swap the model name.

0 commit comments

Comments
 (0)