django-managers
How to use custom manager with related objects?
I have a custom manager. I want to use it for related objects. I founduse_for_related_fields in docs. But it does not work the way I used it:[详细]
2023-04-06 00:37 分类:问答How to get the data returned by the previous query in the method of custom class manager?
I developing a custom manager class with chainable method. Got a problem. I need to randomize filtered query. To get a random record I need a count of filtered and distinct records. But I don\'t know[详细]
2023-04-05 18:27 分类:问答Returning a custom model instance from a manager
I have a model that looks like this and stores data as key-value pairs. class Setting(models.Model): company = models.ForeignKey([详细]
2023-04-04 06:40 分类:问答What functions do the order of Django Managers affect?
So, I\'ve read most of the docs and I\'ve been looking around on SO a bit, but I can\'t quite find the answer to my question. I\'ll start with the code.[详细]
2023-03-23 14:10 分类:问答django soft delete doesn't cascade delete
I\'m using a soft delete in my django admin, done like this. The issue is that when I delete a foreign key item, that it doesn\'t seem to trigger the deletes for all the items it\'s linked to. Or may[详细]
2023-03-17 15:32 分类:问答Help with creating a custom create and a custom get method
I have two models like so: class Visit(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=65535, null=False)[详细]
2023-03-17 01:04 分类:问答Using Django custom manager function on an already filtered queryset
Consider the following case: class MyModelManager(models.Manager): def my_filter(self): return [some code here].filter(field_A__gt=3)[详细]
2023-03-01 11:19 分类:问答Custom Chainable QuerySet
This is a piece of my code from django.db import models from django.db.models.query import QuerySet from mptt.models import MPTTModel[详细]
2023-02-25 01:43 分类:问答Method to create a model instance based on a request object
I have a model like this: class UserSubmission(models.Model): mantra = models.CharField(max_length=64) ip = models.CharField(max_length=15) # xxx.xxx.xxx.xxx[详细]
2023-02-14 01:21 分类:问答Django and the domain layer
How to organize my domain layer using django? I know I can write custom managers to hold my queries b开发者_StackOverflow中文版ut what if I want something more flexible like the specification pattern[详细]
2023-01-27 01:58 分类:问答