Jajaja para nada de hecho ya quedo lo deje asi para cualquiera que lo
necesite:
-------------------view------------------------------
def clientes(request):
clientes = Clientes.objects.order_by('Nombre')
clientes2 = Clientes.objects.order_by('Nombre').filter(medio='1')
clientes3 = Clientes.objects.order_by('Nombre').filter(medio='2')
clientes4 = Clientes.objects.order_by('Nombre').filter(medio='3')
medios = Clientes.objects.order_by('tipo')
abecedario = string.ascii_letters[:26]
objects = []
order = 'Nombre'
for letra in abecedario:
filters = {'Nombre__startswith': letra}
objects.append({letra :
Clientes.objects.filter(**filters).order_by(order) })
template = 'products/Clientes.html'
return render(request, template, locals())
----------------template-----------------------
<div class='container'>
<div class=' col-sm-offset-1 '>
{% for letra in objects %}
{% for key, clientes in letra.items %}
<h1 class = "text-transform: uppercase"> {{key}}</h2>
<hr>
{% for cliente in clientes %}
<a href='{{ cliente.get_absolute_url }}'><p align="justify"><font
size=3>Nombre del Cliente: {{ cliente.Nombre }} {{
cliente.Apellido}}</p></font>
<p align="justify"><font size=2 >Medio por el cual llego: {{
cliente.medio}}<p></font> </a>
<br>
{% endfor %}
<br>
{% endfor %}
{% endfor %}
</div>
Muchas gracias por tu tiempo
El martes, 10 de noviembre de 2015, 11:25:17 (UTC-6), Luke M escribió:
>
> Yo no se verdaderamente si estas 'trolling' ... pero bueno, si no, puedo
> decirte exactamente lo que pasa - usas `objects.appened` en lugar de
> `objects.append`, a ver:
> https://docs.python.org/3/tutorial/datastructures.html#more-on-lists
>
> Despues el 'for' loop, tienes una lista de listas que son objetos de
> filtro que contiene los resultos de lo que has buscado.
>
> Eso es algo differente en comparacion de lo que ya tuviste cuando
> pasaste el `Clientes` objeto dentro el template.
>
> On 10.11.2015 17:46, miguel angel lopez mendo wrote:
> > ya lo acomode pero aun asi me manda este error
> > <
> https://lh3.googleusercontent.com/-7SmUF6IDdxo/VkIfOsntrPI/AAAAAAAAAg8/ohvr7a1ZWWU/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.44.43%2Ba.m..png>
>
>
> >
> >
> > Te dejo mi template para que veas tambien
> >
> > <div class='container'>
> >
> > <h3></h3>
> >
> > <hr />
> >
> > {% for clientes in objects %}
> >
> > <div class="col-md-4 col-sm-offset-1">
> >
> > <br>
> >
> > <p align="justify"><font size=3>Nombre del Cliente: {{
> > cliente.Nombre}}</p></font>
> >
> > <p align="justify"><font size=2>Medio por el cual llego: {{
> > cliente.get_medio_display}}<p></font>
> >
> > </div>
> >
> > {% endfor %}
> >
> > </div>
> >
> > {% endblock %}
> >
> >
> > El martes, 10 de noviembre de 2015, 10:36:25 (UTC-6), [email protected]
> > escribió:
> >
> > Check your indentation, it's off starting from the line below
> `import
> > string`. My email
> > client kinda borked my indentation, so you need to take care.
> >
> > On 2015-11-10 17:30, miguel angel lopez mendo wrote:
> > >
> > <
> https://lh3.googleusercontent.com/-y6iDerxsJQM/VkIbpx5j19I/AAAAAAAAAgw/OYdyYTRJgME/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.30.09%2Ba.m..png
>
> > <
> https://lh3.googleusercontent.com/-y6iDerxsJQM/VkIbpx5j19I/AAAAAAAAAgw/OYdyYTRJgME/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.30.09%2Ba.m..png>>
>
>
> >
> > >
> > > i have the next view but it does not work
> > >
> > >
> > <
> https://lh3.googleusercontent.com/-4PPNOaFeJOI/VkIa2AhLQbI/AAAAAAAAAgg/0VyNoj7bMvw/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.26.32%2Ba.m..png
>
> > <
> https://lh3.googleusercontent.com/-4PPNOaFeJOI/VkIa2AhLQbI/AAAAAAAAAgg/0VyNoj7bMvw/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.26.32%2Ba.m..png>>
>
>
> >
> > >
> > > also have the model
> > >
> > >
> > >
> > <
> https://lh3.googleusercontent.com/-qCaTL7AhvTQ/VkIbR0E2jqI/AAAAAAAAAgo/82RRntPAfzM/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.28.43%2Ba.m..png
>
> > <
> https://lh3.googleusercontent.com/-qCaTL7AhvTQ/VkIbR0E2jqI/AAAAAAAAAgo/82RRntPAfzM/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.28.43%2Ba.m..png>>
>
>
> >
> > >
> > >
> > <
> https://lh3.googleusercontent.com/-y6iDerxsJQM/VkIbpx5j19I/AAAAAAAAAgw/OYdyYTRJgME/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.30.09%2Ba.m..png
>
> > <
> https://lh3.googleusercontent.com/-y6iDerxsJQM/VkIbpx5j19I/AAAAAAAAAgw/OYdyYTRJgME/s1600/Captura%2Bde%2Bpantalla%2B2015-11-10%2Ba%2Blas%2B10.30.09%2Ba.m..png>>
>
>
> >
> > >
> > >
> > > the error is the follow
> > >
> > >
> > >
> > > El martes, 10 de noviembre de 2015, 10:14:02 (UTC-6),
> > [email protected]
> > > escribió:
> > >>
> > >> Haven't run this code, but you could try something like:
> > >>
> > >> ```
> > >> import string
> > >>
> > >> myletters = string.ascii_letters[:16]
> > >> objects = []
> > >> order = 'Nombre'
> > >> for letter in myletters:
> > >> filters = {'Nombre__startswith': letter}
> > >>
> > >> objects.append(Clientes.objects.filter(**filters).order_by(order)
> > >> ```
> > >>
> > >> Hope that helps,
> > >> Luke
> > >>
> > >> On 2015-11-10 17:06, miguel angel lopez mendo wrote:
> > >> > a = Clientes.objects.filter(
> > Nombre__startswith='A').order_by('Nombre')
> > >> > b = Clientes.objects.filter(
> > >> > Nombre__startswith='B').order_by('Nombre')
> > >> > c = Clientes.objects.filter(
> > >> > Nombre__startswith='C').order_by('Nombre')
> > >> > d = Clientes.objects.filter(
> > >> > Nombre__startswith='D').order_by('Nombre')
> > >> > e = Clientes.objects.filter(
> > >> > Nombre__startswith='E').order_by('Nombre')
> > >> > f = Clientes.objects.filter(
> > >> > Nombre__startswith='F').order_by('Nombre')
> > >> > g = Clientes.objects.filter(
> > >> > Nombre__startswith='G').order_by('Nombre')
> > >> > h = Clientes.objects.filter(
> > >> > Nombre__startswith='H').order_by('Nombre')
> > >> > i = Clientes.objects.filter(
> > >> > Nombre__startswith='I').order_by('Nombre')
> > >> > j = Clientes.objects.filter(
> > >> > Nombre__startswith='J').order_by('Nombre')
> > >> > k = Clientes.objects.filter(
> > >> > Nombre__startswith='K').order_by('Nombre')
> > >> > l = Clientes.objects.filter(
> > >> > Nombre__startswith='L').order_by('Nombre')
> > >> > m = Clientes.objects.filter(
> > >> > Nombre__startswith='M').order_by('Nombre')
> > >> > n = Clientes.objects.filter(
> > >> > Nombre__startswith='N').order_by('Nombre')
> > >> > o = Clientes.objects.filter(
> > >> > Nombre__startswith='O').order_by('Nombre')
> > >> > p = Clientes.objects.filter(
> > >> > Nombre__startswith='P').order_by('Nombre')
> > >>
> > >>
> >
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/68413021-54be-4eb5-b14f-0bc2f2b273fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.