Re: Re: Templates for unknown object types

2006-12-18 Thread Crispin Bennett
> > It's not a particularly bad idea; having an object carry with it > standardized information which tells you what template to use to > display it would be pretty easy (assuming, of course, that you have > the ability to lay out the model classes to support that). > Fortunately my models make t

Re: Re: Templates for unknown object types

2006-12-18 Thread James Bennett
On 12/18/06, Crispin Bennett <[EMAIL PROTECTED]> wrote: > I was primarily wondering whether there's a 'natural' Django idiom or > pattern for doing this kind of thing. My first crude attempt is to > have a method in the model that provides a predictable template name > for the object. Then in my m

Re: Re: Templates for unknown object types

2006-12-18 Thread James Bennett
On 12/18/06, Alan Trick <[EMAIL PROTECTED]> wrote: > Actually every class instance has a __str__ method. If it's not > over-ridden, it gets the one inherited from object (which is probably > not what you want, but it's still there). Yeah, what I wanted to get at was that the representation it pro

Re: Templates for unknown object types

2006-12-18 Thread Crispin Bennett
On 12/19/06, James Bennett <[EMAIL PROTECTED]> wrote: > > Even if the types aren't known in advance, it's possible to make some > educated guesses; most classes will, for example, have a __str__ > method which will allow them to intelligently print themselves as > strings. > > If you know what typ

Re: Templates for unknown object types

2006-12-18 Thread Alan Trick
On Mon, 2006-12-18 at 19:57 -0600, James Bennett wrote: > Even if the types aren't known in advance, it's possible to make some > educated guesses; most classes will, for example, have a __str__ > method which will allow them to intelligently print themselves as > strings. Actually every class in

Re: Templates for unknown object types

2006-12-18 Thread James Bennett
On 12/18/06, Crispin Bennett <[EMAIL PROTECTED]> wrote: > Is there a natural way in Django to write a template that can display > the details of objects of various types, where the types aren't > necessarily known in advance? Even if the types aren't known in advance, it's possible to make some e

Re: Templates for unknown object types

2006-12-18 Thread limodou
On 12/19/06, Crispin Bennett <[EMAIL PROTECTED]> wrote: > > Is there a natural way in Django to write a template that can display > the details of objects of various types, where the types aren't > necessarily known in advance? > if the objects can be convert to string, or it has __str__ method, I