Django REST Framework Install करना
In this page:
Package Install करना
अपने virtual environment को active रखते हुए, pip उपयोग करके DRF install करें, वैसे ही जैसे आपने खुद Django install किया था।
उदाहरण: Installing the Package
With your virtual environment active, install DRF using pip, the same way you installed Django itself.
pip install djangorestframework
⚠️ Run this in your own terminal or Node.js environment.
App को Register करना
किसी भी Django app की तरह, DRF को INSTALLED_APPS में listed होना चाहिए ताकि Django इसके templates, static files, और features (जैसे browsable API) load करे।
उदाहरण: Registering the App
Like any Django app, DRF must be listed in INSTALLED_APPS so Django loads its templates, static files, and features (like the browsable API).
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'myapp',
]
{# Django-only code -- models.py/views.py/urls.py/settings.py
snippets, or template markup using Django template tags/variables
-- can't run standalone via Judge0 or the browser preview, since
it needs a real Django project. Only this course's pure-Python
examples (example_lang == 'python', no Django imports) are
actually runnable, so those still get the button below. #}
Install को Verify करना
अपने virtual environment के अंदर Python interpreter से इसका version confirm करके जांचें कि DRF सही से install हुआ।
उदाहरण: Verifying the Install
Check that DRF installed correctly by confirming its version from the Python interpreter inside your virtual environment.
python -c "import rest_framework; print(rest_framework.VERSION)"
⚠️ Run this in your own terminal or Node.js environment.
- djangorestframework install करना लेकिन
INSTALLED_APPSमें rest_framework add करना भूल जाना, इसलिए DRF की features silently activate नहीं होती। - इसे project के virtual environment के अंदर उपयोग करने के बजाय globally install करना, जो machines के बीच version mismatches का कारण बनता है।
settings.pyमें rest_framework add करने के बाद development server restart न करना।
pip install djangorestframeworkसे DRF को अपने active virtual environment में install करें।settings.pyमेंINSTALLED_APPSlist में rest_framework add करें।- Development server restart करें ताकि नया app pick up हो जाए।
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: