Exception Value: no such table: example_post - python

I have a little issue of trying the exemple file from https://github.com/zhebrak/django-statsy
OperationalError at /
no such table: example_post
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.11.5
Exception Type: OperationalError
Exception Value: no such table: example_post
Exception Location: /home/jeremie/.virtualenvs/statsy/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py in execute_sql, line 894
Python Executable: /home/jeremie/.virtualenvs/statsy/bin/python
Python Version: 2.7.12
Python Path:
['/home/jeremie/django-statsy',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/plat-x86_64-linux-gnu',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-tk',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-old',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/jeremie/.virtualenvs/statsy/local/lib/python2.7/site-packages',
'/home/jeremie/.virtualenvs/statsy/lib/python2.7/site-packages',
'/home/jeremie/django-statsy']
Server time: Fri, 15 Sep 2017 15:13:34 -0500
Here is what I have done so far :
git clone https://github.com/zhebrak/django-statsy.git
mkvirtualenv statsy
cd django-statsy
workon statsy
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
I just want to enter inside the example file to see what type of result and test out the app itself. Why do I have the problem? Do you recommend this app if I am working in a project using Django 1.10 and python 2.7?
Update
┌─╼ [~/django-statsy]
└────╼ python2.7 manage.py makemigrations example
Migrations for 'example':
example/migrations/0001_initial.py
- Create model Post
┌─╼ [~/django-statsy]
└────╼ python2.7 manage.py migrate example
Operations to perform:
Apply all migrations: example
Running migrations:
Applying example.0001_initial... OK
Here is the result when I ran localhost:8000 : image
How could I test out the exemple which is given?

Based on your replies in the comments, it's looking like you haven't created the example_post database table. You'll need to add example to your list of INSTALLED_APPS in your settings file, then run through the database migration process:
./manage.py makemigrations
./manage.py migrate
If the example app isn't in INSTALLED_APPS, the database migration files won't be created and the table won't be created as a result.

Related

ValueError: Dependency on app with no migrations: account

I am trying to deploy my code in heroku.
While deploying i complete all the steps
but i get error while migrate
i try these command
heroku run python manage.py makemigrations account
While running above command i get
account/migrations/0001_initial.py
- Create model User
but while trying to migrate
I try
heroku run python manage.py migrate account
i get error
raise ValueError("Dependency on app with no migrations: %s" % key[0])
ValueError: Dependency on app with no migrations: account
i also try
heroku run python manage.py makemigrations
heroku run python manage.py migrate
At this time also i get same error
the project is running successfully in localhost
with out any error
I am new to heroku please anyone can help with full instruction
First try to run command heroku run python manage.py showmigrations to see what migrations have been done.
If it returns an empty list, you have to run heroku run python manage.py migrate to migrate the existing migrations.
After that, you can follow the normal procedures in tutorial
python manage.py makemigrations
python manage.py migrate
my case
(heroku.com)
heroku dashboard
↓
app
↓
deploy
↓
Github
↓
Manual deploy
I was able to migrate

Django error no such table: main.auth_user__old

I'm creating my first Django project. I am getting an error when I press the save button after adding the data to the text fields inside the products. This is the error I get:
OperationalError at /admin/products/product/add/
no such table: main.auth_user__old
Request Method: POST
Request URL: http://127.0.0.1:8080/admin/products/product/add/
Django Version: 2.1
Exception Type: OperationalError
Exception Value:
no such table: main.auth_user__old
Exception Location: C:\Users\Ehtsham\PycharmProjects\firstproject\venv\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296
Python Executable: C:\Users\Ehtsham\PycharmProjects\firstproject\venv\Scripts\python.exe
Python Version: 3.8.1
Python Path:
['C:\\Users\\Ehtsham\\PycharmProjects\\firstproject',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\lib',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages\\setuptools-40.8.0-py3.8.egg',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages\\pip-19.0.3-py3.8.egg']
Server time: Sun, 5 Jan 2020 15:00:27 +0000
I also did migrations before:
(venv) C:\Users\Ehtsham\PycharmProjects\firstproject>python manag
e.py makemigrations
Migrations for 'products':
products\migrations\0002_offers.py
- Create model Offers
(venv) C:\Users\Ehtsham\PycharmProjects\firstproject>python manag
e.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, products, sess
ions
Running migrations:
Applying products.0002_offers... OK
I'm using Django version 2.1 and SQLite DB browser on PyCharm IDE.
It shows your django version is "Django Version:2.1"
You need to upgrade your django. if its a new project.
Please do the following steps.
step:1>> pip install Django --upgrade
step:2 >> python manage.py makemigrations
Step:3 >> python manage.py migrate
Ste:-4 >> python manage.py runserver

south.exceptions.NoMigration – djcelery

I just added a many-to-many relationship to my model and generated the new migration file:
py manage.py schemamigration myapp --auto
Then tried running the migration:
py manage.py migrate myapp
It did not complete successfully, raising a south.exceptions.NoMigrations exception:
south.exceptions.NoMigrations: Application '<module 'djcelery' from 'C:\Python27\lib\site-packages\djcelery\__init__.pyc'>' has no migrations.
No more information is given, and I cannot figure out what might be wrong. Has anybody experienced this issue before?
I am using Python 2.7 and Django 1.4.22.

django: by mistake deleted migration files from production server

By mistake I deleted all the migration files from all apps on production server.
Now running python manage.py makemigrations and then python manage.py migrate raises:
"field already exists in the database"
error for each field, What should I do ?
django version: 1.7.7
If you already migrated and then deleted.Then fake will help you
python manage.py migrate --fake
you have to fake the migration, the next command may help you:
python manage.py migrate 'name_app' 'name_migration' --fake
Example:
python manage.py migrate books 005_auto_20150505 --fake

Add field to existing django app in production environment

I have an existing django app and would like to add a field to a model.
But because the website is already in production, just deleting the database is not an option any more.
These are the steps I took:
pip install south
added 'south' to INSTALLED_APPS
python manage.py syncdb
python manage.py convert_to_south [myapp]
So now I have the initial migration and south will recognize the changes. Then I added the field to my model and ran:
python manage.py schemamigration [myapp] --auto
python manage.py migrate [myapp]
Now I have the following migrations:
0001_initial.py
0002_auto__add_field_myapp_fieldname.py
Which commands should I run on my production server now to migrate? Also should I install south first and then pull the code changes and migrations?
first is to fake the initial migration:
python manage.py migrate [yourapp] --fake 0001
then you can apply the migration to the db
python manage.py migrate [yourapp]
I'm assuming you ran convert_to_south on development, in which case production still wouldn't be aware of the migrations yet. convert_to_south automatically fakes the initial migration for you! If you were to just run migrate on production without faking, it should error.

Categories

Resources