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

**OperationalError at /at_random:** no such table: generators_generator #1

Closed
SanipRijal opened this issue Dec 20, 2019 · 7 comments
Closed

Comments

@SanipRijal
Copy link

SanipRijal commented Dec 20, 2019

Using the tarot at random button raises the following error:

Environment:
Request Method: GET
Request URL: http://localhost:8000/at_random

Django Version: 2.2.9
Python Version: 3.5.2
Installed Applications:
['essays.apps.EssaysConfig',
'landings.apps.LandingsConfig',
'generators.apps.GeneratorsConfig',
'work_orders.apps.WorkOrdersConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'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']

Template error:
In template /home/sanip/Development/tarot_juicer/templates/base.html, error at line 0
no such table: generators_generator
1 : {% load static %}
2 :
3 : <!doctype html>
4 :
5 :
6 :
7 :
8 :
9 :
10 :

Traceback:

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py" in execute
383. return Database.Cursor.execute(self, query, params)

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

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/sanip/Development/tarot_juicer/generators/views.py" in at_random
13. return render(request, 'generators/at_random.html', context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/shortcuts.py" in render
36. content = loader.render_to_string(template_name, context, request, using=using)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/loader.py" in render_to_string
62. return template.render(context, request)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/backends/django.py" in render
61. return self.template.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render
171. return self._render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/loader_tags.py" in render
150. return compiled_parent._render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in _render
163. return self.nodelist.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render
937. bit = node.render_annotated(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/base.py" in render_annotated
904. return self.render(context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/template/defaulttags.py" in render
308. if match:

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/models/query.py" in bool
278. self._fetch_all()

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all
1242. self._result_cache = list(self._iterable_class(self))

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/models/query.py" in iter
55. results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
1133. cursor.execute(sql, params)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
99. return super().execute(sql, params)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
67. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
76. return executor(sql, params, many, context)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/utils.py" in exit
89. raise dj_exc_value.with_traceback(traceback) from exc_value

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)

File "/home/sanip/.virtualenvs/tarot/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py" in execute
383. return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /at_random
Exception Value: no such table: generators_generator

@enoren5
Copy link
Owner

enoren5 commented Dec 21, 2019

Thanks, @SanipRijal for raising the issue. Although when I click the at random button, nothing happens. This is because I have not yet marked up the GET request into my template, nor have I added any code to my views. Did add some of this code yourself?

@SanipRijal
Copy link
Author

@Angeles89 I did not change any codes but cloned it and started the server. The instructions were followed as it is stated in the README file.

@enoren5
Copy link
Owner

enoren5 commented Dec 22, 2019

Strange. I'm not sure what to make of your trace back because line 16 in my template reads: <button class="btn third">Pull Card At Random</button>. There is no http response or call made to the server yet. It's just placeholder for now. So it shouldn't trigger anything in the Django server console.

The only potential issue I can really think of is that the latest Django release notes state:

Django 2.2 supports Python 3.5, 3.6, 3.7, and 3.8 (as of 2.2.8). We highly recommend and only officially support the latest release of each series

(emphasis mine, but source link here)

You're running Python 3.5.2 and the instructions say they only support the latest release of each series. For the Python 3.5, the latest series would be 3.5.9.

What distro/operating system are you running, @SanipRijal? How easy might it be to try a more recent version of Python?

@SanipRijal
Copy link
Author

Tried your solution but still the error persists. I am using Ubuntu 16.04.6 LTS and have upgraded Python to 3.6.

Looking at the issue, I have found that your "generators" app does not have a migration file due to which the table "generators_generator" is not being created.

@enoren5
Copy link
Owner

enoren5 commented Dec 26, 2019

I figured out the issue, @SanipRijal . You need to add some placeholder content in the fields from the admin dashboard. Just create a supervisor with manage.py, login, and add some Lorem Ipsum stuff. That should get rid of the error you are referring to.

@SanipRijal
Copy link
Author

I am sorry but you are not properly understanding your problem. It is not related with any contents or placeholder, it is related with no tables being created in the database. Why? Because I can see no migration files in your system. Yes I tried migrating, but without any migration files, the models that have been created cannot be reflected in the database. I also created a superuser and tried to add a placeholder but since there is no table named generators created(lack of migration file) in the database, I am unable to add fields as you have mentioned.

I tried to run the system because i saw your post in upwork and just thought of giving it a try. But it does not work. It would be good if you could test the system in a fresh machine and update the README as per the steps you have followed.

@enoren5
Copy link
Owner

enoren5 commented Dec 26, 2019

@SanipRijal

"no such table: generators_generator" means your local db.sqlite3 file inside the project folder doesn't have any tables. The db.sqlite3 file in the project folder is empty by default. You need to fill it with information. All my content will be added later in production. But for the test case, you need to add Lorem Ipsum filler from the superuser Django admin dashboard. For example, you can fill in text like this: https://imgur.com/aV9t8h6

Then you may invoke makemigrations and migrate. At that point the OperationalError with 'no such tables' will finally go away.

The db.sqlite3 is hidden by default in .gitignore. I've commented that line out from my .gitignore and pushed my local db.sqlite3 to my remote repo. That should get red of the 'no such tables' error you are reporting for sure. All you would need to do now is perform $ git pull and it should work.

enoren5 pushed a commit that referenced this issue Mar 19, 2022
Updating abubakar branch against master branch
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