🆕 New: The documentation website is now available here. It includes reasons for using the application, its features, and detailed configuration instructions.
⚠️ IMPORTANT: If upgrading from a version before 2.x.x, please note significant database changes were introduced in version 2.0.0. Please read the migration guide before updating. Version 3.x.x introduces the ability to send email reminders for appointments using Django Q for efficient task scheduling. It also allows clients to reschedule appointments if it is allowed by admins.
Django-Appointment is a Django app engineered for managing appointment scheduling with ease and flexibility. It enables users to define custom configurations for time slots, lead time, and finish time, or use the default values provided. This app proficiently manages conflicts and availability for appointments, ensuring a seamless user experience.
For a detailed walkthrough and live example of the system, please refer to this tutorial.
Detailed documentation can be found in the docs' directory. For changes and migration information, please refer to the release notes here and here.
See the release notes. For older version, see their release notes.
Install Django-Appointment in your project using pip:
pip install django-appointment
Add "appointment" to your INSTALLED_APPS
setting like so:
INSTALLED_APPS = [
# other apps
'appointment',
]
Then, incorporate the appointment URLconf in your project's urls.py
:
from django.urls import path, include
urlpatterns = [
# other urls
path('appointment/', include('appointment.urls')),
]
In your Django's settings.py
, append the following:
AUTH_USER_MODEL = 'models.UserModel' # Optional if you use Django's user model
For instance, if you employ a custom user model called UserClient
in an app named client
, you would add it like:
AUTH_USER_MODEL = 'client.UserClient'
But if you're using the default Django user model (like most of us), there's no need to add this line since Django automatically sets it to:
AUTH_USER_MODEL = 'auth.User'
Ensure your create_user
function includes the following arguments, even if they are not all used (in case you're
using a custom user model with your own logic for creating users):
def create_user(first_name, email, username, last_name=None, **extra_fields):
pass
This function will create a passwordless user. After doing so, a link to set the password will be sent to the user's email upon completing the appointment request.
Another variable that is worth configuring is the website's name in your settings.py
:
APPOINTMENT_WEBSITE_NAME = 'Chocolates'
It will be used in the footer of the emails sent to clients upon scheduling an appointment:
<p>® 2023 {{ APPOINTMENT_WEBSITE_NAME }}. All Rights Reserved.</p>
Next would be to create the migrations and run them by doing python manage.py makemigrations appointment
and right
after, run python manage.py migrate
to create the appointment models.
Launch the development server and navigate to http://127.0.0.1:8000/admin/ to create appointments, manage configurations, and handle appointment conflicts (the Admin app must be enabled).
You must create at least one service before using the application on the admin page. If your service is free, input 0 as the price. If your service is paid, input the price in the price field. You may also provide a description for your service.
Visit http://127.0.0.1:8000/appointment/request/
Proper email configuration is crucial for the sending email and for the appointment reminder functionality.
Add the following to your settings.py
:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'your_smtp_host'
EMAIL_PORT = 587 # or 465 for EMAIL_USE_SSL
EMAIL_USE_TLS = True # or EMAIL_USE_SSL = True
EMAIL_HOST_USER = 'your_email@example.com'
EMAIL_HOST_PASSWORD = 'your_email_password'
# Optional: Set your website name for email footer
APPOINTMENT_WEBSITE_NAME = 'Your Website Name'
Note: Make sure to use environment variables or a secure method to store sensitive information like email passwords in production.
Django-Appointment uses Django Q for sending email reminders. This feature is optional but recommended for better performance and user experience.
Install Django Q:
pip install django_q2
Add 'django_q' to INSTALLED_APPS in your settings.py:
INSTALLED_APPS = [
# ...
'django_q',
]
Configure Django Q in your settings.py:
Q_CLUSTER = {
'name': 'django-appointment',
'workers': 4,
'timeout': 90,
'retry': 120,
'queue_limit': 50,
'bulk': 10,
'orm': 'default',
}
USE_DJANGO_Q_FOR_EMAILS = True # Use Django Q for sending ALL emails
Start the Django Q cluster:
python manage.py qcluster
Note: If you choose not to use Django Q, email reminders will not be sent, but the rest of the application will function normally.
If you're using a base.html template, you must include the following blocks in your template:
{% block customCSS %}
{% endblock %}
{% block title %}
{% endblock %}
{% block description %}
{% endblock %}
{% block body %}
{% endblock %}
{% block customJS %}
{% endblock %}
These blocks are essential for the proper functioning of the application:
customCSS
and customJS
allow the application to inject the necessary styles and scripts.body
is where the main content of each page will be rendered.title
and description
are used for SEO and are recommended but not strictly required.At minimum, the blocks for CSS, body, and JS are required for the application to work properly. jQuery is also required to be included in the template.
See an example of a base.html template here.
settings.py
, you can override the default values for the appointment scheduler.
More information regarding available configurations can be found in
the documentation.Django-Appointment now supports Docker, making it easier to set up, develop, and test.
Using Django-Appointment with Docker is primarily intended for development purposes or local testing. This means you'll need to clone the project from the GitHub repository to get started.
Note: These Docker instructions are for development and testing. For production deployment, please refer to Django's official deployment documentation and best practices.
Here's how you can set it up:
Clone the Repository: Clone the Django-Appointment repository to your local machine:
git clone https://github.com/adamspd/django-appointment.git
or using SSH:
git clone git@github.com:adamspd/django-appointment.git
then go to the project's directory:
cd django-appointment
Prepare an .env File: Create an .env
file in the root directory of your project with your configuration
settings.
You should include your email host user and password for Django's email functionality (if you want it to work):
# Main admin user, can have several others, but you need to change the settings.py configuration then
ADMIN_NAME="Super Admin"
ADMIN_EMAIL=super.admin@example.com
# If you don't change these 3 below, docker-compose (or localhost) will fail sending emails
EMAIL_HOST_USER=no-reply@example.com
EMAIL_HOST_PASSWORD=youcantguessme
EMAIL_HOST=smtp.example.com
# default one (can leave it as is)
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
# if using TLS on your mail server this is ok, else, use 465 for SSL
EMAIL_PORT=587
EMAIL_USE_TLS=True
# On localhost, you must install django-q2, with docker-compose, it's already installed
USE_DJANGO_Q=True
Note: The
.env
file is used to store sensitive information and should not be committed to version control.
Build and Run the Docker Containers: Run the following command to build and run the Docker containers:
docker-compose up -d --build
or
docker compose up -d --build
Make Migrations and Run: Create the migrations with the following command:
docker-compose exec web python manage.py makemigrations appointment
or
docker compose exec web python manage.py makemigrations appointment
Then, apply the migrations with the following command:
docker-compose exec web python manage.py migrate
or
docker compose exec web python manage.py migrate
Create a Superuser: After the containers are running, create a superuser to access the Django admin interface:
docker-compose exec web python manage.py createsuperuser
or
docker compose exec web python manage.py createsuperuser
Access the Application: Once the containers are running, you can access the application at localhost:8000
. The
Django admin interface is available at localhost:8000/admin
. And from there, add the necessary configurations.
Follow this documentation.
Shut Down the Containers: When you're finished, you can shut down the containers with the following command:
docker-compose down
# docker compose down
Note: I used the default database settings for the Docker container. If you want to use a different database, you can modify the Dockerfile and docker-compose.yml files to use your preferred database.
A compatibility matrix is available to help you determine which versions of Django and Python are compatible with the package. The matrix is updated regularly to reflect the latest compatibility test results. For more information, please refer to the compatibility matrix here.
For support or inquiries regarding the Appointment Scheduler app, please refer to the documentation in the "docs" directory or visit the GitHub repository for more information.
Contributions are welcome! Please refer to the contributing guidelines for more information.
Important: Please consider starring the repository if you find it useful. It helps me to know that the project is appreciated and that I should continue to maintain it. Thank you!
Please refer to the code of conduct for more information.
Please refer to the security policy for more information.
I'm working on a testing website for the application that is not fully functional yet, no hard feelings. Before using it, it's important to me that you read the terms of use, only then you can use it if you agree to them. The demo website is located at https://django-appt.adamspierredavid.com/. Ideas are welcome.
Adams Pierre David - Website