I've been trying to retrieve all data from model StudentInfo. But it shows the following error.
django.db.utils.ProgrammingError: column student_studentinfo.gurdians_mobile does not exist allStudent
Error in formatting: ProgrammingError: column student_studentinfo.gurdians_mobile does not exist LINE 1: ...ile_no1", "student_studentinfo"."current_address", "student_s...
After debugging my code, I found the line that causes error is
allStudent = StudentInfo.objects.all()
And the debugging messages Shows:
Unable to get repr for class 'django.db.models.query.QuerySet'
Here is my model StudentInfo
class StudentInfo(models.Model):
student_name = models.CharField("Student Name",max_length=20)
admission_date = models.DateField("Admission Date")
mobile_no1 = models.CharField("Mobile No.",max_length=12)
current_address = models.CharField("Current Address",max_length=20,blank=True)
batch_number = models.ForeignKey(BatchInfo)
coaching_id = models.IntegerField("Coaching ID")
def __unicode__(self):
return self.student_name
def __repr__(self):
return str(self.student_name)
And the other model BatchInfo that is related to StudentInfo
class BatchInfo(models.Model):
batch_name = models.CharField("Batch Name",max_length=20)
batch_started_from = models.DateField("Batch Started From")
no_of_registered_student = models.IntegerField("Number of Registered Student so far",default=0)
def __str__(self):
return self.batch_name
def __unicode__(self):
return self.batch_name
The strange part is that I've used the same style of code in other places which are perfectly functioning.
all_batch = BatchInfo.objects.all()
I try my best to solve it by my own but as a newbie, I found it very difficult for me. So I ask your help. Thanks in advance.
So what I've learned so far about this problem is that there is no definitive answer exists for this particular type of problem. Django shows this error for multiple reasons. So I'm going to list all the scenarios and solutions that I've came across so far for this problem:
Note: I'll keep this answer updated once I get new scenario and their solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With