Django abstract user extension - python

using django abstract user i ran makemigrations and migrate then tried to access my admin it is showin no such table app_user error
I deleted all my migrations except init

Related

Django database migrations are gives no "No migrations to apply." error

Hi I am having issues trying to migrate my django database.
I have a database that definitely cant be cleared/removed, which is what most solutions recommend. However I do want the changes I made to my models to be applied to the database.
I have tried all the following command-sets:
python manage.py makemigrations
python manage.py migrate --run-syncdb
python manage.py makemigrations django_project
python manage.py migrate django_project
python manage.py migrate
python manage.py makemigrations && python manage.py migrate
python manage.py makemigrations django_project
python manage.py migrate --fake-initial
python manage.py migrate
I cleared the migrations folder everytime.
Every set resulted in the same response:
08:59 ~/GluoApi $ python manage.py makemigrations && python manage.py migrate
Migrations for 'django_project':
django_project/migrations/0001_initial.py
- Create model Blacklist
- Create model Like
- Create model Post
- Create model PostReaction
- Create model Profile
- Create model Token
- Create model ReportUser
- Create model ReportPost
- Add field reports to profile
- Add field requests to profile
- Add field user to profile
- Create model PostReactionReport
- Create model PostReactionLike
- Add field likes to postreaction
- Add field post to postreaction
- Add field poster to postreaction
- Add field reports to postreaction
- Add field likes to post
- Add field poster to post
- Add field reports to post
- Add field post to like
- Add field user to like
- Create model GiftLink
- Create model AuthToken
- Create model Article
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, django_project, sessions, sites
Running migrations:
No migrations to apply.
Your models in app(s): 'django_project' have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Have you cleared the django_migrations table in your database too ?
This table contains probably a tuple ('django_project', '0001_initial') which tell to Django that the initial migration has been already applied, so the migrate command tell you there is not migrations to apply.
But you tell, you can't remove the database, so if you just want to apply migration without make the operations, you can call: makemigrations && migrate --fake, for applying the migrations without really change the database

Error when saving data in admin user interface in django

When I enter data into the admin interface to an app in Django using sqlite3 database I got this error:
OperationalError at /admin/products/product/add/
no such table: main.auth_user__old
you have to run python manage.py makemigrations and python manage.py migrate whenevr you do changes on django models.

ProgrammingError when switching from Sqlite3 to Postgresql in django admin console

In django, I have attempted to switch from using an sqlite3 database to postgresql. settings.py has been switched to connect to postgres. Both python manage.py makemigrations and python manage.py migrate run without errors. makemigrations says that it creates the models for the database, however when running migrate, it says there is no changes to be made.
The django server will run, however when clicking on a specfic table in the database in the /admin webpage, it throws the error:
ProgrammingError at /admin/app/tablename/
relation "app_tablename" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "app_tablename"
With the same code (other than settings.py database connection) this worked when using sqlite3.
Happened same thing to me. i deleted the table from database then created the migration again using python manage.py makemigrations . Then i ran that particular migration again using python manage.py migrate myapp 00123 assuming that appname is myapp and migration name is 00123.py
What I did was create a new database and switched to it through the settings.py file. After that, migrations should happen with no problems

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 migration relation does not exist

So I'm trying to run the initial migrations on a django app and when I try to run the migrate command (python manage.py migrate or makemigrations) I get the following error:
psycopg2.ProgrammingError: relation "dotworks_server_internship" does not exist
LINE 1: ...s", "dotworks_server_internship"."questions" FROM "dotworks_...
^
I'm on a Windows environment using Django 1.9.6 and my database is postgres. Plus, I'm using PGAdmin to manage my database.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'dotworks',
'USER': 'postgres',
'PASSWORD': 'mypasswordgoeshere',
'HOST': 'localhost',
'PORT': '5432',
}
}
I had this problem and I had to comment out everything in urls.py that referenced views.py, then run makemigrations. Hope this helps.
Make sure that you don't have any class variables in your code that are calling Django manager
For example:
class SomeViewSet(viewsets.ViewSet):
se = SomeEntity.objects.first() # fetching some entity on the class level
def list(self, request):
# the rest of the code
So, when you try to create/apply migrations, this variable will also try to initialise, and will try to access SomeEntity, but at that moment that entity doesn't even exist, and the error occurs.
If all other solutions mentioned fail, if you are still in development probably the easiest solution is dropping the database (in pgAdmin 4 2.0, right-click on database) and then run makemigrations and migrate.
Try to migrate particular app using following process. Refer Django migrations
python manage.py makemigrations
Initial migration created then run migrate command with app name
python manage.py migrate appname1, appname2
When you run a query before applying migrations this error appears.
If you got this error during python manage.py makemigrations or python manage.py migrate you must consider that makemigrations and migrate commands run after successful django bootstrap! So this error happens when you run a query during django bootstrap! So you must find the place you run this query during bootstrap progress.
For example, during bootstrap, django reads root {project}/urls.py and its nested imports. If you use views or viewsets in urls.py and they are run a query during initializing (in their __init__ method or __init__.pyfile or somewhere etc.), it happens!
In this situation and similars, you must comment out any entry in urls.py and similar files which cause running a query during bootstrap and prevent them from running by raising of exception during bootstrap! makemigrations and migrate need successful bootstrap to be run!
If your commented out code needs to makemigrations and migrate handcooks :D, it needs to be patient and be silent for a cycle or a while ;), and after a successful migrations it could be active and verbose ;D.
Your app is trying to call some DB entries that does not exist.
If you are trying to migrate it to a new database, one of your options is to export a dump of old database and import it to your new DB.
For example in PostgreSQL, import the database using below command then migration will work!
sudo -u postgres -i psql mydb < mydb-export.sql
If you're running in local,
For each Django app (maybe you have only one), erase the content of the migrations folder.
Then, run python manage.py makemigrations app1 app2 app3 (if you have 3 Django apps named app1, app2, app3). This will (re)create the migrations files required to migrate your database
Then, run python manage.py migrate. It will apply the migration files you just created.
This error may have related to previous database error.so if you created new database and you also face that type of error ,you can simply run the command with the app name:
1)python manage.py makemigrations <"app name">
2)python manage.py migrate <"app name">
I've solved this error with this solution.
first remove all url in urls.py .
create simple function view for viewing nothing.
def simple(request):
context = {}
return render(request, 'base.html', context)
and add url to urs.py
do migrate
python manage.py migrate
after migrate,
recover the deleted urls.py contents
:)
For me the error came from some initialization code I put into the app.ready() method. Commenting that part of code allowed me to run the command makemigrations without any issue.
I believe app.ready is called at some point by manage.py even for the makemigrations command, which caused my code to query my database before any migration.
I found the problematic code thanks to the traceback.

Categories

Resources