Wednesday, December 28, 2016

Define Django Base Model Class

In one of my django projects, I have a base model (that inherits from django.db.models.Model), and is the base model class that all my models uses.
I would like to "override" the base model class from django, so everytime a developer would import the base model class with "from django.db.models import Model", it would insted import my project's custom base model.

The result would be something like this:

from django.db import models

class MyModel(models.Model):
   
pass


>>> type(MyModel)
<class 'MyProject.MyApp.CustomModel'>


Any help would be apreciated!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/649b3b97-17d3-4257-b473-f050440b4d14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment