Smart Deals - promotions, discount codes and sales

Django settings.py Configurator

Free online Django settings.py Configurator that runs directly in your browser.

Secure (SSL)
Client-Side Processing
100% Free
Instructions
  • 1
    Enter data
    Enter content, paste text or load a file from disk.
  • 2
    Click the button
    The tool will immediately process your data in the browser.
  • 3
    Get the result
    Copy the finished text or save the file to your device.
function runTool() {
  return "Result ready in 0.1s";
}
545 characters
Set the parameters and click \"Process\" to see the result.

Rate this tool:

Related tools

Other tools you may find useful

Django settings.py configurator – generating a safe Django project configuration

Django is one of the most advanced and most frequently chosen web frameworks written in Python. Built on the "batteries-included" philosophy, it provides developers with a complete set of ready-made modules (ORM, administrator panel, authentication system, forms support). The heart of every Django project is thesettings.pyfile, where all configuration variables are defined: database connections, security settings, application registration, middleware, and static and media file paths. Errors in the configuration file can lead to application crashes or, even worse, critical security vulnerabilities. Our free online Django settings.py configurator allows you to visually click options and generate a ready-made, optimized and safe configuration file.

This saves you time on manually entering parameters and ensures that your configuration meets market best practices.

Key variables in Django settings.py file

The following table shows the most important Django project configuration parameters and their importance in production and development environments:

Variable name Role and purpose Recommended development value Recommended production value
SECRET_KEY Cryptographic key for signing sessions, cookies and CSRF tokens. Default random string. Taken from environment variables (secured!).
DEBUG Debug mode displaying detailed error descriptions (Traceback). True(makes it easier to find errors). False(errors must not be visible to end users!).
ALLOWED_HOSTS List of IP addresses and domains that can host the application (protection against Host Header attacks). ['localhost', '127.0.0.1'] List of specific domains (e.g.['yourdomain.pl', 'www.yourdomain.pl']).
DATABASES Configuration of connections to databases (e.g. PostgreSQL, MySQL, SQLite). Default SQLite (built-in local file). PostgreSQL or MySQL from environment variables.
SECURE_SSL_REDIRECT Force all HTTP requests to be redirected to secure HTTPS. False True(secure encrypted traffic).

Django security in production – what do you need to remember?

Django has a built-in set of diagnostic tools (python manage.py check --deploycommand) that verifies the security of your configuration. Below are the key steps before running a project on the server:

  1. Hide SECRET_KEY:Never put the key on GitHub or other repositories in plain text. Use libraries such aspython-dotenvordjango-environto read the key from the.envfile on the server.
  2. Disable DEBUG:LeavingDEBUG = Truein production is a critical security vulnerability. The user then sees the full database structure, system variables and source code fragments for each error.
  3. Configure Cookies:Enable security flags for sessions and CSRF cookies:
    SESSION_COOKIE_SECURE = True
    CSRF_COOKIE_SECURE = True
  4. Set HSTS headers:Enable HTTP Strict Transport Security so that browsers communicate with your domain only via HTTPS:
    SECURE_HSTS_SECONDS = 31536000
    SECURE_HSTS_INCLUDE_SUBDOMAINS = True

How to use the settings.py configurator?

Generating a file using our tool is simple and fast:

  • Fill in the basic project data: Project name, time zone (e.g. Europe/Warsaw) and language (e.g. pl).
  • Select the database type (SQLite, PostgreSQL, MySQL) and enter the access data.
  • Select production security options (HTTPS, HSTS, secure cookies).
  • Click the "Generate settings.py" button, copy the code and paste it into your project in the configuration file.

Frequently asked questions (FAQ)

What is middleware in Django and how to configure it in settings.py?

Middleware is a lightweight plugin framework that processes requests and responses that pass through Django. Responsible for, among others: for session authorization, CSRF protection, security headers and Gzip compression. In theMIDDLEWAREarray, order is crucial because requests go from top to bottom and responses come back from bottom to top.

How to configure support for static files (CSS, JS) in production?

In production, Django does not support static files for performance reasons. In the settings.py file you need to defineSTATIC_URL, STATIC_ROOT(target directory) and run the commandpython manage.py collectstatic. Then the Nginx or Apache server (or a service like WhiteNoise) should serve these files directly from disk.

How to configure connection to PostgreSQL in settings.py?

To use the PostgreSQL database, you need to install thepsycopg2driver and change the configurationDATABASES: engine (ENGINE) todjango.db.backends.postgresql, provide the database name (NAME), user (USER), password (PASSWORD), host (HOST) and port (PORT - default 5432).

What is INSTALLED_APPS and does the order matter?

INSTALLED_APPSis a list of applications enabled in your Django project (both built-in system applications and your own modules and external packages). The order matters if applications overwrite the same templates or static files - Django searches applications in the order they appear in the array.

How to define the BASE_DIR variable?

The variableBASE_DIRpoints to the root directory of the project on disk. In newer versions of Django (since version 3) it is defined using a modulepathlib: BASE_DIR = Path(__file__).resolve().parent.parent. This allows you to create absolute paths to databases, templates or static files regardless of where the project will be launched.

Install Webp.pl Have the tools in your own pocket!