From an example you can see a multiple OR query filter:
Article.objects.filter(Q(pk=1) | Q(pk=2) | Q(pk=3))
For example, this results in:
[<Article: Hello>, <Article: Goodbye>, <Article: Hello and goodbye>]
However, I want to create this query filter from a list. How to do that?
e.g. [1, 2, 3] -> Article.obj...
I am looking for a pure python based web server has the capability for reverse proxy as well?
...
I'm looking to understand python via writing a small requirements management system. I know C, C++, PHP, JQuery, etc. (all the basics) - which webhost provides the right platform (with PostgresSQL?) and which MVC should I use (Django?)...I know coding, but want to learn python the right way - not reinventing existing functionality or wo...
I am looking for a pure python based web server has the capability for reverse proxy as well?
...
I want to find the location(s) of a specific item in a list of lists. It should return a list of tuples, where each tuple represents the indexes for a specific instance of the item. For example:
list = [['1', '2', '4', '6'], ['7', '0', '1', '4']]
getPosition('1') #returns [(0, 0), (1, 2)]
and getPosition('7') #returns [(1,0)]
...
Say I have 2 models:
class Poll(models.Model):
category = models.CharField(u"Category", max_length = 64)
[...]
class Choice(models.Model):
poll = models.ForeignKey(Poll)
[...]
Given a Poll object, I can query its choices with:
poll.choice_set.all()
But, is there a utility function to query all choices from a set of...
Django has a number of open source projects that tackle one of the framework's more notable missing features: model "evolution". Ruby on Rails has native support for migrations, but I'm curious if anyone can recommend one of the following Django "evolution" projects:
South
django-evolution
dmigrations
...
I need to write a software that creates an shapefile with various circles or circumferences on it.
The shapefile created should be readable by ESRI ArcMap.
I need a library that let me add circles or circular arc to it.
The library could be in for Python or in Java.
...
Hello,
I'm using Python/Django over MySQL. I'm currently working with MySQLdb that's under GNU GPL license. Is there a library with "similar" capabilities that's not under GPL-like licenses?
To clarify:
I don't know yet if I will want to distribute my source code or charge money for my application. What I do know is that I don't want...
How can I access Microsoft Access databases in Python? With SQL?
I'd prefere a solution that works with Linux, but I could also settle for Windows.
I only require read access.
...
Hi, I am looking for a way to represent '\n' with only one character. I am writing a program that uses dictionaries to 'encrypt' text. Because each character is represented in the dictionary, i am having a problem when my program gets to a '\n' in a string, but reads it as '\' 'n' . Is there alternate way to represent a newline, that is ...
I was bored and playing around with the ipython console and came upon the following behaviour I don't really understand
In [1]: 2**2
Out[1]: 4
In [2]: 2**2**2
Out[2]: 16
In [3]: 2**2**2**2
Out[3]: 65536
In [4]: 2**2**2**2**2
The answer to [4] is not 4294967296L, it's a very long number, but I can't really figure out why.
The numbe...
I am working on a Django application which allows a user to upload files. I need to perform some server-side processing on these files before sending them on to Amazon S3. After reading the responses to this question and this blog post I decided that the best manner in which to handle this is to have my view handler invoke a method on ...
I am writing a function and intended to use a dictionary key and its value as parameters. For example:
testDict={'x':2,'xS':4}
def newFunct(key,testDict['key']):
newvalue=key+str(testDict['key'])
return newValue
for key in testDict:
newValue=newFunct(key,testDict[key])
print newValue
I get a SyntaxError: invalid sy...
It seems that all roads lead to having to use PyISAPIe to get Django running on IIS6. This becomes a problem for us because it appears you need separate application pools per PyISAPIe/Django instance which is something we'd prefer not to do.
Does anyone have any advice/guidance, or can share their experiences (particularly in a shared W...
I'm using Python with pywin32's adodbapi to write a script to create a SQL Server database and all its associated tables, views, and procedures. The problem is that Python's DBAPI requires that cursor.execute() be wrapped in a transaction that is only committed by cursor.commit(), and you can't execute a drop or create database statemen...
Dear Friends,
I want to communicate using flex client with GAE, I am able to communicate using XMl from GAE to FLex but how should I post from flex3 to python code present on App Engine.
Can anyone give me a hint about how to send login information from Flex to python
Any ideas suggest me some examples.....please provide me some help ...
Is there any way, in Python, to "programmatically" (:-) change the CAPS LOCK/NUM LOCK/SCROLL LOCK states. This isn't really a joke question - more like a real question for a joke program. I intend to use it for making the lights do funny things ;-)
...
I recently wrote a program that used a simple producer/consumer pattern. It initially had a bug related to improper use of threading.Lock that I eventually fixed. But it made me think whether it's possible to implement producer/consumer pattern in a lockless manner.
Requirements in my case were simple:
One producer thread.
One consume...
I'm working on some screen scraping software and have run into an issue with Beautiful Soup. I'm using python 2.4.3 and Beautiful Soup 3.0.7a.
I need to remove an <hr> tag, but it can have many different attributes, so a simple replace() call won't cut it.
Given the following html:
<h1>foo</h1>
<h2><hr/>bar</h2>
And the following co...