Re: filepath (system file system path) field

2010-10-22 Thread BigBlogMaker
look like this solved the problem
a source in Russian

http://translate.google.ru/translate?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=ru&tl=en&u=http://blog.vernart.ru/programming/python/django/sobstvennye-filepathfield-dlya-django-spisok-direktorij/


On 23 сен, 01:07, pixelcowboy  wrote:
> That field seems to grab all the files in a given directory according
> to a set filtering. I actually just want to register the actual
> directory names, and possible launch a file picker for the user to
> select it.
>
> On Sep 22, 2:30 am, Nuno Maltez  wrote:
>
>
>
> > On Tue, Sep 21, 2010 at 6:17 PM, pixelcowboy  
> > wrote:
> > > Hi, I have seen this asked before here (without answers), but I wanted
> > > to know how to go on about creating a field that stores filepath names
> > > from the client filesystem, so I wanted to check if someone could
> > > recommend the best apporach: Creating a custom field perhaps? Or
> > > perhaps extending the filefield? Or maybe just use a charfiled and do
> > > it all in validation? What do you guys think?
>
> > Hmmm something like 
> > this?http://docs.djangoproject.com/en/dev/ref/models/fields/#filepathfield
>
> > Nuno

-- 
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.



How to get an dictionary item in template

2010-12-26 Thread BigBlogMaker
I'm sorry for my english, but on other groups nobody does not answers.

In view defined variables:

production = Production.objects.all ()
images = {}
for product in production:
try:
image = product.image_set.get (somefield = somevalue)
images [product.id] = image
except:
pass

Now the question is: how to access the elements of images in the
template?

{% for product in production %}
{{ product.title }}
{% if images %}

{% endif %}
{% endfor %}

-- 
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.



Re: How to get an dictionary item in template

2010-12-26 Thread BigBlogMaker
Each product can have multiple images.
images are divided by type. it facilitates the withdrawal of the
desired image in the right place.

On 27 дек, 01:35, Mikhail Korobov  wrote:
> production = Production.objects.all()
> for product in production:
>     try:
>         product.image = product.image_set.get (somefield = somevalue)
>     except Image.DoesNotExist:
>         pass
>
> {% for product in production %}
>     {{ product.title }}
>      "{{ product.title }}">
> {% endfor %}
>
> or even better implement the 'get_image' method for the Product.
>
> But please note that these solutions are executing SQL queries for
> each product. It may be better to denormalize the DB and add a FK
> field to Product model pointing to the main Image model.
>
> On 26 дек, 23:56, BigBlogMaker  wrote:
>
>
>
>
>
>
>
> > I'm sorry for my english, but on other groups nobody does not answers.
>
> > In view defined variables:
>
> > production = Production.objects.all ()
> > images = {}
> > for product in production:
> >     try:
> >         image = product.image_set.get (somefield = somevalue)
> >         images [product.id] = image
> >     except:
> >         pass
>
> > Now the question is: how to access the elements of images in the
> > template?
>
> > {% for product in production %}
> > {{ product.title }}
> > {% if images %}
> >  > "{{ images..title }}"/>
> > {% endif %}
> > {% endfor %}

-- 
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.



Filtering related objects in template

2011-01-08 Thread BigBlogMaker
Can I filtering of related objects in a template? Explained:
Now I make so

{% for image in product.image_set.all %}
{% if image.image_type.id == 777 %}

{% endif %}
{% endfor %}

And I would like to:

{% for image in product.image_set.all | image_type.id : 777 %}

{% endfor %}

--
(sorry for my English %))

-- 
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.