django

mounting an s3 bucket in ec2 and using transparently as a mnt point

I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com). When the user uploads the files, I can easily drop them in into a folder called "site_up...

Serving gzipped content from django

I'm trying to serve a gzipped version of a text/html page in Django, but Firefox is telling me there's a content encoding error. NOTES: I realize this is not a best practice and I'm most likely going to use mod_gzip. This is just a learning exercise to understand what's going on. I know about the Django gzip middleware-- it has probl...

Is the lift framework as "easy" as ruby on rails or django?

Just wondering if anyone has experience with the three. I have used read through some RoR and used Django. They seem fairly easy to use. Is lift "easy" like these two are? I know easy is subjective and has no context here. I mean in a very high level and general sense. ...

Django model custom save with ManyToManyField problem

I know this question has been posted multiple times but I still couldn't find a definite answer to this problem. So, here I go: class Invoice(models.Model): program = models.ForeignKey(Program) customer = models.ForeignKey(Customer, related_name='invoices') participants = models.ManyToManyField(Participant, related_name='par...

Help! Why did MySql just screech to a halt?

Our relatively high traffic website just screeched to a halt, and we're totally stumped. We run on Django and Mysql (InnoDB), and we're trying to figure out why it's all of a sudden totally slow. Here's what we know so far: On our mysql server, a simple query (from django shell) runs fast. On our app server, a simple query (from django ...

Substituting an absent field value when saving a modelform

I have a this model: class Fleet(models.Model): company = models.ForeignKey("Company", editable=False) aircraft = models.ForeignKey("Aircraft") size = models.IntegerField(default=1) description = models.TextField(blank=True) def __unicode__(self): return u"%s" % (self.aircraft, ) And then a form based on this model: class F...

Django EmailMultiAlternatives and HTML e-mail display in Outlook 2003 on Win2003

I'm using django.core.mail.EmailMultiAlternatives when sending e-mails from my django app in an attempt to make sure that the message downgrades to text if the e-mail client doesn't support HTML. Here is my send_email method: def send_email(self, from_address, to_list, subject, msg_text, msg_html): subject=subject.replace('\r',...

Why do I get an error when I try to execute a query with parameters in postgreSQL?

The db is PostgreSQL. When I try to execute a query with parameters, such as this one cursor.execute(""" SELECT u.username, up.description, ts_rank_cd(to_tsvector(coalesce(username,'')|| coalesce(description,'')) , to_tsquery('%s')) as rank FROM auth_user u INNER JOIN pm_core_userprofile up on u.id = up.user_id ...

Django: How to check if an item is in another item's ManyToMany field?

as per title. ...

Need help with Django ModelForm: How to filter ForeignKey/ManyToManyField?

Alright, I'm having a hard time explaining this, let me know if I should fill you in on more details. My url looks like this: http://domain.com/&lt;category>/ Each <category> may have one or many sub categories. I want the category page to have a form with a select box (among other fields) containing the category sub-categories. I'...

Errors in Decimal Calcs within def clean method?

I'm attempting a few simple calculations in a def clean method following validation (basically spitting out a euro conversion of retrieved uk product price on the fly). I keep getting a TypeError. Full error reads: Cannot convert {'product': , 'invoice': , 'order_discount': Decimal("0.00"), 'order_price': {...}, 'order_adjust': None, ...

Django: Mod_python error: ImportError: Could not import settings

I'm a complete noob here, so please bare with me on this one. Trying to get django to work with apache, and i'm getting the following error: ImportError: Could not import settings 'MyDjangoApp.settings' (Is it on sys.path? Does it have syntax errors?): No module named MyDjangoApp.settings My django app is located in /home/user/djan...

How to pull a random record using Django's ORM?

I have a model that represents paintings I present on my site. On the main webpage I'd like to show some of them: newest, one that was not visited for most time, most popular one and a random one. I'm using Django 1.0.2. While first 3 of them are easy to pull using django models, last one (random) causes me some trouble. I can ofc cod...

How much flexibility is there in a Django for loop?

I am outputting a series of Django objects in a template: {% for obj in list %} ... {% endfor %} But I'd like to only output the first five of these, then put the remainder in the seperate <DIV>. The idea being, that I can hide the second half until required. I envisage something like this, but need to restrict the elements itera...

bulk action in django

I am using bulk action in my model.I have switched to django1.2 beta. I want to know that when i perform a bulk action on selected data ,it is not shown on 'action list'(recent actions) displayed at the starting page of django.But if i do some changes maually means as perform in earlier versions then it shows in action list ...

[Appengine + Django] Can't seem to get list() working

I am trying to convert a set object to list...for example "p=list('abc')" is not working. any ideas or is it inherent in appengine ...

Django : Adding a property to the User class. Changing it at runtime and UserManager.create_user

For various complicated reasons[1] I need to add extra properties to the Django User class. I can't use either Profile nor the "inheritance" way of doing this. (As in http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django ) So what I've been doing is including the User class in my local_settings ...

view on site

Why view on site linked to an unwanted page.Can i disable view on site ...

<option> Level control of Select inputs using Django Forms API

I'm wanting to add a label= attribute to an option element of a Select form input using the Django Forms API without overwriting the Select widget's render_options method. Is this possible, if so, how? Note: I'm wanting to add a label directly to the option (this is valid in the XHTML Strict standard) not an optgroup. ...

How could I hack conditional behaviour into django-survey?

I need a survey application very soon. django-survey seems to be nearly what I am looking for. But one feature is missing: conditional questions i.e.: have you been taking part in this.... yes no if your answer is yes, please proceed with Question 1.1. if it is no, please proceed with Question 1.2 Here it should be c...