Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable save table after making changes in the model.py file #58

Open
DHAVALdesai13 opened this issue May 22, 2019 · 1 comment
Open

Comments

@DHAVALdesai13
Copy link

I have installed the django-excel tutorial app and made changes to its model.py file.

I have done the following steps :

  1. python manage.py makemigrations polls

Output : Migrations for 'polls': polls\migrations\0001_initial.py - Create model hpcl

  1. python manage.py migrate polls

output : Operations to perform: Apply all migrations: polls Running migrations: No migrations to apply.

Model.py file

from django.db import models

class hpcl(models.Model):
    plannedPLT = models.IntegerField(default=0)
    pub_date = models.DateTimeField('date published')
    consumption = models.IntegerField(default=0)
    required_PLT = models.CharField(max_length=200)


    def __str__(self):
        return self.pub_date

Request Method: POST
Request URL: http://127.0.0.1:8000/polls/import/

Django Version: 2.2.1
Python Version: 3.7.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in _execute
84. return self.cursor.execute(sql, params)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
383. return Database.Cursor.execute(self, query, params)

The above exception (no such table: polls_hpcl) was the direct cause of the following exception:

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\dhaval1.desai\Documents\Notes\Feedstock\Django-excelV2\django-excel-master\polls\views.py" in import_data
53. ['plannedPLT', 'pub_date', 'consumption', 'required_PLT']

File "C:\Users\dhaval1.desai\Documents\Notes\Feedstock\Django-excelV2\django-excel-master\django_excel_init_.py" in save_book_to_database
63. pe.save_book_as(**params)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel\core.py" in save_book_as
112. return sources.save_book(book, **dest_keywords)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel\internal\core.py" in save_book
56. return _save_any(a_source, book)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel\internal\core.py" in _save_any
60. a_source.write_data(instance)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel\plugins\sources\db_sources.py" in write_data
111. **self._keywords

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel\plugins\renderers\django.py" in render_book_to_stream
75. **keywords

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel_io\io.py" in save_data
129. **keywords

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel_io\io.py" in store_data
146. writer.write(data)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel_io\book.py" in write
221. sheet_writer.close()

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\pyexcel_io\database\importers\django.py" in close
58. an_object.save()

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py" in save
741. force_update=force_update, update_fields=update_fields)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py" in save_base
779. force_update, using, update_fields,

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py" in _save_table
870. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py" in _do_insert
908. using=using, raw=raw)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py" in _insert
1186. return query.get_compiler(using=using).execute_sql(return_id)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
1335. cursor.execute(sql, params)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in execute
99. return super().execute(sql, params)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in execute
67. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in _execute_with_wrappers
76. return executor(sql, params, many, context)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in _execute
84. return self.cursor.execute(sql, params)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py" in exit
89. raise dj_exc_value.with_traceback(traceback) from exc_value

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in _execute
84. return self.cursor.execute(sql, params)

File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
383. return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /polls/import/
Exception Value: no such table: polls_hpcl

@mindansung
Copy link

have you managed to fix this issue? I get same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants