Re: Fluent interface on custom methods of custom Queryset class

2017-07-19 Thread Felippe Raposo
t=True) objects = models.Manager.from_queryset(ProcedureQuerySet)() Warmly, Felippe Raposo 2017-07-19 11:50 GMT-03:00 Fabio C. Barrionuevo da Luz : > What is the right way to make Fluent interface on custom methods of custom > Queryset class? > > In other words, how to make "by

Fluent interface on custom methods of custom Queryset class

2017-07-19 Thread Fabio C. Barrionuevo da Luz
What is the right way to make Fluent interface on custom methods of custom Queryset class? In other words, how to make "by_validity" work without lost previous filters? Procedure.objects.filter(is_active=False).by_validity() I've tried using q = self or q = self.query

How to sort by many custom methods in Django Admin

2014-07-10 Thread 9devmail
I want to be able to sort by several custom methods in Django Admin. This question on StackOverflow <http://stackoverflow.com/questions/2168475/django-admin-how-to-sort-by-one-of-the-custom-list-display-fields-that-has-no-d> provides solution for one method only. I tried to mod

Re: Returning values from calculations done by custom methods in models

2012-02-18 Thread Gchorn
Whoops, wow that really was basic Python. Sorry for the spam; of course I know there's a difference between calling a method and calling an attribute...how embarassing. =) Thanks for your help Anssi. Also thanks for not adding, ", you moron!" to the end of each sentence... On Feb 19, 9:47 am, a

Re: Returning values from calculations done by custom methods in models

2012-02-18 Thread akaariai
On Feb 19, 3:38 am, Gchorn wrote: > Hello All, > > So in my models.py file, I have: > > class Player(models.Model): >         team = models.ForeignKey(Team) >         first_name = models.CharField(max_length=100) >         last_name = models.CharField(max_length=100) >         gp = models.IntegerF

Returning values from calculations done by custom methods in models

2012-02-18 Thread Gchorn
Hello All, So in my models.py file, I have: class Player(models.Model): team = models.ForeignKey(Team) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) gp = models.IntegerField(max_length=2) #games played mp = model

Re: dynamic forms and custom methods

2010-08-12 Thread Nick
I think jquery may be the right way to go for this. It will allow you to evaluate the weights in real time so you won't have to submit the form before any validation errors would be returned. Working it at the model level may get tricky, for ease I would handle it at the form or view level. On Au

Re: dynamic forms and custom methods

2010-08-12 Thread Steve Holden
On 8/12/2010 8:36 AM, lingrlongr wrote: > Hi Nick, > > Thanks for the reply. Yes, the department weights will be used in a > grading scheme. One department may be 25% (0.25), etc... But in the > end, the weights should total 1.0. For example, in my Store model: > > class Store(models.Model):

Re: dynamic forms and custom methods

2010-08-12 Thread lingrlongr
Hi Nick, Thanks for the reply. Yes, the department weights will be used in a grading scheme. One department may be 25% (0.25), etc... But in the end, the weights should total 1.0. For example, in my Store model: class Store(models.Model): #...etc... def _get_total_dept_weight(self):

Re: dynamic forms and custom methods

2010-08-11 Thread Nick
Are you trying to create a save function that evaluates all the weights and returns an error if they are more than 1? On Aug 10, 3:17 pm, lingrlongr wrote: > I 'm trying to create a form dynamically.  This works just fine, but > there's no way for the form to offer any customized validation, by w

dynamic forms and custom methods

2010-08-10 Thread lingrlongr
I 'm trying to create a form dynamically. This works just fine, but there's no way for the form to offer any customized validation, by way of the clean() method. def get_dept_weight_form(store): fields = {} s = Store.objects.get(pk=store.id) for d in store.department_set.all():

Re: custom methods

2009-09-08 Thread Daniel Roseman
On Sep 8, 7:29 pm, Slammer wrote: > FYI, I'm a beginner,  I'm having trouble with custom methods,  I'm > using an existing database which is used for a fantasy football > site,   the primary data return is a list of players for a particular > team, I've done th

Re: custom methods

2009-09-08 Thread Angel Cruz
Here is my total: {{my_total}} On Tue, Sep 8, 2009 at 11:29 AM, Slammer wrote: > > FYI, I'm a beginner, I'm having trouble with custom methods, I'm > using an existing database which is used for a fantasy football > site, the primary data return is a list of player

custom methods

2009-09-08 Thread Slammer
FYI, I'm a beginner, I'm having trouble with custom methods, I'm using an existing database which is used for a fantasy football site, the primary data return is a list of players for a particular team, I've done that fine, but the score for those players is in a dif

Re: Custom methods for ManyToManyManager

2007-11-20 Thread Tomi Pieviläinen
> I've been hacking some filtering for related managers, have a look at > the BoxManager > here:http://django-pm.googlecode.com/svn/trunk/myproject/pm/models.py Thanks for food for thoughts. Looking at your code got me thinking and in the end my problem was really simple. I was using the example

Re: Custom methods for ManyToManyManager

2007-11-16 Thread Samuel Adam
I've been hacking some filtering for related managers, have a look at the BoxManager here: http://django-pm.googlecode.com/svn/trunk/myproject/pm/models.py My app misses the user.inbox.new() feature, i will add it soon. :) On Nov 16, 2:18 pm, "Tomi Pieviläinen" <[EMAIL PROTECTED]> wrote: > Hi gr

Re: Custom methods for ManyToManyManager

2007-11-16 Thread Samuel Adam
I've added it, line 228 On Nov 16, 3:32 pm, Samuel Adam <[EMAIL PROTECTED]> wrote: > I've been hacking some filtering for related managers, have a look at > the BoxManager > here:http://django-pm.googlecode.com/svn/trunk/myproject/pm/models.py > > My app misses the user.inbox.new() feature, i wi

Custom methods for ManyToManyManager

2007-11-16 Thread Tomi Pieviläinen
Hi group, Is it possible to have custom filtering methods for MTMManagers? More precisely I'd like to be able to use user.received_messages.new in my templates. I can define a custom manager for my Message model with a custom new method, but unfortunately this returns all new messages in the syst

returning bools from custom methods

2007-03-30 Thread Eric Spaulding
Hello -- I've added a custom method to a model that returns a boolean -- I've tried something like this: class Liquid(models.Model): # ... def ruins_everything(self): return bool(0) ... which does show up as "False" in the list of the admin. What I'm wondering is, what would I

Re: Using custom methods in queryset lookups

2007-03-19 Thread Tim Chase
> Now, I want to select all records whose duration (end_time - > start_time) is more than 2 hours. > > I tried a custom method in the model like this which returns the > duration but cannot figure out how to use it in queryset filters. Filtering by calculated fields is best done on the server si

Using custom methods in queryset lookups

2007-03-19 Thread Sambhav
Hi everyone, A simplified version of my model looks like this: class Schedule(models.Model): start_time = models.DateTimeField('Start Time') end_time = models.DateTimeField('End Time') event = models.CharField(maxlength=100) Now, I want to select all records whose duration (end_time