table bank_app_bank has no column named DOB

140 views
Skip to first unread message

meenu loranz

unread,
Aug 18, 2023, 3:05:57 PM8/18/23
to Django users
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?

Joe Reitman

unread,
Aug 19, 2023, 10:35:19 AM8/19/23
to Django users
You can not use all caps as a field name. Some other restrictions are:
  • A field name cannot be a Python reserved word.
  • A field name cannot contain more than one underscore in a row.
  • A field name cannot start with an underscore.


ivan harold

unread,
Aug 19, 2023, 11:47:48 AM8/19/23
to Django users

RANGA BHARATH JINKA

unread,
Aug 19, 2023, 1:19:13 PM8/19/23
to django...@googlegroups.com
Hi,

Try changing DOB to small letters dob and run the migrations again. 

All the best 👍

Thanks and Regards

J. Ranga Bharath
Cell: 9110334114
   

--
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 django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1aaf9e41-e11c-43bb-bda9-17b609814059n%40googlegroups.com.

meenu loranz

unread,
Aug 21, 2023, 4:46:46 AM8/21/23
to Django users
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

Mike Simkins

unread,
Aug 21, 2023, 3:19:39 PM8/21/23
to django...@googlegroups.com
Did you regenerate and rerun the migrations ??


python manage.py makemigrations
python manage.py migrate



meenu loranz

unread,
Aug 22, 2023, 4:20:01 AM8/22/23
to Django users

Yes i delete that 0001_initial.py page and rerun the migration codes and run the server. But it dosen't work for me..

Kani Sbt

unread,
Aug 23, 2023, 6:35:21 AM8/23/23
to Django users
delete all the migrations without init.py , then delete SQLite file , then do makemigrations and migrate

ivan harold

unread,
Aug 23, 2023, 10:55:20 AM8/23/23
to Django users
Does this thread already resolved?

meenu loranz

unread,
Aug 24, 2023, 3:25:23 AM8/24/23
to Django users
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:

Steven maithya

unread,
Aug 25, 2023, 1:29:59 PM8/25/23
to Django users

(en) PS C:\Users\steve.musyoka\Desktop\CRM-master> python manage.py runserver
C:\Python311\python.exe: can't open file 'C:\\Users\\steve.musyoka\\Desktop\\CRM-master\\manage.py': [Errno 2] No such file or directory
(en) PS C:\Users\steve.musyoka\Desktop\CRM-master> cd
(en) PS C:\Users\steve.musyoka\Desktop\CRM-master> ls






this is the error am getting when i run my django project any help please
Reply all
Reply to author
Forward
0 new messages