Skip to content

Email and Django Q Configuration 📧

Email Configuration 📧

The app needs a working email setup to send confirmations and reminders. Add this to your settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'your_smtp_host'
EMAIL_PORT = 587  # or 465 with 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: your website's name, shown at the top of the emails
APPOINTMENT_WEBSITE_NAME = 'Your Website Name'

To change the emails, see Custom templates: each email can be overridden, with its subject and its plain-text part, and with DEBUG = True a superuser can preview them all at app-admin/email-preview/.

Note: In production, keep secrets like the email password in environment variables (or another secure store), not in settings.py.

Django Q Configuration ⏰

Django-Appointment uses Django Q to send reminder emails at the right time and to clean up abandoned booking requests every day. It's optional, but recommended.

Setting up Django Q

  1. Install Django Q:

    pip install django-q2
    

  2. Add django_q to INSTALLED_APPS in your settings.py:

    INSTALLED_APPS = [
        # ...
        'django_q',
    ]
    

  3. 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  # optional: also send all the other emails in the background
    

  4. Create Django Q's tables:

    python manage.py migrate
    

  5. Start the Django Q cluster, and keep it running alongside your server:

    python manage.py qcluster
    

Note: Without Django Q, the app works normally, but reminder emails are not sent and old booking requests are only cleaned up when you run python manage.py cleanup_appointment_requests yourself.