Re: Custom change_form.html

2014-09-21 Thread Salvatore DI DIO
Thanks Alex,

This indeed allow me to filter the admin page which lists the albums.
But, the problem I have, is,  when I want to add an image.

The 'add' display a listbox containing all the albums the image can be 
attached to
And I want to filter the content of this listbox, showing only the albums 
created by the connected user

Regards


Le dimanche 21 septembre 2014 15:38:39 UTC+2, Alex Chiaranda a écrit :
>
> Hi Salvatore,
>
> in your admin.py you can redefine your get_queryset and do something like 
> this:
>
>
> class FooAdmin(admin.ModelAdmin):
>  
> def get_queryset(self, request):
> if not request.user.is_superuser:
> return 
> super(FooAdmin,self).get_queryset(request).filter(user=request.user) # here 
> you can add any filter you want
> return super(FooAdmin, self).get_queryset(request)
>
>
>
>
> The if is not necessary, it is just to show you that you have the user 
> object into the request. 
>
>
>
> On Sunday, September 21, 2014 8:33:20 AM UTC-3, Salvatore DI DIO wrote:
>>
>> Thank you Collin,
>>
>> In fact I have not really access to the list.
>> II would like to flter a list wich is already rendered
>> as a listbox widget (fiedset.html)
>>
>>
>>
>> Le samedi 20 septembre 2014 01:33:42 UTC+2, Collin Anderson a écrit :
>>>
>>> if nothing else:
>>>
>>> {% for item in list %}{% if item.user = user %}
>>>
>>> {% endif %}{% endfor %}
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/96f7f978-8390-4b28-97ca-8b30dc874d05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom change_form.html

2014-09-21 Thread Alex Chiaranda
Hi Salvatore,

in your admin.py you can redefine your get_queryset and do something like 
this:


class FooAdmin(admin.ModelAdmin):
 
def get_queryset(self, request):
if not request.user.is_superuser:
return 
super(FooAdmin,self).get_queryset(request).filter(user=request.user) # here you 
can add any filter you want
return super(FooAdmin, self).get_queryset(request)




The if is not necessary, it is just to show you that you have the user 
object into the request. 



On Sunday, September 21, 2014 8:33:20 AM UTC-3, Salvatore DI DIO wrote:
>
> Thank you Collin,
>
> In fact I have not really access to the list.
> II would like to flter a list wich is already rendered
> as a listbox widget (fiedset.html)
>
>
>
> Le samedi 20 septembre 2014 01:33:42 UTC+2, Collin Anderson a écrit :
>>
>> if nothing else:
>>
>> {% for item in list %}{% if item.user = user %}
>>
>> {% endif %}{% endfor %}
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f55b13d6-ee50-48f2-b6ac-d0a80a196617%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom change_form.html

2014-09-21 Thread Salvatore DI DIO
Thank you Collin,

In fact I have not really access to the list.
II would like to flter a list wich is already rendered
as a listbox widget (fiedset.html)



Le samedi 20 septembre 2014 01:33:42 UTC+2, Collin Anderson a écrit :
>
> if nothing else:
>
> {% for item in list %}{% if item.user = user %}
>
> {% endif %}{% endfor %}
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7dbcac7f-1c73-4b25-a0a1-a0329d36d6d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom change_form.html

2014-09-19 Thread Collin Anderson
if nothing else:

{% for item in list %}{% if item.user = user %}

{% endif %}{% endfor %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/09cc77ee-3fb8-433b-b80c-385d1d9f8cee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Custom change_form.html

2014-09-19 Thread Salvatore DI DIO
Hello,

*To follow my preceding question, on customize admin view, (*Helton Alves 
gave me a nice response).
I am wondering how to filter a list in change_form.html  admin  form, 
according to a partuculiar user ?

Thank you for your help

Regards




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e916af0-17f8-4642-b226-aca71a08b289%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.