Skip to main content

polls on wagtail

Project description

django-on-hatch

PyPI - Version PyPI - Python Version


目次

詳細

このリポジトリはHatchプロジェクトマネージャーを使ったDjangoプロジェクトの開発またはテスト(お試し)ツールです。

配布用としてDjangoアプリをアップロードする環境を自動構築または配布用としてアップロードされたDjangoアプリをこのDjangoプロジェクトに組み込んでテストすることができます。

使用方法は以下からご覧ください。

インストール

実行環境は「Windows Sybsystem for Linux 2」のUbuntuです。

Pythonの環境は任意です。

私はpyenvを使用してPython3.7の環境を設定しています。

$ pyenv local 3.7

$ python3 --version
Python 3.7.0

仮想環境を作成して有効にし、Hatchをインストールします。

$ python3 -m venv .venv && . .venv/bin/activate

$ pip install --upgrade pip

$ pip install hatch keyrings.alt

リポジトリを落として「wagtail-polls」ディレクトリに入ります。

$ git clone https://github.com/kenno-warise/wagtail-polls.git

$ cd wagtail-polls

hatchコマンドでデータベースの作成・スーパーユーザーの作成・サーバーの起動を行います。

$ hatch run makemigrations polls && hatch run migrate

$ hatch run createsuperuser

$ hatch run runserver

ショートカットとしてHatchの「run」コマンドで実行できるDjangoのコマンドはpyproject.tomlの「tool.hatch.envs.default.scripts」テーブルによって登録しています。

[tool.hatch.envs.default.scripts]
makemigrations = "python3 manage.py makemigrations {args}"
migrate = "python3 manage.py migrate"
createsuperuser = "python3 manage.py createsuperuser"
runserver = "python3 manage.py runserver"
startapp = "python3 manage.py startapp {args}"
shell = "python3 manage.py shell"
test = "python3 manage.py test {args}"
cov = "coverage run --include=app/* --omit=app/test*,app/__init__.py,app/migrations manage.py test {args}"
cov-report = "coverage report -m"

アップロード

Hatchの「version」コマンドでDjangoアプリのバージョン情報を確認できます。

$ hatch version
0.0.1

DjangoアプリをパッケージングしてPyPIにアップロードする。

pyproject.tomlに配布するファイルと配布しないファイルを設定できます。

[tool.hatch.build]
include = ["app_2/*"] # templatesとstaticも含まれます。
exclude = ["app_2/migrations/*"]

上記以外にあれば追記します。

バージョンを更新する場合は「version」コマンドを実行します。

$ hatch version micro
Old: 0.0.1
New: 0.0.2

ビルドを実行します。

$ hatch build

アーティファクトを公開します。

$ hatch publish

Djangoプロジェクトに設定(テスト)

アップロード済みのDjangoアプリを設定します。

myproject/settings.py

pkgの部分をDjangoアプリ名に当てはめます。

INSTALLED_APPS = [
    ...,
    "pkg",
]

myproject/urls.py

pkgの部分をDjangoアプリ名に当てはめます。

...
from django.urls import path, include

urlpatterns = [
    ...,
    path('', include('pkg.urls')),
]

requirements.txt

pkgの部分をDjangoアプリ名に当てはめます。

django==2.2.5
pkg

必要であればマイグレートとスーパーユーザーを作成します。

$ hatch run migrate

$ hatch run createsuperuser

サーバーを起動します。

$ hatch run runserver

License

django-on-hatch is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

warise_polls-0.0.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warise_polls-0.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file warise_polls-0.0.1.tar.gz.

File metadata

  • Download URL: warise_polls-0.0.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for warise_polls-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dd02b8c309aca0797c86a6e358369922aaba8a31448e9214114b55caae545af0
MD5 a64e20bcbe2891f6356c5b5ab1f19bea
BLAKE2b-256 77c34245e658e4e20d1f8167cfdb2ae7e816cd99d7d165df97a3c5df2271e0ea

See more details on using hashes here.

File details

Details for the file warise_polls-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: warise_polls-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for warise_polls-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 85c7d65d8a71cdc349a31036ce9cec99b1e648d9699d3639b789ac356ea3b0a6
MD5 9e312da15fad89937a92fc57b015673f
BLAKE2b-256 ad0fa4cd4aee1d7917e2ea6fa2e79db14df6d2cbd5898a0c8abd2f1ac8e99a72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page