mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Support custom managers in Django models
For the moment this support is limited to just Model.objects replacements and does not use the custom manager for ForeignKey related managers.
This commit is contained in:
@@ -6,9 +6,18 @@ from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class TagManager(models.Manager):
|
||||
def specially_filtered_tags(self):
|
||||
return self.all()
|
||||
|
||||
|
||||
class Tag(models.Model):
|
||||
tag_name = models.CharField()
|
||||
|
||||
objects = TagManager()
|
||||
|
||||
custom_objects = TagManager()
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
category_name = models.CharField()
|
||||
@@ -155,6 +164,16 @@ model_instance.objects.update(x='')
|
||||
#? BusinessModel()
|
||||
model_instance.objects.create()
|
||||
|
||||
# -----------------
|
||||
# Custom object manager
|
||||
# -----------------
|
||||
|
||||
#? TagManager()
|
||||
Tag.objects
|
||||
|
||||
#? TagManager()
|
||||
Tag.custom_objects
|
||||
|
||||
# -----------------
|
||||
# Inheritance
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user