Sunday, May 26, 2019

Re: What is this error mean and what can I do

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
On 27 May 2019, 01:15 +0300, Saeed Pooladzadeh <lingo1357@gmail.com>, wrote:

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

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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.

No comments:

Post a Comment