What is this error mean and what can I do

21 views
Skip to first unread message

Saeed Pooladzadeh

unread,
May 26, 2019, 6:14:51 PM5/26/19
to Django users

Hi

This is my model:
from django.db import models
from django.conf import settings


# Create your models here.
class Smodel(models.Model):
    eid=models.IntegerField()
    elogin = models.CharField(max_length=8) 
    epassword= models.CharField(max_length=8) 
  
    elikeDay=models.IntegerField()
    efollowPerDay=models.IntegerField()
    

   
    #esession = models.TextField()
    class Meta:  
        db_table = "saeed"  

And I get this error:

OperationalError at /emp

no such table: saeed
Request Method:POST
Request URL:http://localhost:50021/emp
Django Version:2.2
Exception Type:OperationalError
Exception Value:
no such table: saeed
Exception Location:E:\Django_Try\bot4\bot3\env\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 383
Python Executable:E:\Django_Try\bot4\bot3\env\Scripts\python.exe
Python Version:3.6.6
Python Path:
['E:\\Django_Try\\bot4\\bot3',
 '',
 'E:\\Django_Try\\bot4\\bot3',
 'E:\\Django_Try\\bot4\\bot3\\env\\Scripts\\python36.zip',
 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\DLLs',
 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib',
 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64',
 'E:\\Django_Try\\bot4\\bot3\\env',
 'E:\\Django_Try\\bot4\\bot3\\env\\lib\\site-packages']
Server time:Sun, 26 May 2019 22:05:31 +0000

What is mean and what can I do?

tnanks
Saeed

ramadhan ngallen

unread,
May 26, 2019, 7:18:25 PM5/26/19
to Django users
You got this error because you didn't perform migrations to create the table in your database 

Run>> python manage.py makemigrations

It will create migration number under migrations. Then make sqlmigrations

>> python manage.py sqlmigration <name of your app>  <migration number> 
It will create sql scripts to create a table on your database, then make migrations

>>python manage.py migrate


You may skip sqlmigration and still table will be created but is the best practice to run it so that you can preview how table will look like.
Remeer to perform migrations each time you create or modify your models

Best Regards

Ramadhan Ngallen
--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cf149a11-d875-4d5f-b5be-85dead85fdb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saeed Pooladzadeh

unread,
May 26, 2019, 7:39:02 PM5/26/19
to Django users
But I performed migration many time!!

در دوشنبه 27 مهٔ 2019، ساعت 3:48:25 (UTC+4:30)، ramadhan ngallen نوشته:
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Chandrashekhar Singh

unread,
May 27, 2019, 10:20:37 AM5/27/19
to django...@googlegroups.com
Yes I think you should first do "makemigrations" and then run migrate

--
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.
Reply all
Reply to author
Forward
0 new messages