from django.contrib import auth, messages
from django.http import HttpResponse
from django.shortcuts import render, redirect

from bank_app.models import bank

# Create your views here.


def home(request):
return render(request,"home.html")

def login(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(username=username,password=password)

if user is not None:
auth.login(request,user)
return redirect('/')
else:
messages.info(request,"invalid username or password")
return redirect('login')
return render(request,"login.html")

def registration(request):
return render(request,"registration.html")

def add_form(request):
if request.method == "POST":
name = request.POST.get('name',)
dob = request.POST.get('dob', )
age = request.POST.get('age', )
gender = request.POST.get('gender', )
phone_no = request.POST.get('phone_no', )
mail_id = request.POST.get('mail_id',)
address = request.POST.get('address',)
district = request.POST.get('district',)
branch = request.POST.get('branch',)
account_type = request.POST.get('account_type',)

Bank = bank(name=name,dob=dob,age=age,gender=gender,phone_no=phone_no,
mail_id=mail_id,address=address,district=district,
branch=branch,account_type=account_type,)

Bank.save()
messages.info(request, 'Bank added successfully')
return redirect('home')
return render(request,'add.html')

This is my views.py page. 
On Tuesday, August 22, 2023 at 12:49:39 AM UTC+5:30 Mike Simkins wrote:

> Did you regenerate and rerun the migrations ??
>
>
> python manage.py makemigrations
> python manage.py migrate
>
>
>
> On 21 Aug 2023, at 09:46, meenu loranz <[email protected]> wrote:
>
> Thank you for your response...i changed DOB to dob...but still showing me 
> the error...
> OperationalError at /add/ table bank_app_bank has no column named dob 
> Request Method: 
> POST 
> Request URL: 
> http://127.0.0.1:8000/add/ 
> Django Version: 
> 4.2 
> Exception Type: 
> OperationalError 
> Exception Value: 
> table bank_app_bank has no column named dob 
> Exception Location: 
> C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\sqlite3\base.py,
>  
> line 328, in execute 
> Raised during: 
> bank_app.views.add_form 
> Python Executable: 
> C:\Users\Admin\AppData\Local\Programs\Python\Python39\python.exe 
> Python Version: 
> 3.9.0 
> Python Path: 
> ['C:\\Users\\Admin\\myprojects\\banking_system\\bank_project', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\lib', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages']
>  
>
> Server time: 
> Mon, 21 Aug 2023 08:44:34 +0000
>
> On Saturday, August 19, 2023 at 10:49:13 PM UTC+5:30 RANGA BHARATH JINKA 
> wrote:
>
>> Hi,
>>
>> Try changing DOB to small letters dob and run the migrations again. 
>>
>> All the best 👍
>>
>> Thanks and Regards
>>
>> J. Ranga Bharath
>> Cell: 9110334114
>>     
>>
>> On Sat, 19 Aug 2023, 9:18 pm ivan harold, <[email protected]> wrote:
>>
>>>
>>> https://stackoverflow.com/questions/68269165/why-django-is-not-detecting-my-table-column
>>>
>>> Try reading this article, it may help you.
>>>
>>> On Saturday, August 19, 2023 at 3:05:57 AM UTC+8 meenu loranz wrote:
>>>
>>>> from django.contrib.auth.models import User
>>>> from django.db import models
>>>> from django.urls import reverse
>>>> # Create your models here.
>>>>
>>>> class bank(models.Model):
>>>> name = models.CharField(max_length=255)
>>>> DOB = models.DateField()
>>>> age = models.IntegerField()
>>>> gender = models.CharField(max_length=10)
>>>> phone_no = models.CharField(max_length=10)
>>>> mail_id = models.EmailField(max_length=25)
>>>> address = models.CharField(max_length=255)
>>>> district = models.CharField(max_length=100)
>>>> branch = models.CharField(max_length=100)
>>>> account_type = models.CharField(max_length=100)
>>>> # materials_provided = models.CharField(max_length=100)
>>>>
>>>>
>>>> def __str__(self):
>>>> return self.name
>>>>
>>>> This is my model.py page. And i can see this table and all fields in my 
>>>> database. But while running show me the operational error that no column 
>>>> named DOB. How can i fix this?
>>>>
>>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/1aaf9e41-e11c-43bb-bda9-17b609814059n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/1aaf9e41-e11c-43bb-bda9-17b609814059n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/3166bd2f-a556-49ce-9813-6794a3aac838n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/3166bd2f-a556-49ce-9813-6794a3aac838n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/414a5fad-1be4-4321-80d8-db4da9dad8e8n%40googlegroups.com.

Reply via email to