django-prometheus
django-prometheus copied to clipboard
Migrations created cause "syntax error"
Hello,
Here is the versions I'm using
Django 3.0.3
django-prometheus 2.0.0
I have models like
class Foo(ExportModelOperationsMixin('foo'), models.Model):
...
However, whenever I run makemigrations this line is added to the migration, which is invalid python syntax.
bases=(django_prometheus.models.ExportModelOperationsMixin.<locals>.Mixin, models.Model)
Not sure if this is a django problem or a django_prometheus problem but sadly I can't use this package because of this. Any help would be greatly appreciated!
you can always manually edit the migrations scripts Django generates... I have seen cases where django doesn't properly resolve stuff... you can also try: https://github.com/korfuri/django-prometheus/issues/34#issuecomment-340775515
I encountered the same problem, can someone help me?
@YuXiaoCoder have you tried the workaround I mentioned in a previous comment ? https://github.com/korfuri/django-prometheus/issues/217#issuecomment-607435156
I encountered the same problem today. The workaround mentioned does not do anything to the generated migrations.
Repository with the code where I could reproduce the problem: https://gitlab.com/pfpa/pfpa
I guess this is a duplicate of https://github.com/korfuri/django-prometheus/issues/42
@YuXiaoCoder have you tried the workaround I mentioned in a previous comment ? #217 (comment)
It is possible to edit the migration file manually
@YuXiaoCoder have you tried the workaround I mentioned in a previous comment ? #217 (comment)
It is possible to edit the migration file manually
Yes of course. I used the last comment in the suggested issue.
Could somebody please create a PR for it ?
I've got the same problem and I found a work-around.
I created my model without the ExportModelOperationsMixin annotation, ran the makemigration and migrate commands and then added the ExportModelOperationsMixin annotation.
It works :)
Any code solution for this. I cannot manually change the migration files when running tests. my test runs makemigrations to recreate the migrations and then migrate. It is able to make the migrations without error with this line PROMETHEUS_EXPORT_MIGRATIONS = False but it throws a syntax error when migrate command is run because of the
File "/app/apps/form/migrations/0001_initial.py", line 131
bases=(django_prometheus.models.ExportModelOperationsMixin.<locals>.Mixin, models.Model),
^
| SyntaxError: invalid syntax
Anyone able to get past it without the manual changes??