Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The code that powers djangosnippets.org, it allows users to post and share useful "snippets" of code.

License

NotificationsYou must be signed in to change notification settings

django/djangosnippets.org

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

djangosnippets.org

This code is used to power the snippet sharing site,djangosnippets.org

Development Setup

Prerequisites

  • Python version 3.11
  • PostgreSQL
  • uv - An extremely fast Python package and project manager

Installation

Basic Installation

  1. Clone the repo:

    https://github.com/django/djangosnippets.org.git
  2. Install uv if you haven't already:

    #macOScurl -LsSf https://astral.sh/uv/install.sh | sh#Windowspowershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  3. Connect to PostgreSQL

    Connect in Linux:

    psql -U $(whoami) -d postgres

    Connect in Windows:

    psql -U postgres
  4. Create a PostgreSQL database and role:

    postgres=# CREATE DATABASE djangosnippets;postgres=# CREATE USER djangosnippets WITH SUPERUSER PASSWORD 'djangosnippets';postgres=# GRANT ALL PRIVILEGES ON DATABASE djangosnippets TO djangosnippets;

    Exit psql shell:

    postgres=# exit
  5. Install dependencies:

    uv sync --extra dev
  6. Copy .env.template.local file, rename to .env and configure variables for your local postgres database.

    Copy in Linux:

    cp .env.template.local .env

    Copy in Windows:

    copy .env.template.local .env
  7. Run migrations and create superuser:

    Migrate:

    uv run python manage.py migrate

    Optionally load data first:

    uv run python manage.py loaddata fixtures/cab.json

    Create superuser:

    uv run python manage.py createsuperuser
  8. Install tailwind (npm is required):

    uv run python manage.py tailwind install
  9. Run server locally:

    uv run python manage.py runserver_plus
  10. Run tailwind in another terminal locally:

    uv run python manage.py tailwind start

With Docker

UsingDocker allows you to set up the development environment more quickly if Docker is installed 🐳

  1. Build the Docker images:

    docker compose -f docker-compose.local.yml build
  2. Start the containers:

    docker compose -f docker-compose.local.yml up -d
  3. Go to:http://127.0.0.1:8000/ and enjoy 🙌

Docker

You need to copy .env.example to .env and configure to your needs. The example is fine to start with development.

You may wish to use docker locally for production dependency testing and development; here are the setup instructions:

$ docker-compose -f docker-compose.production.yml build$ docker-compose -f docker-compose.production.yml up -d

-d denotes running docker in a detached state:

$ docker-compose -f docker-compose.production.yml run web python manage.py migrate$ docker-compose -f docker-compose.production.yml run web python manage.py createsuperuser$ docker-compose -f docker-compose.production.yml run web python manage.py loaddata fixtures/cab.json$ npm run build$ docker-compose -f docker-compose.production.yml run web python manage.py collectstatic

The docker setup is running as close as possible to the production setup in Heroku:

Postgres 12.3GunicornRedis

To run our tests with docker:

$ docker-compose -f docker-compose.yml run web python manage.py test --settings=djangosnippets.settings.testing

Test

To run tests:

$ python manage.py test --settings=djangosnippets.settings.testing

Styling Contributor?

DjangoSnippets uses theFoundation framework as the core of its visual style. Toget this working on your local machine you needcompass andbower to compileyour stylesheets. Pleasenever modify the generated .css files directly. Use the .scss ones instead.

To keep the setup path as short as possible, run the following commandsin your terminal:

$ cd djangosnippets/static$ bower install && compass watch

If you don't have either of these two installed, you can find detailedinstructions on their respective websites.

Please make sure that you commit only a compressed version of the CSS fileas this is what will be deployed. (In order to do that the defaultconfiguration inside djangosnippets/static/config.rb isoutput_style = :compressed)

Production Setup

The production setup is currently tailored to Heroku and, therefore, mostlyautomatic. The difference between these two setups is configured inthedjangosnippets.settings.production module and therequirements.txt file.

About

The code that powers djangosnippets.org, it allows users to post and share useful "snippets" of code.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors33


[8]ページ先頭

©2009-2025 Movatter.jp