django

How do I set up gaeunit 2.0a with my Django app?

I am trying to set up Google App Engine unit testing for my web application. I downloaded the file from here. I followed the instructions in the readmen by copying the directory gaeunit into the directory with the rest of my apps and registering 'gaeunit' in settings.py. This didn't seem sufficient to actually get things going. I als...

Parsing a list of dictionaries passed as a POST parameter

I have a list of python dictionaries that look like this: sandwiches = [ {'bread':'wheat', 'topping':'tomatoes', 'meat':'bacon'}, {'bread':'white', 'topping':'peanut butter', 'meat':'bacon'}, {'bread':'sourdough', 'topping':'cheese', 'meat':'bacon'} ] I want to pass this as a POST parameter to another Django app. What doe...

Django query - join on the same table

i have a mini blog app, and a 'timeline' . there i want to be displayed all the posts from all the friends of a user, plus the posts of that user himself. For that, i have to make some kind of a 'join' between the results of two queries (queries on the same table) , so that the final result will be the combination of the user - posesor o...

Django: how to pass form variable to simple tag in template

Hello. I am trying to do some custom things in Django comments form. I have simple tag named "get_flatpage_by_id" that returns flatpage model data as array. This is working I expected: {% get_flatpage_by_id 14 as page %} It's returning flatpage that ID is 14. But this is not working, if I try to pass {{ form.object_pk.data }} (that ret...

LDAP query using Python: always no result

I am trying to use python to query LDAP server, and it always returns me no result. and anyone help me find what wrong with my python code? it runs fine without excpetions, and it always has no result. i played around with the filter like "cn=partofmyname" but just no luck. thanks for help import ldap try: l = ldap.open("server")...

Design an Application That Stores and Processes Files

I'm tasked with writing an application that acts as a central storage point for files (usually document formats) as provided by other applications. It also needs to take commands like "file 395 needs a copy in X format", at which point some work is offloaded to a 3rd party application. I'm having trouble coming up with a strategy for t...

mutli django admins with different db databases in django 1.2 - strange problem

Hey, I am using django 1.2 to create a multi site shop. I need multiple admin logins for each shop instance, e.g. site.com/au/admin site.com/uk/admin and so on. I have a middleware class and a dbrouter that handles database connections based on the URL. This works fine. I am trying to add some customisation per admin system based on...

Passing variable urlname to url tag in django template

Hi All, What I'd like to do (for a recent changes 'widget' - not a django widget in this case) is pass a urlname into my template as a variable, then use it like so: {% url sitechangeobject.urlname %} Where urlname is a string containing a valid name for a url. Is this possible? The template keeps breaking saying it can't find sitechan...

How to handle expired items?

My site allows users to post things on the site with an expiry date. Once the item has expired, it will no longer be displayed in the listings. Posts can also be closed, canceled, or completed. I think it would be be nicest just to be able to check for one attribute or status ("is active") rather than having to check for [is not expired,...

A daemon to call a function every 2 minutes with start and stop capablities

Hi, I am working on a django web application. A function 'xyx' (it updates a variable) needs to be called every 2 minutes. I want one http request should start the daemon and keep calling xyz (every 2 minutes) until I send another http request to stop it. Appreciate your ideas. Thanks Vishal Rana ...

How to make credit card payments in Django?

I need to make credit card payments on my site that provides a service outside the U.S., but I will not be through paypal, where should I start? anyone knows how I can do this? ...

django development mode runserver --noreload hits 100 percent cpu usage

i have setup on pydev eclipse everytime i run runserver --noreload my cpu usage hits to 100 percent on core 2 duo laptop .. pretty much this guy had the same problem http://stackoverflow.com/questions/1750676/django-development-server-cpu-intensive-how-to-analyse i tried on a quad core machine it gets to 30 percent cpu usage too. ...

Django form to enter/save html to database

I'm in my first week of Django development and am working on an admin page that will let me write some quick html using TinyMCE and then save it to the database. I don't need to display this web page on the site or add it to urls.py, etc. The html snippet will be loaded from the database and used in a view function. I've read in "Practi...

Drawbacks of using an integer as a bitfield?

I have a bunch of boolean options for things like "acceptable payment types" which can include things like cash, credit card, cheque, paypal, etc. Rather than having a half dozen booleans in my DB, I can just use an integer and assign each payment method an integer, like so PAYMENT_METHODS = ( (1<<0, 'Cash'), (1<<1, 'Credit Card...

Can django lazy-load fields in a model?

One of my django models has a large TextField which I often don't need to use. Is there a way to tell django to "lazy-load" this field? i.e. not to bother pulling it from the database unless I explicitly ask for it. I'm wasting a lot of memory and bandwidth pulling this TextField into python every time I refer to these objects. The al...

Django inlineformset validation and delete

Hi, Can someone tell me if a form in an inlineformset should go through validation if the DELETE field is checked. I have a form that uses an inlineformset and when I check the DELETE box it fails because the required fields are blank. If I put data in the fields it will pass validation and then be deleted. Is that how it is supposed t...

How to create custom CSS "on the fly" based on account settings in a Django site?

So I'm writing a Django based website that allows users select a color scheme through an administration interface. I already have middleware/context processors that links the current request (based on domain) to the account. My question is how to dynamically serve the CSS with the account's custom color scheme. I see two options: A...

Is it ok to hardcode dynamic links in a permanent view?

Let's say I wanted to showcase 2-3 clickable buttons on my homepage which will be there permanently. These are links to the css, html, and javascript tag listing pages. Is it fine to just hardcode href=/tags/css and href=/tags/html right in my django templates/view? I won't change them for at least a year or so, meaning I don't think I...

asynchronous writing and reading of a file

Hi, I have two processes. One processes is redirecting output of some unix command to a file on server side.The data is always appended to the file. e.g. find / > tmp.txt Another process is opening and reading the same file and storing it in a string and sending the entire string to the client. Now, this things take simultaneously...

Exception RuntimeError

Hi... I am getting 2 following errors: Exception RuntimeError: 'maximum recursion depth exceeded in subclasscheck' in ignored Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored What is the cause for the same.... I have not made any changes to my application since yesterday.... Suddenl...