Re: Different objects returned when filtering with a ValuesListQuerySet

2014-07-28 Thread Marc Kirkwood
Yeah that's what I was thinking it could be. cheers Russ.

-- 
Legal status: Any views or opinions are solely those of the sender and do 
not necessarily represent those of SF Software Ltd unless expressly stated 
in the body of the text of the email, this email is not intended to form a 
binding contract.

Confidentiality: this communication may contain information that is 
confidential and/or privileged and is for the exclusive use of the intended 
recipient(s). Any form of distribution, copying or use of this 
communication by anyone else is strictly prohibited. If you have received 
this communication in error, please reply to this message or telephone +44 
(0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge 
that internet e-mail is not secure. We strongly advise you to understand 
and to be aware of the lack of security when e-mailing us. If you 
communicate with us via e-mail, we will assume that you accept the security 
risk and that you authorise us to communicate with you in the same format. 
The sender therefore does not accept liability for any errors or omissions 
in the contents of this message, which arise as a result of e-mail 
transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are 
present in this email, we cannot accept responsibility for any loss or 
damage arising from the use of this email or attachments. 

-
In compliance with Directive on Disclosure, The Companies Regulations 2006, 
effective 01 January 2007 talktopebble.co.uk,schoolfund.co.uk, 
schoolfundfinder.co.uk, easyusbooks.co.uk, clubfund.co.uk are domain names 
registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with 
company number: 05580540. Our trading name is Pebble our trading address 
and registered office is: Media Exchange Three, Coquet Street, Newcastle 
upon Tyne, NE1 2QB
VAT Registration number is: GB 873 5186 95

-- 
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/f327ed97-ee2f-4ca8-9045-d8bcebd170a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Different objects returned when filtering with a ValuesListQuerySet

2014-07-25 Thread Marc Kirkwood


When filtering a queryset with a *ValuesListQuerySet* instance in Django 
1.6, different objects to that shown in the apparent list seem to be 
returned by the iterator.

An illustration of a head-scratching debug session is shown below:

(Pdb) latest

*[4, 1]*

(Pdb) keys.filter(pk__in=latest).values_list('pk')

*[(3,), (1),)]*

(Pdb) keys.filter(pk__in=[4, 1]).values_list('pk')
*[(4,), (1),)]*

Can anyone explain this behaviour to me? When I fully convert it with 
*list(latest)*, normal service resumes.
I have a suspicion that it's because of the Postgres-aware *order_by()* and 
*distinct()* chain, in the queryset that *latest* was produced from.

Thanks,

Marc.

-- 
Legal status: Any views or opinions are solely those of the sender and do 
not necessarily represent those of SF Software Ltd unless expressly stated 
in the body of the text of the email, this email is not intended to form a 
binding contract.

Confidentiality: this communication may contain information that is 
confidential and/or privileged and is for the exclusive use of the intended 
recipient(s). Any form of distribution, copying or use of this 
communication by anyone else is strictly prohibited. If you have received 
this communication in error, please reply to this message or telephone +44 
(0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge 
that internet e-mail is not secure. We strongly advise you to understand 
and to be aware of the lack of security when e-mailing us. If you 
communicate with us via e-mail, we will assume that you accept the security 
risk and that you authorise us to communicate with you in the same format. 
The sender therefore does not accept liability for any errors or omissions 
in the contents of this message, which arise as a result of e-mail 
transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are 
present in this email, we cannot accept responsibility for any loss or 
damage arising from the use of this email or attachments. 

-
In compliance with Directive on Disclosure, The Companies Regulations 2006, 
effective 01 January 2007 talktopebble.co.uk,schoolfund.co.uk, 
schoolfundfinder.co.uk, easyusbooks.co.uk, clubfund.co.uk are domain names 
registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with 
company number: 05580540. Our trading name is Pebble our trading address 
and registered office is: Media Exchange Three, Coquet Street, Newcastle 
upon Tyne, NE1 2QB
VAT Registration number is: GB 873 5186 95

-- 
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/0ce13f3c-9e46-4575-beba-d79205e97b80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Templatetag variable resolution choices (Python literals)

2013-07-01 Thread Marc Kirkwood
OK, so I've got a template tag and a corresponding Node class. In order to 
check the value of two template variables in the Node.render method, I'm 
using the template.Variable class as specified in the docs. However, I'm 
wondering if there is any point to this, given the extra lines of code that 
are required to instantiate the class in the Node.__init__ method, then 
resolve each of the two variables within separate try-except blocks in case 
of a template.VariableDoesNotExist error. Given that both the variables are 
Python literals (boolean and list) and context.get('name', default) works 
as expected without the extra boilerplate, I'm wondering why it's not a 
documented way of doing this.

In summary, the following types of variable lookup give identical results 
when dealing with Python literals -- except that using the context directly 
removes the need for the try-except block and also eliminates the Django 
template.Variable checking code, which is redundant in this case:


class ExampleNode(template.Node):
def __init__(self):
self.a1 = template.Variable('a_variable')

def render(self, context):
try:
a1 = self.a1.resolve(context)
except template.VariableDoesNotExist:
a1 = False

a2 = context.get('a_variable', False)


I'll add once again that these variables are simply set in a view context 
as Python literals.

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




Re: Django with Jquery

2012-10-11 Thread Marc Kirkwood
I'm having this problem at the moment too. In our case, it's because we 
have a base template that inserts the jQuery library via a script tag 
towards the end of the document, just before the close of the body element. 
Since anything following a $ character in JS depends on jQuery, including 
the $(document).ready function call itself, we can't do anything with 
jQuery in a child template because the browser only includes the jQuery 
library when it receives it from the server. A possible solution is simply 
to move the