Re: mark_safe() not working for me

2008-11-25 Thread Lars Stavholm

Right you are Daniel, works like a charm, thank you!
/L

Daniel Roseman wrote:
> On Nov 25, 4:50 pm, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>> I'm trying to influence one of the admin interface change list
>> fields by using the below get_progress() method in list_display,
>> and using mark_safe().
>>
>> However, I can't get this to work:
>>
>> class Job(models.Model):
>>  progress = models.PositiveSmallIntegerField()
>>
>>  def get_progress(self):
>>  snippet = u"Progress is %d" % self.progress
>>  return mark_safe(snippet)
>>
>> What happens is that the "" and "" gets translated into
>> "p" and "/p" in the output. I thought mark_safe()
>> would help me to avoid that. Obviously not right.
>>
>> Is there another way to tell django not to escape the output?
>>
>> Any ideas appreciated
>> /Lars
> 
> To get HTML into the change_list view, you need to use allow_tags:
> 
>  def get_progress(self):
>  snippet = u"Progress is %d" % self.progress
>  return mark_safe(snippet)
> get_progress.allow_tags=True
> 
> --
> DR.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mark_safe() not working for me

2008-11-25 Thread Daniel Roseman

On Nov 25, 4:50 pm, Lars Stavholm <[EMAIL PROTECTED]> wrote:
> I'm trying to influence one of the admin interface change list
> fields by using the below get_progress() method in list_display,
> and using mark_safe().
>
> However, I can't get this to work:
>
> class Job(models.Model):
>      progress = models.PositiveSmallIntegerField()
>
>      def get_progress(self):
>          snippet = u"Progress is %d" % self.progress
>          return mark_safe(snippet)
>
> What happens is that the "" and "" gets translated into
> "p" and "/p" in the output. I thought mark_safe()
> would help me to avoid that. Obviously not right.
>
> Is there another way to tell django not to escape the output?
>
> Any ideas appreciated
> /Lars

To get HTML into the change_list view, you need to use allow_tags:

 def get_progress(self):
 snippet = u"Progress is %d" % self.progress
 return mark_safe(snippet)
get_progress.allow_tags=True

--
DR.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mark_safe() not working for me

2008-11-25 Thread Lars Stavholm

I'm trying to influence one of the admin interface change list
fields by using the below get_progress() method in list_display,
and using mark_safe().

However, I can't get this to work:

class Job(models.Model):
 progress = models.PositiveSmallIntegerField()

 def get_progress(self):
 snippet = u"Progress is %d" % self.progress
 return mark_safe(snippet)

What happens is that the "" and "" gets translated into
"p" and "/p" in the output. I thought mark_safe()
would help me to avoid that. Obviously not right.

Is there another way to tell django not to escape the output?

Any ideas appreciated
/Lars


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---