How do I get the choices field values and not the key from the form?
I have a form where I let the user select some user's emails for a company.
For example I have a form like this (this reason for model form is that it's inside a formset - but that is not important for now):
class Contacts(forms.ModelForm):
def __init__(self, *args...
Is it possible to access the previous element generated in a list comprehension.
I am working on some toy encryption stuff. Given the key as an arbitrarily large integer, an initialization value, and a list of elements as the message to encrypt. I need to xor each element with the previous ciphered element and the key. The following ...
I have a listbox that you can select users in. To the left of that is a combobox listing the available groups the user can be put it. If the user is in a group, the combobox will automatically be set to that group. I want to make it so when you change the group selection, it will move the user to that group. I added this connection:
QtC...
This document by Apple Technical Q&A QA1235 describes a way to convert unicode strings from a composed to a decomposed version. Since I have a problem with file names containing some characters (e.g. an accent grave), I'd like to try the conversion function
void CFStringNormalize(CFMutableStringRef theString,
CFS...
Hello,
I have a datetime object at my model.
I am sending it to the view, but in html i don't know what to write in order to format it.
I am trying
{{ item.date.strftime("%Y-%m-%d")|escape }}
but I get
TemplateSyntaxError: Could not parse some characters: item.date.strftime|("%Y-%m-%d")||escape
when I am just using
{{ item.date...
The initialization process of group of classes that share a common parent can be divided into three parts: common part1, class-specific part, common part2. Currently the first two parts are called from the __init__ function of each child class, but the second common part has to be called separately
For example:
class BaseClass:
def ...
Can anyone point to serious comparison of Python runtime footprint versus Java?
Thanks,
Avraham
...
I have a django model like this:
class Player(models.Model):
name = models.CharField()
batting = models.IntegerField()
bowling = models.IntegerField()
What would be the Django QuerySet equivalent of the following SQL?
SELECT * FROM player WHERE batting > bowling;
...
I have a long-running Python service and I'd like to know how much cumulative wall clock time has been spent by any runnable threads (i.e., threads that weren't blocked for some other reason) waiting for the GIL. Is there an easy way to do this? E.g., perhaps I could periodically dump some counter to its log file.
My underlying motiva...
Hi,
Let's say I have a set of vectors (readings from sensor 1, readings from sensor 2, readings from sensor 3 -- indexed first by timestamp and then by sensor id) that I'd like to correlate to a separate set of vectors (temperature, humidity, etc -- also all indexed first by timestamp and secondly by type).
What is the cleanest way in ...
Duplicate of "how does one get a count of rows in a datastore model in google appengine?"
I'm having big trouble.
I want to know how many users I have... I did:
users = UserStore.all()
user_count=users.count()
quite simple...
But now I have more than 1000 users and this method continues to return 1000.
Is there any other way of k...
I'm new to mod_python and Apache, and I'm having trouble returning a file to a user after a GET request. I've got a very simple setup right now, and was hoping to simply open the file and write it to the response:
from mod_python import apache
def handler(req):
req.content_type = 'application/octet-stream'
fIn = open('response...
I know that SimplePie itself is derived from UFP, but the features I'm wondering about are the post-processing features that are available in SimplePie for WordPress plugin:
http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress/processing
Can I find something similar to this for my Django application?
Can this be ...
I have a script that's provided with another software package - which I would not like to modify in any way. I need to execute this script, provide a password, and then interact with it from the terminal (using raw_input, etc.).
...
I have a timezone aware timestamptz field in PostgreSQL. When I pull data from the table, I then want to subtract the time right now so I can get it's age.
The problem I'm having is that both datetime.datetime.now() and datetime.datetime.utcnow() seem to return timezone unaware timestamps, which results in me getting this error:
TypeEr...
What is the write way to get the length of a string in Python, and then convert that int to a byte array? What is the right way to print that to the console for testing?
...
I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask
What are strengths of shell scripting that make it an indis...
I have the following models:
class Category(models.Model):
name = models.CharField(max_length=40)
class Item(models.Model):
name = models.CharField(max_length=40)
category = models.ForeignKey(Category)
class Demo(models.Model):
name = models.CharField(max_length=40)
category = models.ForeignKey(Category)
item =...
Of course an HTML page can be parsed using any number of python parsers, but I'm surprised that there don't seem to be any public parsing scripts to extract meaningful content (excluding sidebars, navigation, etc.) from a given HTML doc.
I'm guessing it's something like collecting DIV and P elements and then checking them for a minimum...
Hi all,
here is my problem...
I have a python script that, once executed from command line, performs the needed operations and exit. If, during the execution, the program is not able to perform a choice, he prompts the user and asks them to take a decision !
Now I have to implement a web interface, and here comes the problems ... I crea...