question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

django.db.models.get_model is deprecated

See original GitHub issue

The alias will be dropped in Django 1.9. Just need to update swapper.load_model to use django.db.models.loading.get_model instead.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
mauritsvanreescommented, Jun 9, 2015

Using django.db.models.loading.get_model gets you a second deprecation warning, so this does not help. But it points in the right direction. The loading module has the pointers to the new locations. So you can look in loading.py to see where you should import it from. In this case you should use django.apps.apps.get_model.

Note: I am not using the django-swappable-models project, but this is currently the top link when Googling for django.db.models.get_model is deprecated. 😃

0reactions
mauritsvanreescommented, Mar 18, 2019

Yes, according to the above comment this was fixed more than three years ago in pull request #9. Looking at the commit this was added already in swapper version 0.3.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django: Get model from string?
As of Django 1.7 the django.db.models.loading is deprecated (to be removed in 1.9) in favor of the the new application loading system. --...
Read more >
Replace use of django.db.models.get_model with ...
caused by utils/app_loading.py importing django.db.models.loading ; that entire module is deprecated. There is a pull request #1137 on this ...
Read more >
Model Meta options
A model's database table name is constructed by joining the model's “app label” – the name you used in manage.py startapp – to...
Read more >
django-simple-history - Read the Docs
django-simple-history stores Django model state on every create/update/delete. ... changeReason is deprecated and will be removed in version 3.0.0 (gh-655) ...
Read more >
django-deprecate-fields
This package allows deprecating model fields and allows removing them in a backwards compatible manner.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found