2👍
So far, I’ve tried different things, all without any success:
- used the managed=False Meta option on both Models
That option (the managed = False
attribute on the model’s meta options) seems to meet the requirements.
If not, you’ll need to expand the question to say exactly what is special about your model that managed = False
doesn’t do the job.
2👍
I thought, I have a problem with makemigrations. It pretends to make migration on managed = False
model, but no SQL code generated for this model
Here is my example, model Smdocumets
unmanaged, and no SQL code was generated.
python manage.py makemigrations
Migrations for 'monitor':
monitor\migrations\0005_auto_20171102_1125.py
- Create model Smdocuments
- Add field sid to db
- Alter field name on db
python manage.py sqlmigrate monitor 0005
BEGIN;
--
-- Create model Smdocuments
--
--
-- Add field sid to db
--
ALTER TABLE "monitor_db" RENAME TO "monitor_db__old";
...
- Django rest auth email instead of username
- Why is django's settings object a LazyObject?
- Django collectstatic no such file or directory
- Convert Python None to JavaScript null
- Passing a user, request to forms
2👍
You have the correct solution:
used the managed=False Meta option on both Models
It may appear that it is not working but it is likely that you are incorrectly preempting the final result when you see - Create model xxx
for models with managed = False
when running makemigrations
.
How have you been checking/confirming that migrations are being made?
makemigrations
will still print to terminal - Create model xxx
and create code in the migration file but those migrations will not actually result in any SQL code or appear in Running migrations:
when you run migrate
.
- How does use_for_related_fields work in Django?
- How to emit SocketIO event on the serverside
- Make browser submit additional HTTP-Header if click on hyperlink
- Why is django's settings object a LazyObject?