0Pricing
Django Academy · レッスン

DRFのインストールと設定

DRFとBrowsable APIを追加します

「DRFのインストールと設定」はCoddyKit上の無料Django Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはDjango Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Django Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

A REST API, Quickly

Django REST Framework, or DRF, layers a clean toolkit on top of Django so you can turn your models into a JSON API fast. 🚀

Install the Package

You add DRF the same way you add any Python library: with pip, then pin it in requirements so teammates get the same version.

pip install djangorestframework

Register the App

DRF only wakes up once you add rest_framework to your INSTALLED_APPS list in settings.py, right alongside your own apps.

INSTALLED_APPS = [
    # ...
    'rest_framework',
]

Why INSTALLED_APPS Matters

Adding it to INSTALLED_APPS lets Django discover DRF's templates, static files, and management commands automatically.

The REST_FRAMEWORK Dict

You configure DRF through a single REST_FRAMEWORK dictionary in settings.py, keeping all of its options in one tidy place.

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [],
}

Default Renderers

By default DRF can return both raw JSON and a friendly HTML view, thanks to its built-in renderers you rarely have to touch.

The Browsable API

One reason DRF feels magical is the browsable API: open an endpoint in your browser and you get a clickable, documented page. ✨

Wire Up the URLs

DRF ships login views for the browsable API; you include them in your urls.py so you can sign in while testing endpoints.

urlpatterns = [
    path('api-auth/', include('rest_framework.urls')),
]

Verify the Install

A quick way to confirm DRF is wired in is to open the Django shell and import it without errors before writing any code.

python manage.py shell
>>> import rest_framework

Keep Settings Minimal

Start with an almost empty config. You only add keys to REST_FRAMEWORK when you genuinely need a behavior changed, not before.

You Are API-Ready

With DRF installed, registered, and its URLs included, your project is now ready to expose endpoints that speak JSON to any client.

Quick Check

Where does DRF need to be listed to activate?

Recap: DRF Set Up

You pip-installed DRF, added it to INSTALLED_APPS, included its auth URLs, and confirmed the import. Your API foundation is solid. 🎉

よくある質問

「DRFのインストールと設定」レッスンは無料ですか?

はい。「DRFのインストールと設定」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Django Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Django Academyコースには全4レッスンが含まれています。

「DRFのインストールと設定」で何を学びますか?

DRFとBrowsable APIを追加します ブラウザで直接実行するハンズオンコードでDjango Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Django Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのDjango Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「DRFのインストールと設定」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このDjango Academyレッスンでコードを書いて実行できますか?

はい。すべてのDjango Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. DRFのインストールと設定
  2. Serializers:ModelからJSONへ
  3. APIViewと関数ベースの@api_view
  4. Browsable APIとステータスコード
← Django Academyに戻る