Skip to content

Commit

Permalink
高度なチュートリアル: 再利用可能アプリの書き方
Browse files Browse the repository at this point in the history
  • Loading branch information
ot-nemoto committed Jun 24, 2024
1 parent 12ebf99 commit 35053b9
Show file tree
Hide file tree
Showing 30 changed files with 213 additions and 5 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ coverage html

**django-debug-toolbar**

_settings.py_
_mysite/settings.py_

```python
INSTALLED_APPS = [
Expand All @@ -160,7 +160,7 @@ INTERNAL_IPS = [
]
```

_urls.py_
_mysite/urls.py_

```python
from django.urls import path, include
Expand All @@ -170,3 +170,36 @@ urlpatterns = [
path('__debug__/', include('debug_toolbar.urls')),
]
```

### 高度なチュートリアル: 再利用可能アプリの書き方

パッケージをビルド

```sh
cd django-polls
python setup.py sdist
```

パッケージをインストール

```sh
python -m pip install --user django-polls/dist/django-polls-0.1.tar.gz
```

_mysite/settings.py_

```python
INSTALLED_APPS = [
"django_polls.apps.PollsConfig",
...,
]
```

_mysite/urls.py_

```python
urlpatterns = [
path("polls/", include("django_polls.urls")),
...,
]
```
21 changes: 21 additions & 0 deletions django-polls/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 ot-nemoto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions django-polls/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include LICENSE
include README.rst
recursive-include django_polls/static *
recursive-include django_polls/templates *
recursive-include docs *
28 changes: 28 additions & 0 deletions django-polls/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
============
django-polls
============

django-polls is a Django app to conduct web-based polls. For each
question, visitors can choose between a fixed number of answers.

Detailed documentation is in the "docs" directory.

Quick start
-----------

1. Add "polls" to your INSTALLED_APPS setting like this::

INSTALLED_APPS = [
...,
"django_polls",
]

2. Include the polls URLconf in your project urls.py like this::

path("polls/", include("django_polls.urls")),

3. Run ``python manage.py migrate`` to create the models.

4. Start the development server and visit the admin to create a poll.

5. Visit the ``/polls/`` URL to participate in the poll.
Binary file added django-polls/dist/django-polls-0.1.tar.gz
Binary file not shown.
54 changes: 54 additions & 0 deletions django-polls/django_polls.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Metadata-Version: 2.1
Name: django-polls
Version: 0.1
Summary: A Django app to conduct web-based polls.
Home-page: https://github.com/ot-nemoto/django-tutorial
Author: ot-nemoto
Author-email: nemoto@opentone.co.jp
License: MIT License
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.10
License-File: LICENSE
Requires-Dist: Django>=5.0

============
django-polls
============

django-polls is a Django app to conduct web-based polls. For each
question, visitors can choose between a fixed number of answers.

Detailed documentation is in the "docs" directory.

Quick start
-----------

1. Add "polls" to your INSTALLED_APPS setting like this::

INSTALLED_APPS = [
...,
"django_polls",
]

2. Include the polls URLconf in your project urls.py like this::

path("polls/", include("django_polls.urls")),

3. Run ``python manage.py migrate`` to create the models.

4. Start the development server and visit the admin to create a poll.

5. Visit the ``/polls/`` URL to participate in the poll.
25 changes: 25 additions & 0 deletions django-polls/django_polls.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
LICENSE
MANIFEST.in
README.rst
pyproject.toml
setup.cfg
setup.py
django_polls/__init__.py
django_polls/admin.py
django_polls/apps.py
django_polls/models.py
django_polls/tests.py
django_polls/urls.py
django_polls/views.py
django_polls.egg-info/PKG-INFO
django_polls.egg-info/SOURCES.txt
django_polls.egg-info/dependency_links.txt
django_polls.egg-info/requires.txt
django_polls.egg-info/top_level.txt
django_polls/migrations/0001_initial.py
django_polls/migrations/__init__.py
django_polls/static/polls/style.css
django_polls/static/polls/images/background.png
django_polls/templates/polls/detail.html
django_polls/templates/polls/index.html
django_polls/templates/polls/results.html
1 change: 1 addition & 0 deletions django-polls/django_polls.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions django-polls/django_polls.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Django>=5.0
1 change: 1 addition & 0 deletions django-polls/django_polls.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
django_polls
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion polls/apps.py → django-polls/django_polls/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

class PollsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "polls"
name = "django_polls"
label = "polls"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions django-polls/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ['setuptools>=40.8.0']
build-backend = 'setuptools.build_meta'
31 changes: 31 additions & 0 deletions django-polls/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[metadata]
name = django-polls
version = 0.1
description = A Django app to conduct web-based polls.
long_description = file: README.rst
url = https://github.com/ot-nemoto/django-tutorial
author = ot-nemoto
author_email = nemoto@opentone.co.jp
license = MIT License
classifiers =
Environment :: Web Environment
Framework :: Django
Framework :: Django :: 5.0
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content

[options]
include_package_data = true
packages = find:
python_requires = >=3.10
install_requires =
Django >= 5.0
3 changes: 3 additions & 0 deletions django-polls/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
2 changes: 1 addition & 1 deletion mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"django.contrib.sessions", # A session framework.
"django.contrib.messages", # A messaging framework.
"django.contrib.staticfiles", # A framework for managing static files.
"polls.apps.PollsConfig",
"django_polls.apps.PollsConfig",
"debug_toolbar",
]

Expand Down
2 changes: 1 addition & 1 deletion mysite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.urls import include, path

urlpatterns = [
path("polls/", include("polls.urls")),
path("polls/", include("django_polls.urls")),
path("admin/", admin.site.urls),
path("__debug__/", include("debug_toolbar.urls")),
]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ django
mysqlclient
coverage
django-debug-toolbar
setuptools

0 comments on commit 35053b9

Please sign in to comment.