Re: Django Admin does not use `get_FOO_display`

2023-04-05 Thread Opeoluwa Fatunmbi
calling the field's get_FOO_display method. To make use of your overridden get_status_display method in the admin, you can set the flatchoices attribute of the field to None or remove the attribute altogether. This will cause the admin to call the get_status_display method instead

Django Admin does not use `get_FOO_display`

2023-04-04 Thread 'Ibrahim Abou Elenein' via Django users
, field, empty_value_display): from django.contrib.admin.templatetags.admin_list import _boolean_icon if getattr(field, "flatchoices", None): return dict(field.flatchoices).get(value, empty_value_display) ``` I changed it to use get_FOO_display and it worked, my question is why do

Re: get_FOO_display not working ?

2020-02-23 Thread Yves de Champlain
to finalize the list prior to running migrate. > > Not much help I know > > Good luck > > Mike > > Original message > From: Yves de Champlain > Date: 23/2/20 15:47 (GMT+10:00) > To: Django users > Subject: get_FOO_display not wor

Re: get_FOO_display not working ?

2020-02-23 Thread Yves de Champlain
Hi Actually, the human readable value is not (‘Draft’) but _(‘Draft’) which is shorthand for gettext_lazy(‘Draft’) Yves > Le 22 févr. 2020 à 23:54, Nde Nguti a écrit : > > CHOICES =(('draft', 'Draft'), ) > > On Sun, Feb 23, 2020, 05:48 Yves de Champlain > wrote:

RE: get_FOO_display not working ?

2020-02-22 Thread Mike Dewhirst
to fill up choices lists with just that outcome. I had to finalize the list prior to running migrate.Not much help I knowGood luckMike Original message From: Yves de Champlain Date: 23/2/20 15:47 (GMT+10:00) To: Django users Subject: get_FOO_display not working ? HiI'm

Re: get_FOO_display not working ?

2020-02-22 Thread Nde Nguti
CHOICES =(('draft', 'Draft'), ) On Sun, Feb 23, 2020, 05:48 Yves de Champlain wrote: > Hi > > I'm using StatusModel from models_utils : > > class MetaData(TimeStampedModel, StatusModel, SoftDeletableModel): > STATUS = Choices(('draft', _('Draft')), > ('submitted',

Re: get_FOO_display not working ?

2020-02-22 Thread Nde Nguti
Try ('draft', 'Draft') not ('draft', ('Draft')) On Sun, Feb 23, 2020, 05:48 Yves de Champlain wrote: > Hi > > I'm using StatusModel from models_utils : > > class MetaData(TimeStampedModel, StatusModel, SoftDeletableModel): > STATUS = Choices(('draft', _('Draft')), >

get_FOO_display not working ?

2020-02-22 Thread Yves de Champlain
Hi I'm using StatusModel from models_utils : class MetaData(TimeStampedModel, StatusModel, SoftDeletableModel): STATUS = Choices(('draft', _('Draft')), ('submitted', _('Submitted')), ('underreview', _('Underreview')), ) Forms

Re: get_FOO_display() for generic/variable choice fields

2012-01-27 Thread Michael Elkins
On Tue, Jan 24, 2012 at 03:51:27AM -0800, katstevens wrote: Obviously the 'val = obj.get_field_display()' line doesn't work! Is there a generic way of doing this (something like obj.get_display(fieldname) ?) or am I going to have to hard code separate checks for get_country_display() and

Re: get_FOO_display() for generic/variable choice fields

2012-01-25 Thread katstevens
= choices_lookup_dict[field.name][val] row.append(val) We assume that get_FOO_display() must be doing something like this anyway! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@google

Re: get_FOO_display() for generic/variable choice fields

2012-01-24 Thread Bill Freeman
Maybe try: val = getattr(obj, 'get_%s_display' % field.name)() On 1/24/12, katstevens wrote: > I have a model ContactDetail with two choice fields, > ContactDetail.dialing_code and ContactDetail.country. These use the > standard tuples ('AU', 'Australia') and so on. > >

get_FOO_display() for generic/variable choice fields

2012-01-24 Thread katstevens
I have a model ContactDetail with two choice fields, ContactDetail.dialing_code and ContactDetail.country. These use the standard tuples ('AU', 'Australia') and so on. I know I can use get_country_display() and get_dialing_code_display() to show the longer values, but is there a more generic

Re: get_FOO_display

2011-12-13 Thread Mike Dewhirst
Absolutely. I went back and found where I had made it work previously and that is exactly what I did. I just had a (hopefully) temporary blur. Thanks Mike On 13/12/2011, at 8:47 PM, Ilian Iliev wrote: > Or you can change your field to IntegerField instead of CharField if

Re: get_FOO_display

2011-12-13 Thread Ilian Iliev
Or you can change your field to IntegerField instead of CharField if you are planning to have only Integer values for the choices. -- eng. Ilian Iliev Web Software Developer Mobile: +359 88 66 08 400 Website: http://ilian.i-n-i.org On Tue, Dec 13, 2011 at 9:53 AM, Mike Dewhirst

Re: get_FOO_display

2011-12-12 Thread Mike Dewhirst
On 13/12/2011 5:21pm, kenneth gonsalves wrote: On Tue, 2011-12-13 at 17:16 +1100, Mike Dewhirst wrote: THINGS = ( (0, 'Thing Zero'), (1, 'Thing One'), ) what happens when you do: THINGS = ( ('0', 'Thing Zero'), ('1', 'Thing One'), ) By golly it worked!

Re: get_FOO_display

2011-12-12 Thread kenneth gonsalves
On Tue, 2011-12-13 at 17:16 +1100, Mike Dewhirst wrote: > THINGS = ( (0, 'Thing Zero'), > (1, 'Thing One'), ) what happens when you do: THINGS = ( ('0', 'Thing Zero'), ('1', 'Thing One'), ) -- regards Kenneth Gonsalves -- You received this message because you

get_FOO_display

2011-12-12 Thread Mike Dewhirst
the error is ... Please correct the error below. Value u'1' is not a valid choice. This is Django 1.4 pre-alpha SVN-17200 running on Windows XP SP3 and Python 2.7 I'm 99% sure I have had get_FOO_display() working in the past. Can anybody please show me the error of my ways? Thanks Mike

[1.3] get_FOO_display() and prepopulated_fields?

2011-10-18 Thread Micky Hulse
Hello, Are there any tricks to getting the display value of a choice field to work with prepopulated_fields slug creation in the admin? class Team(Base): MALE = 1 FEMALE = 2 GENDER_CHOICES = ( (MALE, u'Men'), (FEMALE, u'Women'), ) slug =

Re: Utilization of get_FOO_display()

2010-02-08 Thread Karen Tracey
On Mon, Feb 8, 2010 at 8:51 AM, mf wrote: > I want to show the human-readable name for the type selected but I > keep getting the stored value. > > TYPE_CHOICES = ( >('0', 'Basic'), >('1', 'Full'), >('2', 'Intermediate'), > ) > > class

Utilization of get_FOO_display()

2010-02-08 Thread mf
I want to show the human-readable name for the type selected but I keep getting the stored value. TYPE_CHOICES = ( ('0', 'Basic'), ('1', 'Full'), ('2', 'Intermediate'), ) class ServiceType(models.Model): type = models.IntegerField(max_length=1,

Re: get_FOO_display

2009-02-06 Thread Alex Koshelev
get_FOO_display is an instance method not field. So try this: {{ object.get_invoice_type_display }} On Fri, Feb 6, 2009 at 6:09 PM, Alfonso <allanhender...@gmail.com> wrote: > > I've got a field called 'invoice_type' which is a ChoiceField. > > In my template I'm

get_FOO_display

2009-02-06 Thread Alfonso
I've got a field called 'invoice_type' which is a ChoiceField. In my template I'm trying to pull out the 'humanized' invoice type by using {{ object.invoice_type.get_invoice_type_display }} but django's not happy. I'm guessing it's because of the invoice[underscore]type syntax I used? Any

Re: get_FOO_display() and Update Messages

2008-05-03 Thread Karen Tracey
On Sat, May 3, 2008 at 2:15 AM, Greg Taylor <[EMAIL PROTECTED]> wrote: > > I was wondering if there's any reason why get_FOO_display() calls > aren't being evaluated when updating/adding new objects via the admin > interface. What I mean by this is: > > The workout &quo

Re: get_FOO_display() and Update Messages

2008-05-03 Thread dimrub
Yay another fitness app based on django! http://code.google.com/p/fiteat/ On May 3, 9:15 am, Greg Taylor <[EMAIL PROTECTED]> wrote: > I was wondering if there's any reason why get_FOO_display() calls > aren't being evaluated when updating/adding new objects via the admin > in

get_FOO_display() and Update Messages

2008-05-03 Thread Greg Taylor
I was wondering if there's any reason why get_FOO_display() calls aren't being evaluated when updating/adding new objects via the admin interface. What I mean by this is: The workout "1" was changed successfully. Instead of: The workout "Running" was changed succ

Re: get_foo_display doesn't work with integers?

2007-12-29 Thread Florian Apolloner
I found the issue (or non issue, whatever you like ;)) get_test_char_display() calls the field's choices with a string (of course it is a CharField), which results in the following call (stripped down talen from django/db/models/base.py: dict(choices).get(value,value) Now accesing it with a

Re: get_foo_display doesn't work with integers?

2007-12-29 Thread Florian Apolloner
> Error is in the way you use it. Please write full model and usage > example. As you wish :) blubb/models.py: from django.db import models # Create your models here. MY_CHOICES = ( (1, '11'), (2, '12') ) class TestModel(models.Model): test_blubb =

Re: get_foo_display doesn't work with integers?

2007-12-29 Thread Alex Koshelev
Error is in the way you use it. Please write full model and usage example. On 29 дек, 23:54, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > apollo13 pointed this out on the IRC channel: > If your choices use an integers, get_foo_display returns the integer > and not th

get_foo_display doesn't work with integers?

2007-12-29 Thread [EMAIL PROTECTED]
apollo13 pointed this out on the IRC channel: If your choices use an integers, get_foo_display returns the integer and not the "human readable" option. For example, reworking this from the docs: YEAR_IN_SCHOOL_CHOICES = ( (1, 'Freshman'), (2, 'Sophomore'), (3, 'Junior

Re: Using get_FOO_display() in admin classes

2007-04-23 Thread oggie rob
ED]> wrote: > Django-0.96. I've discovered the get_FOO_display() function that I get for > free when I use a "choices=CHOICES" in a model, and I understand how to use > it in a template or in the API. But the problem I'm having is that when I > save something with a choices attr

Using get_FOO_display() in admin classes

2007-04-23 Thread Hancock, David (DHANCOCK)
Django-0.96. I've discovered the get_FOO_display() function that I get for free when I use a "choices=CHOICES" in a model, and I understand how to use it in a template or in the API. But the problem I'm having is that when I save something with a choices attribute, editing that object su

Re: Does django provide a parse_FOO_display? ie. get_FOO_display reverted.

2007-03-27 Thread Malcolm Tredinnick
On Tue, 2007-03-27 at 19:11 -0700, Alex Dong wrote: > Hi Folks, > > I'm wondering are there any "parse_FOO_display" method for the django > models? > > For example: {{{ > class Transaction(models.Model): > STATUS = ( > (1, 'Canceled_Reversal'), > (2, 'Completed'),

Does django provide a parse_FOO_display? ie. get_FOO_display reverted.

2007-03-27 Thread Alex Dong
Hi Folks, I'm wondering are there any "parse_FOO_display" method for the django models? For example: {{{ class Transaction(models.Model): STATUS = ( (1, 'Canceled_Reversal'), (2, 'Completed'), (3, 'Pending'), (4, 'Refunded'), (5,

Re: get_FOO_display and grouped data

2006-12-04 Thread Ross Burton
Jacob Kaplan-Moss wrote: > Try:: > > {% regroup feature.task_set.all|dictsortreversed:"priority" by > get_priority_display as grouped %} > > That is, the "by" argument to {% regroup %} doesn't just have to be a field > name; it can be anything that a variable could resolve. Excellent, thanks.

Re: get_FOO_display and grouped data

2006-12-04 Thread Jacob Kaplan-Moss
On 12/4/06 4:34 PM, Ross Burton wrote: > In my view, I'm grouping the data on the priority: > > {% regroup feature.task_set.all|dictsortreversed:"priority" by priority > as grouped %} > {% for group in grouped %} > {{ group.grouper }} > > However, when I do this, group.grouper expands to "0"

get_FOO_display and grouped data

2006-12-04 Thread Ross Burton
Hi, I have a model with an integer field that uses choices for display names: class Task(models.Model): PRIORITY_CHOICES = ( ('0', 'Low'), ('1', 'Normal'), ('2', 'High') ) priority = models.IntegerField(choices=PRIORITY_CHOICES) In my view, I'm grouping the

get_FOO_display for a grouper

2006-11-08 Thread sorrison
I have a class with a "site" field that uses choices I want to display the human readable name for it when being used as a grouper i thought something like site.get_grouper_display or get_site.grouper_display but that doesn't work here is the template code {% regroup