On Sun, Jul 10, 2011 at 6:26 PM, het.oosten <het.oos...@gmail.com> wrote:
> Ok perhaps a basic question. I wrote a custom method for my model: > def image_list(self): > return '<img src=\"/media/%s\" alt=\"%s\">' % > (self.image, self.alt) > You should never really put HTML inside a method unless you *really* have to (even if it's for performance, unless your site is getting thousands and thousands of hits a minute, then just use a template) > And i indeed get a nice list of image in the template. I want however > control where the single images show up. With something like {{image. > 1}} other text {{image.2}} in the text. > I'm a bit confused as to how you are getting the image list in the first place, you'll need to paste your code. (use dpaste or pastebin please). > > How do i accomplist this? > > On Jul 10, 5:54 pm, Shawn Milochik <sh...@milochik.com> wrote: > > I'd rather see the contents of your __unicode__ function as a > > get_absolute_url function, with the __unicode__ maybe returning just the > > filename or the parent object's title and the filename. > > > > I strongly dislike the embedding of template code in a text field of > > your model, because it makes maintenance a lot harder. I don't know what > > your code looks like that reads and writes that, so maybe it works for > > you. In any case, have a look at adding a method or property to your > > model that returns an iterable of image links. I think it'll be a lot > > easier to maintain in the long run. > > -- > 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.