Update Readme

This commit is contained in:
jasonlin15 2024-09-25 17:45:55 -04:00
parent 81613c0e51
commit a7399964e0

View File

@ -74,6 +74,50 @@ INSTALLED_APPS = [
]
```
# Getting Started
To help you get started quickly with Django REST framework, follow these steps to create a simple API project.
### Step 1: Install Django and Django REST framework
First, make sure you have Python installed on your machine. You can install Django and Django REST framework using pip:
```bash
pip install django djangorestframework
```
### Step 2: Create a New Django Project
Create a new Django project by running the following command
```bash
django-admin startproject myproject
cd myproject
```
### Step 3: Create a New Django App
Next, create a new app within your project:
```bash
python manage.py startapp myapp
```
### Step 4: Update Settings
Add your new app and REST framework to the INSTALLED_APPS list in myproject/settings.py:
```bash
INSTALLED_APPS = [
...
'rest_framework',
'myapp',
]
```
Once you have follow the steps above, you should be able to use the REST framework. View the example below for extra details.
# Example
Let's take a look at a quick example of using REST framework to build a simple model-backed API for accessing users and groups.
@ -167,6 +211,29 @@ Or to create a new user:
"is_staff": false,
}
# Common Issues and Solutions
### 1. Database Migrations
If you encounter issues related to database migrations, ensure that you have run:
```bash
python manage.py makemigrations
python manage.py migrate
```
### 2. Missing Packages
If you receive errors about missing packages, double-check that you have installed both Django and Django REST framework using pip.
### 3. Debugging Configuration Errors
For configuration issues, ensure that your settings.py file includes all necessary apps in the INSTALLED_APPS list, and that your URLs are correctly configured.
For more detailed troubleshooting, refer to the documentation provided below.
# Documentation & Support
Full documentation for the project is available at [https://www.django-rest-framework.org/][docs].