django

Different ManyToManyField widget

The default django 1.0.2 ManyToManyField widget (a multi-select) is difficult to use when there are a lot of things in the select box. Is there another widget available that gives a comma separated list of id's in a textarea? If this is not available what do I need to do to write one, and have it show up on ModelForm.as_p() and in the...

Testing time sensitive applications in Python

I've written an auction system in Django. I want to write unit tests but the application is time sensitive (e.g. the amount advertisers are charged is a function of how long their ad has been active on a website). What's a good approach for testing this type of application? Here's one possible solution: a DateFactory class which provi...

Amazon S3 permissions

Trying to understand S3...How do you limit access to a file you upload to S3? For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file? It seems like the query string authentication requires an expiration date and that won't work for me, is there ano...

Django / mod_wsgi / postgresql_psycopg2: can't connect authentication fails (but settings work fine under django runserver or dbshell)

Hi Stackers, I'm deploying my django site on a Ubuntu 8.10 server that I've set up from scratch. I'm totally new to this so there may be plenty of stuff that I've missed, but happily have found my way through to the point of deploying a website. My last hurdle: I'm getting an authentication error with postgresql [Sun Apr 19 18:44:05...

Some internals of Django auth middleware

In the django.contrib.auth middleware I see the code: class AuthenticationMiddleware(object): def process_request(self, request): assert hasattr(request, 'session'), "requires session middleware" request.__class__.user = LazyUser() return None Please avdise me why such a form request._ class _.user = L...

How do I prevent execution of arbitrary commands from a Django app making system calls?

I have a Django application I'm developing that must make a system call to an external program on the server. In creating the command for the system call, the application takes values from a form and uses them as parameters for the call. I suppose this means that one can essentially use bogus parameters and write arbitrary commands for t...

django left join

I have a bit of a left join issue.. I have the following models class CommandInfo(models.Model): server = models.ForeignKey(Server) count = models.IntegerField(default=1) ts = models.DateTimeField(auto_now=True) class Server(models.Model): name = models.CharField(max_length=100) group = models.ForeignKey(Application...

How do I use AND in a Django filter?

How do I create an "AND" filter to retrieve objects in Django? e.g I would like to retrieve a row which has a combination of two words in a single field. For example the following SQL query does exactly that when I run it on mysql database: select * from myapp_question where ((question like '%software%') and (question like '%java%')) ...

What is the best secure way to allow a user to delete a model instance that they added to the db?

I would like to give users access to delete a model instance that they added to the db. In the django docs it says allowing someone to delete from the template is not a good practice. Is there a secure way to let a user click a "delete this" link from the template and remove that model instance? How should I go about doing that? ...

Django Custom Template Tags In Google App Engine

I am trying to include the following Tag In Google App Engine Web Application: http://www.djangosnippets.org/snippets/1357/ Is there any configuration of this file to make it work with Google App Engine? Cause I followed the Django Template tutorials: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ and have this stru...

Installing Django on Shared Server: No module named MySQLdb?

I'm getting this error Traceback (most recent call last): File "/home/<username>/flup/server/fcgi_base.py", line 558, in run File "/home/<username>/flup/server/fcgi_base.py", line 1116, in handler File "/home/<username>/python/django/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) F...

How to design html pages which renders properly in windows while staying in Linux?

I usually prefer linux for programming( i program in django on Ubuntu). But often i need to design html pages which renders properly in Windows and Linux? How iam currently doing the above is Design (Fix) html page in linux Reboot to windows check whether the design is proper or not. if not reboot to linux repeat step1 ,step...

How to organize checkboxes in several columns in Django forms

I am a newbie to Django and web-development in general so be patient for maybe a very dumb question :) I have a form generated from a model and in this form I have about 20 checkboxes. Now they are aligned in one long column and it looks not very nice from a UI point of view. I'd like this column to be split in several ones but still ha...

How do I get the class of a object within a Django template?

If I have a list of objects that require similar layouts but need some attribute set based on the class of object how can I go about getting the class name while class and other xx values are not available within templates. {% for obj in objects %} <div class={{obj.__class__.__name__}} .. </div> {% endfor }} There is probably an...

Django caching for subdomains

I'm using subdomains in django for user pages via a middleware hack in a similar way to what is described here: stackoverflow.com/questions/624827/in-a-django-web-application-how-do-you-give-users-their-own-subdomain Now, I have the default django cache turned on for all pages for not-logged-in users. I had to disable the cache implicit...

Django payment proccessing

Can anyone suggest any good payment processing libraries for python/django? ...

django foreignkey contains query

I have the following model class Command(models.Model): server = models.ForeignKey(Server) user_login = models.CharField(max_length=100) user_run = models.CharField(max_length=100) host = models.CharField(max_length=100) ip = models.CharField(max_length=100) session = models.CharField(max_length=100) command ...

Magento ORM Documentation

Outside of the source code, is there any extensive documentation on the Magento ORM? I get the basics, and can usually dig through the Mage code base, litter it with Mage::Log calls and figure out something that works, but my efficiency would go way up if I had a high level overview of how the models are intended to be used. How do the...

Moving objects from one many-to-many association to another in django?

Hey all, Got a question. Say I have two models in a many-to-many relationship (Article, Publication). Article A is in Publication One, Two, and Three. I want to remove it from those publications and put it into Publication X. The django documentation covers deleting objects and adding objects, but I don't want to delete nor add objects,...

Django admin display groups horizontally

How do I get Django admin to display groups horizontally? If I have 3 adjacent datetime fields, I'd rather them take up 1 row, not 3. ...