Re: Sorl thumbnails VS Google

2012-06-05 Thread Àlex Pérez
Hello,

You can change the name of the files generated by sorl and be sure that the
name that you are giving to the image is unique, and if not, make a new
name,

you can find information about that locking the code:
https://github.com/sorl/sorl-thumbnail/blob/master/sorl/thumbnail/base.py#L32

and there are a settings parameter to tell sorl the class to override
the default class.

Search things about that, I think that is the key.

2012/6/5 kooliah 

> That's what i'll do.
>
> Thanks for the answer
>
>
>
> On 06/04/2012 03:10 PM, fabrixxm wrote:
>
>> On 4 Giu, 12:32, 
>> kooliah>
>>  wrote:
>>
>>
>>> So i can't understand if i want to have a better ranking, it is better
>>> to not use sorl for this kind of images and use
>>>
>>> >> height="{{ pic.picture.height }}" />
>>>
>>> that gives
>>> >> width="187" height="280" />
>>>
>>>
>>>
>> from a user perspective, I think is much wors load a full size image
>> and scale it down only to use its filename..
>>
>> the same page you linked says also:
>>
>> "
>> Create great alt text
>>
>> The alt attribute is used to describe the contents of an image file.
>> It's important for several reasons:
>>  •It provides Google with useful information about the subject matter
>> of the image.
>>   We use this information to help determine the best image to return
>> for a user's query.
>> •Many people-for example, users with visual impairments, or people
>> using screen readers or who have
>>  low-bandwidth connections—may not be able to see images on web
>> pages.
>>  Descriptive alt text provides these users with important information.
>> "
>> so you should try to add a usefull alt alttrbute, like
>>
>>  {% thumbnail pic.picture "280x280" as image %}
>>  
>>   {% endthumbnail %}
>>
>> Which could render as
>>
>> >   width="187" height="280" alt="CCF Iveco" />
>>
>>
>>
>>
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



Re: How can i transmit an objects in list?

2012-06-14 Thread Àlex Pérez
Hello,


Are you sure?

I suppose that "childrens" is a custom manager, can you show us, the
implementation of that manager?

Only for performance "if len(category.childrens.all()):" -> "if
category.childrens.exist():"

But your problem, it's rare. Print the type of the firs element of the
result list:

list = BuildList(Categories.objects.filter(parent = None))
print type(list[0])

2012/6/14 Dominis 

> Hello.
> I need a bit help with my code.
> I write a function for menu building, which should create a list of
> objects, for designing it in html code.
> Code of function below:
>
>> def BuildList(categories):
>> list = []
>> for category in categories:
>> if len(category.childrens.all()):
>> list.append(category)
>> list.append(BuildList(category.childrens.all()))
>> else :
>> list.append(category)
>> return list
>>
>
> I call this function for a list of categories, like this:
>
>> list = BuildList(Categories.objects.filter(parent = None))
>>
> My function work right, but in list i get not an objects, my values have
> only name of a categories. I thought it happens couse in my Category model
> in __unicode__  function i place a 'return self.name', and when i call my
> categories in function - it return just name. :(
> What i should do for get full objects in my list? With full collection of
> parameters.
> I suppose this question is easy, but i just start to learn python and
> django.
> Thx for you time and answers.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/LwmJH2ZcRcwJ.
> 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.
>



-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



Re: How do I get django working without having to manually run the server?

2012-06-17 Thread Àlex Pérez
One question,

The automatic reload whenever you modify the files. There are an
alternative to do that with mod_wsgi? or anything else?

Thanks!

2012/6/17 Kurtis Mullins 

> I did forget one important (and very useful feature) that the runserver
> contains -- the automatic reload whenever you modify files. I was just
> curious if it provided more debugging information than otherwise would be
> provided based upon that statement.
>
>
> On Sun, Jun 17, 2012 at 6:48 AM, Phang Mulianto wrote:
>
>> The python manage.py runserveris intended for fast development time
>> to kick start the apps.
>>
>> you don't need to prepare the apache wsgi stack first, especialy if you
>> want to try something new like django newcomer. it's took time and
>> knowledge to prepare the apache wsgi.
>>
>> but it still an option if you don't want use the runserver command.
>> if you don't want to type it everytime you start the development, make it
>> run as service in your devel machine.
>>
>> it's bundled in django as a development web server, not for production
>> web server.
>>
>> so make it what you like ... it's in the documentation..
>>
>>
>>
>> On Sun, Jun 17, 2012 at 12:20 PM, Kurtis Mullins <
>> kurtis.mull...@gmail.com> wrote:
>>
>>> But you still need manage.py runserver for development because it is
 specially designed to prioritise debugging over security and performance.
>>>
>>>
>>> Really? I could see the use for it when running an actual debugger but
>>> otherwise, I'm not so sure there's any benefit to using it. Do you have any
>>> sources or more information on this? This is new information to me. Thanks!
>>>
>>> --
>>> 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.
>>
>
>  --
> 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.
>



-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



Re: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-07-01 Thread Àlex Pérez
+1

2012/7/1 s 

> Great
> On Jun 30, 2012 6:10 PM, "Cal Leeming [Simplicity Media Ltd]" <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Hi all,
>>
>> As some of you know, I did a live webcast last year (July 2011) on our
>> LLG project, which explained how we overcome some of the problems
>> associated with large data processing.
>>
>> After reviewing the video, I found that the sound quality was very
>> poor, the slides weren't very well structured, and some of the information
>> is now out of date (at the time it was 40mil rows, now we're dealing with
>> 700+mil rows).
>>
>> Therefore, I'm considering doing another live webcast (except this time
>> it'll be recorded+posted the next day, the stream will be available in
>> 1080p, it'll be far better structured, and will only last 50 minutes).
>>
>> The topics I'd like to cover are:
>>
>> * Bulk data processing where bulk_insert() is still not viable (we went
>> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still
>> using the ORM - no raw sql here!!)
>> * Applying faux child/parent relationship when standard ORM is too
>> expensive (allows for ORM approach without the cost)
>> * Applying faux ORM read-only structure to legacy applications (allows
>> ORM usage on schemas that weren't properly designed, and cannot be changed
>> - for example, vendor software with no source code).
>> * New Relic is beautiful, but expensive. Hear more about our plans to
>> make an open source version.
>> * Appropriate use cases for IAAS vs colo with SSDs.
>> * Percona is amazing, some of the tips/tricks we've learned over.
>>
>> If you'd like to see this happen, please leave a reply in the thread - if
>> enough people want this, then we'll do public vote for the scheduled date.
>>
>> Cheers
>>
>> Cal
>>
>> --
>> 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.
>



-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



ContentType and multiple database

2012-08-01 Thread Àlex Pérez
Hello,

I want to take objects of another project that i don't have installed.
I can have the contenttype of the external object but I can't take the
object I understand that, take the object remotly  of a model thah you
dosen't have have the class is not possible (I think...) but if i want only
a value i think that could be reasonable...

I want to tho something like that:

 c = ContentType.objects.using("site").get(pk=self.ext_content_id)
 obj = c.get_object_for_this_type(pk=self.ext_object_id).values("nombre")

but obiously doesn't work.

Please guys help me!!

Thanks


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



Re: union of two QuerySets

2012-08-01 Thread Àlex Pérez
Hi,

it's better  Person.objects.filter(models.Q(first_**name__startswith='mic'),
models.Q(first_**name__startswith='joh'))
(only one query...)


2012/8/1 Robin Pedersen 

> On Monday, December 11, 2006 4:37:25 AM UTC+1, Rares Vernica wrote:
>>
>> Hi,
>>
>> What is a way to get the union of two QuerySets?
>>
>> Something like:
>>
>> In [6]: a = Person.objects.filter(first_**name__startswith='mic')
>>
>> In [7]: b = Person.objects.filter(first_**name__startswith='joh')
>>
>> In [8]: a + b
>>
>> Thanks a lot,
>> Ray
>>
>
> Try:
>
> a | b
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ie69j4ewJNUJ.
> 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.
>



-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



csrf cookie and varnish

2012-10-15 Thread Àlex Pérez
Today I had a problem with CSRF protection of Djando and varnish, the
varnish basically detects that a cookie (the CSRF) and does not perform its
task (cache requests).

The solutions found on google have not convinced me. And I tried an idea,
delete all cookies when I'm not on a website that requires cookies and
delete on the rest.

Someone may find any inconvenient to this solution?

I do not need user authentication ...

thanks
-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



csrf protection question

2012-10-23 Thread Àlex Pérez
I have override the  CsrfViewMiddleware middleware by:

class CustomCsrfViewMiddleware(CsrfViewMiddleware):

def process_response(self, request, response):
if getattr(response, 'csrf_processing_done', False):
return response

# If CSRF_COOKIE is unset, then CsrfViewMiddleware.process_view was
# never called, probaby because a request middleware returned a
response
# (for example, contrib.auth redirecting to a login page).
if request.META.get("CSRF_COOKIE") is None:
return response

if not request.META.get("CSRF_COOKIE_USED", False):
return response

# Set the CSRF cookie even if it's already set, so we renew
# the expiry timer.
response.set_cookie(settings.CSRF_COOKIE_NAME,
request.META["CSRF_COOKIE"],
max_age=60 * 60 * 24 * 7 * 52,
domain=settings.CSRF_COOKIE_DOMAIN,
path=request.META["PATH_INFO"],
secure=settings.CSRF_COOKIE_SECURE
)
# Content varies with the CSRF cookie, so set the Vary header.
patch_vary_headers(response, ('Cookie',))
response.csrf_processing_done = True
return response


my change is: path=request.META["PATH_INFO"],

I don't know if could be any problem.

Thanks


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



Concat on Update

2012-12-28 Thread Àlex Pérez
Hello,

Someone know how to do that in django?:

url = "basE_url"
query.update(url= url + models.F("slug_nombre")),

and the result should be the concatenation of de column  url like
"basE_url(slug_nombre)"

I'm a little bit confused, because I understand why doesn't work that, but
don't know why the orm doesn't detect the types of the params and make an
aritmethic funcion or concatenate function.

thanks!



-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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



ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
I want to know if there is a way that the query that is executed to get the
prefetch related information can get only certains values, actually that
only works for select_related,

May be i have done something wrong but the prefetch_related query is
getting all the fields of the model.

Someone can help me please?


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
Ok thank's!!!

but you thinks thats the normal behaviour? this could be included in future
versions of the orm?

You know the way to simulate  the behaviour that i want.?

2013/5/29 akaariai 

> There is no way to alter the behavior of prefetch_related. It fetches
> the related objects with the query defined by the related manager and
> that's it.
>
>  - Anssi
>




-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
As you say the raw sql always is the solution.

But I take a few time to think how that could be possible with the ORM, and
like
akaariai says the prefetch_related get the values for de _default_manager.

But if i defined a temporally manager that makes the only clausure it
works, but i don't know if is thread safe.



class OtherManager(models.Manager):
def get_query_set(self):
return
super(OtherManager,self).get_query_set().only("nombre")

class Especialidad(models.Model):
nombre = models.CharField(max_length=255)

objects = models.Manager()
otro = OtherManager()


Especialidad._default_manager = Especialidad.otro
tpl_vars["list"] = list(tpl_vars["list"])
Especialidad._default_manager = Especialidad.objects

Thank's!


2013/5/29 Christophe Pettus 

>
> On May 29, 2013, at 12:44 PM, Àlex Pérez wrote:
>
> > You know the way to simulate  the behaviour that i want.?
>
> Raw SQL.  At the point you are doing a multi-join query and selecting a
> subset of the fields to be returned, you probably should switch to raw SQL
> anyway.
>
> --
> -- Christophe Pettus
>x...@thebuild.com
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django foreing keys joins

2013-06-05 Thread Àlex Pérez
Can someone tell me why the or in that query:
print Counter.on_medicos.filter(loc__isnull=True).only("id").query

""SELECT `web_counter`.`id` FROM `web_counter` LEFT OUTER JOIN
`locations_localidad` ON (`web_counter`.`loc` = `locations_localidad`.`id`)
WHERE (`web_counter`.`mode` = 1  AND `locations_localidad`.`id` IS NULL)"""

The orm is making a JOIN?? i can't understant!

The foreignkey loc is nullable and blank, i don't understant why making a
filter the orm is performing the join and making an exclude the ORM is not
performing the JOIN...

print Counter.on_medicos.exclude(loc__isnull=True).only("id").query
SELECT `web_counter`.`id` FROM `web_counter` WHERE (`web_counter`.`mode` =
1  AND NOT (`web_counter`.`loc` IS NULL))

Thank's!

-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django foreing keys joins

2013-06-08 Thread Àlex Pérez
Thanks!,

that query is making the join, and i wan't tho make a faster query, Joins
ar not slow but if i can avoid it better.
>>> print Counter.on_medicos.filter(loc_id__isnull=True).only('id').query

My solution was: instead of  put null values on empty relations, put a 0
value.. It work's very good.

Thank for your answer,

p.s: Can you give me your opinion about that  question
https://groups.google.com/forum/?fromgroups#!searchin/django-users/prefetch_related$20and$20only/django-users/im9LGioyWu8/8DrEnakoQKgJ
?





2013/6/6 Jani Tiainen 

> That is how Django works.
>
> So as you see, django makes query where it compares _joined_ table id as a
> null. To make it happen (left outer) join must happen, otherwise it
> wouldn't return any rows.
>
> I agree that Django _could_ do a better and optimize query so that it
> would query instead of underlying fk field as a null value, though that
> would not be simple since a you know, filters may be chained and in case of
> chaining rewriting whole query would require quite a bit of reworkings.
>
> If you absolutely know that your query stops there you can use underlying
> id field for faster testing:
>
> >>> print Counter.on_medicos.filter(loc_id__isnull=True).only('id').query
>
> That should return what you might have been expecting.
>
> --
>
> Jani Tiainen
>
> "Impossible just takes a little longer"
>
> On Thu, 6 Jun 2013 01:05:32 +0200
> Àlex Pérez  wrote:
>
> > Can someone tell me why the or in that query:
> > print Counter.on_medicos.filter(loc__isnull=True).only("id").query
> >
> > ""SELECT `web_counter`.`id` FROM `web_counter` LEFT OUTER JOIN
> > `locations_localidad` ON (`web_counter`.`loc` =
> `locations_localidad`.`id`)
> > WHERE (`web_counter`.`mode` = 1  AND `locations_localidad`.`id` IS
> NULL)"""
> >
> > The orm is making a JOIN?? i can't understant!
> >
> > The foreignkey loc is nullable and blank, i don't understant why making a
> > filter the orm is performing the join and making an exclude the ORM is
> not
> > performing the JOIN...
> >
> > print Counter.on_medicos.exclude(loc__isnull=True).only("id").query
> > SELECT `web_counter`.`id` FROM `web_counter` WHERE (`web_counter`.`mode`
> =
> > 1  AND NOT (`web_counter`.`loc` IS NULL))
> >
> > Thank's!
> >
> > --
> > Alex Perez
> > alex.pe...@bebabum.com
> >
> >  *bebabum* be successful
> >
> > c/ Còrsega 301-303, Àtic 2
> > 08008 Barcelona
> > http://www.bebabum.com
> > http://www.facebook.com/bebabum
> > http://twitter.com/bebabum
> >
> > This message is intended exclusively for its addressee and may contain
> > information that is confidential and protected by professional privilege.
> > If you are not the intended recipient you are hereby notified that any
> > dissemination, copy or disclosure of this communication is strictly
> > prohibited by law.
> >
> > Este mensaje se dirige exclusivamente a su destinatario y puede contener
> > información privilegiada o confidencial. Si no es vd. el destinatario
> > indicado,
> > queda notificado que la utilización, divulgación y/o copia sin
> autorización
> > está prohibida en virtud de la legislación vigente.
> >
> > Le informamos que los datos personales que facilite/ha facilitado
> pasarán a
> > formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
> > por finalidad gestionar las relaciones con usted.
> > Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
> > oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la
> dirección
> > de e-mail l...@bebabum.com
> >
> > --
> > 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?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> 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-use