Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connecting templates
- ====================
- views.py:
- from django.shortcuts import render
- def index(request):
- return render(request,('index.html'))
- =========================================
- urls.py(projetc):
- from django.contrib import admin
- from django.urls import path
- from blog import views
- urlpatterns = [
- path('admin/', admin.site.urls),
- path('',views.index),
- ]
- =========================================
- create a derectory file in app and rename templates
- create a new html file in templates
- ======================================================
- terminal or cmd:
- python manage.py makemigrations
- python manage.py migrate
- =========================================
- models.py:
- from django.db import models
- class Blog(models.Model):
- title = models.CharField(max_length=100)
- body = models.TextField()
- class ShuvoAnanto(models.Model):
- friends = models.CharField(max_length=40)
- friendsnum = models.CharField(max_length=20)
- ======================================================
- turn on xampp. create a databasein (blogapp) phpadmin.
- ========================================
- setting.py(DATABASES):
- 'ENGINE': 'django.db.backends.mysql',
- 'NAME': 'blogapp',
- 'USER': 'root',
- 'PASSWORD':'',
- 'HOST':'localhost',
- 'PORT':'3306'
- ========================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement