Re: Overriding admin Media class

2010-04-02 Thread Scot Hacker
On Apr 2, 3:48 pm, Sam Lai wrote: > > And that should work. You need to make sure you have the right imports > for the various classes. I tend to define my forms in a separate > forms.py but that's up to you. Sam, you're a genius - that worked perfectly. Thanks SO much. I really appreciate it.

Re: Overriding admin Media class

2010-04-02 Thread Sam Lai
On 3 April 2010 08:44, Scot Hacker wrote: > Sorry for long delay on this thread. Back at the problem now. > > On Mar 25, 1:22 am, Sam Lai wrote: >> On 25 March 2010 09:25, Scot Hacker wrote: > > OK I've got something similar now, using _media rather than "class > Media:" Now all that remains is

Re: Overriding admin Media class

2010-04-02 Thread Scot Hacker
Sorry for long delay on this thread. Back at the problem now. On Mar 25, 1:22 am, Sam Lai wrote: > On 25 March 2010 09:25, Scot Hacker wrote: > > > > > > > It sounds like you're saying that the model method is not > > attaching to an instance like it usually does (which is why "self" > > doesn'

Re: Overriding admin Media class

2010-03-25 Thread Sam Lai
On 25 March 2010 09:25, Scot Hacker wrote: > > > It sounds like you're saying that the model method is not > attaching to an instance like it usually does (which is why "self" > doesn't work). But I'm no closer to figuring out how why it's > different from model methods accessed from within views

Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker
On Mar 24, 2:08 pm, Shawn Milochik wrote: > > http://docs.python.org/library/functions.html#staticmethod > > It means that the method is function that, when you run it, doesn't > specifically belong to any particular instance, but to the class itself. > > Shawn Thanks Shawn. That URL's not wor

Re: Overriding admin Media class

2010-03-24 Thread Shawn Milochik
> >> The problem is you are defining get_class as >> an instance method and trying to call it is a class method (or static >> method). > > Sorry, I have no idea what you're referring to here, and Googling for > static vs. class methods is not turning up anything I can understand. > Can you show w

Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker
On Mar 24, 12:05 pm, Firat Can Basarir wrote: > Scot you need to learm Python. Do you mean learn *more* Python? Great, I'm always game to learn more! I've taken a Python class and read books and run several Django sites. It's not like I don't know enough Python to be functional. But we're all h

Re: Overriding admin Media class

2010-03-24 Thread Firat Can Basarir
Scot you need to learm Python. The problem is you are defining get_class as an instance method and trying to call it is a class method (or static method). On Wed, Mar 24, 2010 at 8:00 PM, Scot Hacker wrote: > > On Mar 23, 5:32 pm, Paulo Almeida wrote: > > I don't have a working sample (never di

Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker
On Mar 23, 5:32 pm, Paulo Almeida wrote: > 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: > retur

Re: Overriding admin Media class

2010-03-23 Thread Paulo Almeida
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, yo

Overriding admin Media class

2010-03-23 Thread Scot Hacker
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