0Pricing
Django Academy · Lektion

Die browsable API und Statuscodes

Endpoints im Browser korrekt testen

Die browsable API und Statuscodes ist eine kostenlose Django Academy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Django Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Django Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Test in the Browser

DRF's browsable API renders any endpoint as an interactive web page, so you can explore and test your API without extra tools. 🌐

How It Decides

DRF uses content negotiation: browsers ask for HTML and get the friendly page, while code asking for JSON gets raw JSON instead.

Forms for Free

For write endpoints the browsable API even shows a form, letting you POST test data with a click instead of crafting curl commands.

Force JSON Anytime

Append ?format=json to any URL to skip the HTML page and see the exact JSON a real client would receive.

GET /api/books/?format=json

Status Codes Matter

Every API response carries an HTTP status code that tells the client what happened, far more reliably than reading the body text.

200 and 201

200 means a successful read, while 201 Created signals that a POST actually made a new resource, a small but important distinction.

Readable Constants

Instead of magic numbers, DRF gives you named constants in status so your code reads clearly and avoids typos like 20 versus 200.

from rest_framework import status
status.HTTP_201_CREATED

Client Errors: 400 and 404

The 4xx range blames the request: 400 means bad input that failed validation, and 404 means the resource simply was not found.

Response(serializer.errors, status=400)

Server Errors: 500

A 500 means your code crashed, not the client. These signal bugs to fix, never something the caller did wrong.

Match Code to Outcome

Good APIs are predictable: return 201 on create, 400 on invalid input, 404 when missing. Correct status codes make clients trust you.

Browsable Plus Status

Together the browsable API and clear status codes make DRF endpoints easy to test by hand and easy for clients to consume.

Quick Check

Which status code best fits a successful POST that creates a record?

Recap: Test and Respond

You met the browsable API for hands-on testing and learned to return honest status codes like 200, 201, 400, and 404. ✅

Häufig gestellte Fragen

Ist die Lektion „Die browsable API und Statuscodes“ kostenlos?

Ja — der vollständige Text von „Die browsable API und Statuscodes“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Django Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Django Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Die browsable API und Statuscodes“?

Endpoints im Browser korrekt testen Du übst Django Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Django Academy zu starten?

Keine Vorkenntnisse erforderlich. Django Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Die browsable API und Statuscodes“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Django Academy-Lektion Code schreiben und ausführen?

Ja. Jede Django Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. DRF installieren und konfigurieren
  2. Serializers: Model zu JSON
  3. APIView und die Funktion @api_view
  4. Die browsable API und Statuscodes
← Zurück zu Django Academy