django

python imaplib ssl error using celeryd queue

I'm having a problem using imaplib on python 2.6 with the latest django svn. I want to download imap emails in a queue (using celeryd). I'm able to connect/download emails from the command line, but when i offload the task through django to celeryd i get this error: "SSLError: [Errno 1] _ssl.c:1325: error:1408F10B:SSL routines:SSL3_GET_R...

Conditional query from html controls

I want to build a web page where user can select data from different html controls and form a conditional query. For instance a == 2 and b == 4 and c == 6 or x == 0 The data for a, b, c and x comes from html controls and user is also able to delete different conditions in the query. Later I want to transform this query into j...

Django: Question about model architecture

Does this facade code look like a good idea, or is there anything inherently flawed about the design? More importantly, is there a problem I will likely run into down the road with this code? Any help is much appreciated. I'm trying to build this so that I can have a Payment class as my facade, which accepts cc numbers, etc. and a PayPa...

Django JSON fixture generation

I'm new to Django coming from Rails, and I am finding the Django fixtures (most commonly JSON from what I gather), to be somewhat awkward and unweildy, at least in comparison to the rails fixtures that I am familiar with. I liked being able to embed some ruby code, e.g <%= Time.now %>, or reference other fixtures by name when relating ...

Trouble with pycurl.POSTFIELDS

I'm familiar with CURL in PHP but am using it for the first time in Python with pycurl. I keep getting the error: Exception Type: error Exception Value: (2, '') I have no idea what this could mean. Here is my code: data = {'cmd': '_notify-synch', 'tx': str(request.GET.get('tx')), 'at': paypal_pdt_test ...

how to make RSS feeds where the /rss/ is at the end of the URL, not at the beginning?

http://docs.djangoproject.com/en/dev/ref/contrib/syndication/ describes the way to use the Feeds class, and it works well for me, but it requires the URL to be like http://example.com/rss/feedid/parameters/ I need it to be http://example.com/feedid/parameters/rss/ How to do that? ...

Make settings.py customizable from user input?

def save_local_setting_JSON(dest, content): fwrite = open(dest, 'wb') dict_json = eval(json.dumps(content)) string_json =json.dumps(dict(dict_json)) fwrite.write('EMAIL_DEVELOPMENT='+string_json+"\n") fwrite.close() def config_mail_show(request, template='admin/config_mail.html'): form = form...

How do I reference a choice list in django template?

Hi guys, I have the following in my django model: PRIORITY = ( (1, 'Low'), (2, 'Normal'), (3, 'High'), ) Obviously the entry associated with this is storing the integer. In my template however I would like to show the priority in human-readable format. How exactly do I accomplish this? My template: {% for x in items %...

Django: Can I have an app in a sub folder of another app?

I tried to put an app inside another app (Outer one is a facade into the inner one so it made sense to locate them that way), and it doesn't create a table for the model in that inner app. Is this normal? (the app is installed, and registered with the admin) ...

What is the relationship between '@1' and '@2'

class SortedDict(dict): def __new__(cls, *args, **kwargs): instance = super(SortedDict, cls).__new__(cls, *args, **kwargs) instance.keyOrder = [] return instance def __setitem__(self, key, value): super(SortedDict, self).__setitem__(key, value)#@1 if key not in self.keyO...

django - what's the best/recommended way to translate db values?

Hi - I'm trying to figure out the best way to translate actual database values (strings, not date formats or anything complicated) when i18n-ing my application. The most logical thing I could come up with is either hold a column for every language ('description_en', 'description_de', 'description_fr', etc) or have a different db for ev...

saving data in Bulk using Django

Hi all, I have objects A witch has many to many relation ship to object b. Is it possible to save objects A with it's B collection in a bulk ' I mean not to save B objects one by one then add them to A. for b in b_objects : A.b_objs.add(b) A.save() Thanks ...

ImageModel form problem

Hello, I'm trying to upload an image from a form. I'm using ImageModel with the User as a foreign key, I'm having trouble with the form . any help will be highly appreciated, please, thanks ...

Django, allowing user to use embed/object html and XSS protection

For the site i am building i would like the users to be able to provide embed codes for video and audio sites. i know this poses a security risk, so i wanted to find out, within Django, how best to filter the html provided so that only certain tags and certain sites are allowed. Does anyone have any references to how i can accomplish th...

Query and paginate three types of models at the same time in django

Hi, In django I have three models: SimpleProduct ConfigurableProduct Instead of showing several variations of SimpleProducts, the user will see one product with options like color. GroupProduct - Several SimpleProducts that are sold together. First I'm creating all the SimpleProducts, then I create ConfigurableProducts from several ...

How can I configure Apache2/mod_python/Django to abort request processing after N seconds?

I recently spent a long while debugging something that turned out to be an infinite loop bug in my own code. Since I can't guarantee I'll never make that sort of mistake again, how can I configure my web server to terminate any apache2 subprocess that remains waiting for my python app to return a response for over N seconds? In this cas...

Get specific fields from a formset

For the documentation, I'm able to display a formset as below <table> {{ formset }} </table> However, what if I want to format the layout manually? Like how it's done for ModelForms? How can I achieve this? ...

Running Different Django Versions But Sharing Authentication

Brand new to django. We have a legacy django project using django 0.96x that does authentication, ldap, etc., and it's pretty involved so we don't want to rewrite that code. We want to add a forum solution (off the shelf) but all of the ones I've seen so far require django 1.x I'm trying to figure out how to get this working and I've ...

Django, BigIntegerField, and django.contrib.auth.user.id

Django now provides a BigIntegerField for use in django models (available in svn trunk and also 1.2 alpha-1 release). I need my django.contrib.auth.user model to have a BigIntegerField as its auto-incrementing primary key, whereas it currently uses an auto-incrementing IntegerField as its primary key. Also, wherever contrib.auth.user is...

How do I turn a dictionary into a JSON object using simplejson, in Python?

It's something like this, but this example seems a little complicated. import simplejson as json json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) My dictionary is: myfruits = {'fruit':4, 'color':11} How can I turn this into a JSON, and then use render_to_response to shoot it to a template? I'm using ...