database connection ******** DJANGO************
Install pip install mysqlclient
step 1
create a database and table in mysql
step 2
configure in settings (settings.py)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'studentdb',
'USER':'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3306',
'OPTIONS':{
'init_command':"SET sql_mode='STRICT_TRANS_TABLES'"
}
}
}
step 3
create a template
studentreg.html ( Regno,sname,course,dept)
step 4
******create a model********* ( model.py)
from django.db import models
class studentdetails(models.Model):
Regno=models.CharField(max_length=10)
StudentName=models.CharField(max_length=20)
Course=models.CharField(max_length=20)
Department=models.CharField(max_length=20)
class Meta:
db_table="tblstudent"
step 5
set URl path
******************************urls.py ************
from django.urls import path
from exampleapp import views
Install pip install mysqlclient
step 1
create a database and table in mysql
step 2
configure in settings (settings.py)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'studentdb',
'USER':'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3306',
'OPTIONS':{
'init_command':"SET sql_mode='STRICT_TRANS_TABLES'"
}
}
}
step 3
create a template
studentreg.html ( Regno,sname,course,dept)
step 4
******create a model********* ( model.py)
from django.db import models
class studentdetails(models.Model):
Regno=models.CharField(max_length=10)
StudentName=models.CharField(max_length=20)
Course=models.CharField(max_length=20)
Department=models.CharField(max_length=20)
class Meta:
db_table="tblstudent"
step 5
set URl path
******************************urls.py ************
from django.urls import path
from exampleapp import views