### Starting Production Website Container with Docker Compose (Shell) Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_prod.md This command starts the main website container using Docker Compose. It assumes the container has already been built and configured. Use this command to resume service after it has been stopped. ```Shell docker-compose start ``` -------------------------------- ### Running Database Docker Container - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Starts the Docker container for the PostgreSQL development database. This command is a convenient shortcut defined in the project's Makefile to quickly get the database running. Requires Docker Engine and Docker Compose. ```Shell make run_db ``` -------------------------------- ### Starting Docker Development Services using Makefile Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_dev.md Executes the `run_dev` target defined in the project's Makefile. This command typically handles the orchestration of starting necessary Docker containers for development, such as database and application services, using Docker Compose. ```Shell make run_dev ``` -------------------------------- ### Initializing Development Environment - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Runs the initialization process defined in the Makefile, which typically handles installing project dependencies (Python via Poetry, potentially Node). This prepares the project's environment after cloning. Requires a shell environment and Makefile setup. ```Shell make init ``` -------------------------------- ### Quick Launching Local Development Server - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md A convenience command defined in the Makefile for quickly launching the local development server, potentially combining multiple setup steps. Useful for subsequent development after the initial setup. Requires a shell environment and Makefile setup. ```Shell make run_local ``` -------------------------------- ### Full Deployment Cycle for Website Container with Docker Compose (Shell) Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_prod.md This command sequence performs a complete deployment cycle for the main website container. It stops and removes any existing containers, pulls the latest image, builds if necessary, and starts the new container in detached mode. Use this for fresh deployments or updates. ```Shell docker-compose stop ; docker-compose rm -f ; docker-compose pull ; docker-compose up --build -d ``` -------------------------------- ### Creating Django Superuser - Python Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Starts the interactive process to create an administrative user account for the Django application. This user can access the Django admin interface. Requires the Python environment with Django activated and the database configured. ```Python python manage.py createsuperuser ``` -------------------------------- ### Activating Python Virtual Environment - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Activates the Poetry-managed Python virtual environment in the current shell session. This ensures that subsequent Python commands use the project's installed dependencies rather than system Python. Requires Poetry to be installed. ```Shell poetry shell ``` -------------------------------- ### Running Django Development Server - Python Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Starts the built-in Django development server on the local machine. This server is used for testing and developing the application. Requires the Python environment with Django activated and the database configured. ```Python python manage.py runserver ``` -------------------------------- ### Run Standard Tests (pytest) - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/README.md This command executes the standard test suite for the project using the pytest framework. It should be run inside the 'src' directory and requires pytest-django to be installed. It checks the basic functionality of the application. ```Shell pytest ``` -------------------------------- ### Deploying PostgreSQL Service with Docker Compose (Shell) Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_prod.md This command deploys the PostgreSQL database service required by the PyCon Taiwan website using Docker Compose. It builds the image if necessary and runs the service in detached mode. Requires navigating to the `pycontw-postgresql` directory first. ```Shell docker-compose up --build -d ``` -------------------------------- ### Applying Django Database Migrations - Python Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Runs database migrations to set up or update the database schema based on the Django models. This must be done after setting up the database and whenever models are changed. Requires the Python environment with Django activated and database access. ```Python python manage.py migrate ``` -------------------------------- ### Changing Directory to Source Root - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Navigates into the `src` directory of the project. Most Django management commands (`python manage.py ...`) are typically executed from this directory. Standard shell command. ```Shell cd src ``` -------------------------------- ### Copying Local Environment File - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Copies the sample local environment settings file to the active local settings file (`local.env`). This file is used to store local-specific configurations like the SECRET_KEY and database URL. Requires a shell environment. ```Shell cp src/pycontw2016/settings/local.sample.env src/pycontw2016/settings/local.env ``` -------------------------------- ### Deploying Nginx Service with Docker Compose (Shell) Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_prod.md This command deploys the Nginx web server service required by the PyCon Taiwan website using Docker Compose. It builds the image if necessary and runs the service in detached mode. Requires navigating to the `pycontw-nginx` directory first. ```Shell docker-compose up --build -d ``` -------------------------------- ### Compiling Django Localization Messages - Python Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Compiles gettext translation files (`.po`) into machine-readable binary files (`.mo`). This is necessary if the project uses internationalization (i18n) for translations. Requires the Python environment with Django activated. ```Python python manage.py compilemessages ``` -------------------------------- ### Setting Django Secret Key - Configuration Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_local_env_dev.md Sets the Django SECRET_KEY value, typically within the `local.env` file. This key is essential for cryptographic signing in Django, such as session cookies. Replace the placeholder with a unique, randomly generated string. ```Configuration SECRET_KEY=twvg)o_=u&@6^*cbi9nfswwh=(&hd$bhxh9iq&h-kn-pff0&&3 ``` -------------------------------- ### Accessing Docker Service Shell using Makefile Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_dev.md Runs the `shell_dev` target from the Makefile. This command provides a shell interface inside a specific Docker service container (identified as `pycontw` in the context), allowing users to interact directly with the application environment for running commands. ```Shell make shell_dev ``` -------------------------------- ### Running Django Management Commands in Docker Shell Source: https://github.com/pycontw/pycon.tw/blob/master/document/deploy_docker_dev.md A collection of essential Django management commands executed using `python manage.py` from within the project's container shell. These commands cover typical development tasks like creating and applying database migrations, setting up a superuser, and managing internationalization (translation) files. ```Shell # make migrations python manage.py makemigrations # apply migrations python manage.py migrate # create a superuser python manage.py createsuperuser # pull out strings for translations python manage.py makemessages -l en_US -l zh_Hant # compile translations python manage.py compilemessages ``` -------------------------------- ### Run Tests with Coverage (pytest-cov) - Shell Source: https://github.com/pycontw/pycon.tw/blob/master/README.md This command runs the project's test suite using pytest and generates a code coverage report using the pytest-cov plugin. The '--cov=.' flag specifies that coverage should be calculated for the current directory ('src'). It helps identify untested parts of the codebase. ```Shell pytest --cov=. ``` -------------------------------- ### Initializing and Logging with Project Logger in Python Source: https://github.com/pycontw/pycon.tw/blob/master/logs/README.md This snippet demonstrates the standard approach to obtaining a logger instance named 'project' and then using it to log an informational message. It requires the built-in 'logging' module and is intended for recording events within the application's custom logic. ```python import logging logger = logging.getLogger("project") # Anywhere else in the file logger.info('Started processing foo') ``` -------------------------------- ### Generating Account Activation Email Body (Django Template) Source: https://github.com/pycontw/pycon.tw/blob/master/src/templates/default/registration/verification_email.txt This snippet contains the full Django template used to generate the body of an account activation email. It uses the `blocktrans` tag for combining translatable text with context variables like `host`, `user_email`, and `verification_url`. It requires the `i18n` template tags to be loaded and disables autoescaping for the content. ```Django Template Language {% spaceless %} {% autoescape off %} {% load i18n %} {% blocktrans with user_email=user.email %} An account has been created on {{ host }} with this email address ({{ user_email }}). To activate this account and confirm this email address, go to {{ verification_url }} You can ignore this message if you did not sign up for this site. {% endblocktrans %} {% endautoescape %} {% endspaceless %} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.