Re: sorting in /admin

2011-03-22 Thread Siara
Hmm i dont know but if you dont realy need 2 separate colums for name
and surname you can define in Customer __unicode__ like that:

def __unicode__(self):
   return self.lastName + " " + self.firstName

and then in list_diplay = ['CustomerId'],
but that solution could give ou another problems

On 22 Mar, 20:10, Bobby Roberts <tchend...@gmail.com> wrote:
> how else would you pull in information from another model into the
> current model list view in admin?
>
> On Mar 22, 2:41 pm, Siara <pawel.skrzyn...@gmail.com> wrote:
>
>
>
> > Why are you doing this way ?
> > The better idea is to make it that way:
>
> > class YourModelAdmin(admin.ModelAdmin):
> >    model = YourModel
> >    list_display = [ 'firstName', 'lastName' ]
>
> > admin.site.register(YourModel, YourModelAdmin)
>
> > and i'm sure then you will be able to sort olums
>
> > On 22 Mar, 19:28, Bobby Roberts <tchend...@gmail.com> wrote:
>
> > > I am listing the following fields from the model in /admin as follows:
>
> > > [...snip...]
>
> > > def Client_Lastname(self, obj):
> > >      return  obj.CustomerId.lastName
>
> > > def Client_Firstname(self, obj):
> > >      return  obj.CustomerId.firstName
>
> > > list_display = ('Client_Firstname', 'Client_Lastname', )
>
> > > [...snip...]
>
> > > The Firstname and Lastname fields from the Client model drop right
> > > into the list fine but I cannot sort on these fields when i click the
> > > column header.  What do I need to do to make them sortable?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sorting in /admin

2011-03-22 Thread Siara
Why are you doing this way ?
The better idea is to make it that way:

class YourModelAdmin(admin.ModelAdmin):
   model = YourModel
   list_display = [ 'firstName', 'lastName' ]

admin.site.register(YourModel, YourModelAdmin)

and i'm sure then you will be able to sort olums

On 22 Mar, 19:28, Bobby Roberts  wrote:
> I am listing the following fields from the model in /admin as follows:
>
> [...snip...]
>
> def Client_Lastname(self, obj):
>      return  obj.CustomerId.lastName
>
> def Client_Firstname(self, obj):
>      return  obj.CustomerId.firstName
>
> list_display = ('Client_Firstname', 'Client_Lastname', )
>
> [...snip...]
>
> The Firstname and Lastname fields from the Client model drop right
> into the list fine but I cannot sort on these fields when i click the
> column header.  What do I need to do to make them sortable?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Unicode string writed on boolean field in model

2011-03-22 Thread Siara
Hi i think that i found 'funny' thing during writing my app.
I have app which returns JSON with data for second app. Interesting
part of my JSON looks like that:

"availability_internet" : "True",
"availability_phone" : "False",

In seconds app models.py i have lines like that:

availability_internet = models.BooleanField(verbose_name = 'Dostępność
przez internet', default=False)
availability_phone = models.BooleanField(verbose_name = 'Dostępność
przez telefon', default=False)

In second app i have script to fetch data from first app and to save
them in database, i'm doing it like that:

model_instance = model(**kwargs)
model_instance.save()

where kwargs is dictionary obtained through JSON.

And now goes the 'funny' thing, during debugging my app i found that
after i save model_instance it has fields like that:

availability_internet - unicode: True
availability_phone -  unicode: False

and that was looking in app admin panel like both fields are set to
True.

I found a way to fix it, but in my opinion i should get error during
model_instance.save().
And there is a question did anyone have similar problem, or could
confirm that this is realy is bug ?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem with DECIMAL_SEPARATOR

2011-03-16 Thread Siara
Thx for help,
DECIMAL_SEPARATOR = ','  wasnt neccesary when USE_L10N=False cause its
default delimeter
On 15 Mar, 20:07, emonk <elmonke...@gmail.com> wrote:
> try this in settings.py
>
> USE_L10N = False
> DECIMAL_SEPARATOR = ','
>
> 2011/3/15 Siara <pawel.skrzyn...@gmail.com>
>
>
>
> > Hi
> > I tried to find solution to my problem on django-developers group and
> > they send me here ;)
> > Ant there is my problem:
> > I'm writing application which return json with data for another app.
> > I'm from Poland so I set LANGUAGE_CODE = 'pl', the problem is that we
> > are using coma instead of dot in float numbers, and setting language
> > to polish changing dot for coma in jsons, but i need dot.
> > I tried DECIMAL_SEPARATOR = '.'  but its doesnt work, it looks like
> > LANGUAGE_CODE is overwriting DECIMAL_SEPARATOR settings.
> > So any ideas how to keep polish internatiolization with
> > DECIMAL_SEPARATOR as dot intead coma ?
>
> > --
> > 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@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Problem with DECIMAL_SEPARATOR

2011-03-15 Thread Siara
Hi
I tried to find solution to my problem on django-developers group and
they send me here ;)
Ant there is my problem:
I'm writing application which return json with data for another app.
I'm from Poland so I set LANGUAGE_CODE = 'pl', the problem is that we
are using coma instead of dot in float numbers, and setting language
to polish changing dot for coma in jsons, but i need dot.
I tried DECIMAL_SEPARATOR = '.'  but its doesnt work, it looks like
LANGUAGE_CODE is overwriting DECIMAL_SEPARATOR settings.
So any ideas how to keep polish internatiolization with
DECIMAL_SEPARATOR as dot intead coma ?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.