I don't have a working sample (never did this), but you may be looking for
something like this:

class Media:
       js = get_path()

And in the class where you keep use_editor:

def get_path(self)
    if self.use_editor:
        return path1
    else:
        return path2

This is just an idea, you'd probably have to tweak the details.

- Paulo

On Tue, Mar 23, 2010 at 9:36 PM, Scot Hacker <shac...@berkeley.edu> wrote:

> Given an admin media class that sets up a rich text editor, like:
>
> class TutorialAdmin(admin.ModelAdmin):
>
>    fields...
>
>    class Media:
>        js = ['/paths/...',]
>
> I would like the ability to selectively override js. I've added a
> "use_editor" boolean to the Tutorial model. The question is, how can I
> detect whether the current instance has that bool set? I'd like to end
> up with something like:
>
>    class Media:
>        if self.use_editor:
>            js = ['/paths',]
>        else:
>            js = ''
>
> But can't find a way to make this work. Anyone have a working sample?
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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.

Reply via email to