mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-30 18:05:21 +08:00
Merge branch 'django-custom-object-manager' of https://github.com/PeterJCLaw/jedi into django
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()
|
||||
@@ -49,6 +58,9 @@ class BusinessModel(models.Model):
|
||||
|
||||
unidentifiable = NOT_FOUND
|
||||
|
||||
def method(self):
|
||||
return 42
|
||||
|
||||
# -----------------
|
||||
# Model attribute inference
|
||||
# -----------------
|
||||
@@ -132,6 +144,11 @@ model_instance.unidentifiable
|
||||
#! ['unidentifiable = NOT_FOUND']
|
||||
model_instance.unidentifiable
|
||||
|
||||
#? int()
|
||||
model_instance.method()
|
||||
#! ['def method']
|
||||
model_instance.method
|
||||
|
||||
# -----------------
|
||||
# Queries
|
||||
# -----------------
|
||||
@@ -147,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