# Django Orm



```
pip install Django
```

### **Setting up a Django Project** <a href="#id-7049" id="id-7049"></a>

```
django-admin startproject myproject
python manage.py runserver
```

### Create app and linked with Project

```
 python manage.py startapp ORMExample
```

```
#setings.py
INSTALLED_APPS = [
    'ORMExample',
]

#urls.py project
from django.urls import path,include
urlpatterns = [
    path('ORMExample/',include('ORMExample.urls')),            
]

urls.py apps
from django.urls import path
urlpatterns = [
    
]
```

### **Defining Models** <a href="#c8ff" id="c8ff"></a>

```python
from django.db import models


class BlogPost(models.Model):
  title = models.CharField(max_length=200)
  content = models.TextField()
  pub_date = models.DateTimeField('date published')
  category= models.CharField(max_length=200)
  def __str__(self):
    return self.title
```

### **Creating a Database Schema** <a href="#af4f" id="af4f"></a>

```bash
python manage.py makemigrations
python manage.py migrate
```
