Coder Social home page Coder Social logo

Comments (8)

mmdaz avatar mmdaz commented on June 12, 2024 12

I changed the bases=(models.Model, django_prometheus.models.Mixin) line with bases=(models.Model, django_prometheus.models.ExportModelOperationsMixin('model_name')) and it worked.

I think there is a bug in the library when it wants to create the migration file.

from django-prometheus.

5igm4 avatar 5igm4 commented on June 12, 2024 4

Has there been any progress made on this issue? I'm currently running into it myself.
Django 2.0
django-prometheus==1.0.13
Python 3.6.5

from django-prometheus.

voigt avatar voigt commented on June 12, 2024 1

Was able to fix the issue by removing the line import django_prometheus.models and bases=(django_prometheus.models.Mixin, models.Model), from all migrations.CreateModel.
Afterwards I was able to successfully run the migrations.

...
import django_prometheus.models    <- remove

        migrations.CreateModel(
            name='<name>',
            fields=[
             ...
            ],
            options={
                'ordering': ['...'],
            },
            bases=(django_prometheus.models.Mixin, models.Model),   <- remove
        ),

I have no idea whats happening here. Maybe this helps someone.
The disadvantage is, that if you recreate your migrations you have to do the procedure again...

I am running on

  • Django 1.11
  • django-prometheus 1.0.15
  • Python 3.6.6

from django-prometheus.

chrislat avatar chrislat commented on June 12, 2024 1

Just wondering whether there is an update on this? Perhaps a more elegant fix?

from django-prometheus.

elnappo avatar elnappo commented on June 12, 2024

Same error here:
Django 2.0.2
django-prometheus 1.0.11
Python 3.6.4

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/venv/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
    app_config.ready()
  File "/venv/lib/python3.6/site-packages/django_prometheus/apps.py", line 24, in ready
    ExportMigrations()
  File "/venv/lib/python3.6/site-packages/django_prometheus/migrations.py", line 46, in ExportMigrations
    executor = MigrationExecutor(connections[alias])
  File "/venv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 200, in build_graph
    self.load_disk()
  File "/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 109, in load_disk
    migration_module = import_module("%s.%s" % (module_name, migration_name))
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/code/api/migrations/0001_initial.py", line 10, in <module>
    class Migration(migrations.Migration):
  File "/code/api/migrations/0001_initial.py", line 42, in Migration
    bases=(django_prometheus.models.Mixin, models.Model),
AttributeError: module 'django_prometheus.models' has no attribute 'Mixin'

from django-prometheus.

weijiangan avatar weijiangan commented on June 12, 2024

Was able to fix the issue by removing the line import django_prometheus.models and bases=(django_prometheus.models.Mixin, models.Model), from all migrations.CreateModel.
Afterwards I was able to successfully run the migrations.

...
import django_prometheus.models    <- remove

        migrations.CreateModel(
            name='<name>',
            fields=[
             ...
            ],
            options={
                'ordering': ['...'],
            },
            bases=(django_prometheus.models.Mixin, models.Model),   <- remove
        ),

I have no idea whats happening here. Maybe this helps someone.
The disadvantage is, that if you recreate your migrations you have to do the procedure again...

I am running on

  • Django 1.11
  • django-prometheus 1.0.15
  • Python 3.6.6

I'm doing exactly the same thing right now it's annoying

from django-prometheus.

knicholes avatar knicholes commented on June 12, 2024

Just hit the same issue. Fixed as shown above.

from django-prometheus.

acherry avatar acherry commented on June 12, 2024

Also hit same issue, fixed as above. I did try changing django_prometheus.models.Mixin to django_prometheus.models.ExportModelOperationsMixin just in case it was just a naming issue, but that didn't help. This is in a class that inherits from another Django base model; perhaps that's causing issues? This was the first migration after adding the class. I'm using:

  • Django 2.1.7
  • Python 3.6.7
  • django-prometheus 1.0.15
  • prometheus-client 0.6.0
  • django-simple-history 2.7.0 (only mentioned because it has caused a couple of other migration issues for me)

from django-prometheus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.