django

ImageMagick Error in Django's aino-convert app

I'm using aino-convert on a project and running into an issue I've never seen before. I've taken the exact same code from another project where I've used aino-convert, but it's blowing up with an ImageMagick error in the new project. My template code looks like this: {% thumbnail img.image "156x106" as thumb %} <img src="{{ thumb }}" al...

Excluding a Django app from being localized using a middleware

I need to localize a django project, but keep one of the applications (the blog) English only. I wrote this middleware in order to achieve this: from django.conf import settings from django.core.urlresolvers import resolve class DelocalizeMiddleware: def process_request(self, request): current_app_name = __name__.split('.'...

Is there an easier way to package with Python?

I tried to package a django app today. It's a big baby, and with the setup file, I have to manually write all packages and sub packages in the 'package' parameter. Then I have to find a way to copy fixtures, htmls / Css / image files, documentations, etc. It's a terrible way to work. We are computer scientists, we automatize, doing this...

Changing the active database in django

Hello, i'm writing a testing application that i'm using to test the rest of my code base. What i'd like to be able to do for it is when i test using this manage.py command, automatically change to be logging to a different database. is there a good way to do this? ...

random object in GAE python

Possible Duplicate: Fetching a random record from the Google App Engine Datastore? Hi there, I'm looking for an equivalent of Entry.objects.order_by('?') without using Django. I just want to get a random instance of my model using GAE datastore. ...

Sending ajax form reloads page instead of sending request

I'm struggling to create a shoutbox for django. Everything works fine now concerning reading data from the database, but when I want to add a new shout the whole page is being reloaded, and from what I was able to check - form's action remains the same, and there is no request sent to function under specified url. What am I doing wrong h...

Using Pinax's STATIC_URL for custom widgets.

Hello Stack-ers, I've come across a case whereas I've been using WYMEditor in the admin to take care of my rich text editing needs. I've now implemented the site utilising the basic/zero Pinax project. It seems however, that now I need to re-route the media needs of the wymeditor widget to STATIC_URL instead of MEDIA_URL. Though I'm ...

How do I get access to the request object when validating a django.contrib.comments form?

I would like to run a check on the IP-adress when users post with django comments. I can easily override and customize the form used by django.comments, but I need access to the request object to add an IP-test to its clean(). Is it possible to get access to this in a clean way? An alternative could be to check the IP when recieving th...

Appengine - Upload to Google Spreadsheet datastore values

Hello, I´d like to know how to upload to a Google Spreadsheet, values stored in the database of my application. Objective: Connecting to Google Spreadsheet and automatically fill in a chart in the admin area with values that were passed by the upload. I've been giving a look in the docs and it seems to me that I have to use Bulk Loa...

Allow hop-by-hop headers in Django proxy middleware

I need to implement a HTTP proxy in Django and my Google safari led me to a project called django-webproxy. Although no longer maintained, it's quite simple. Most of the logic relies on a simple proxy Middleware class that intercepts all requests to the Django WSGI server and handles it. If the Middleware returns any data, the WSGI se...

Get all Request headers in Django

I need to get all the Django request headers. From what i've read, Django simply dumps everything into the request.META variable along with a lot aof other data. What would be the best way to get all the headers that the client sent to my Django application? I'm going use these to build a httplib request. Thank you. ...

quick question: clear an attribute of a model in django

hello everybody! i think this is a pretty easy question for you. I want to clear an attribute of a django-model. If i have something like this: class Book(models.Model): name = models.TextField() pages = models.IntegerField() img = models.ImageField() In an abstract function i want to clear an attribute, but a...

django - 404 page displayed for dev web server (http://127.0.0.1:8000/)

I am familiarizing my self with django. I have succesfully installed and tested a demo site. I now want to switch on the admin module, to see what happens. This is the steps I took (granted, some were unnecessary, but I just wanted to make sure I was starting from a clean slate): Edited mysite/settings.py to enable admin Edited mysit...

Django Markdown works in dev but not in prod ..

I'm using the flatpages app with markdown and on the (django) development server markdown works fine. But when deployed on my staging server with apache/mod_python, all the markup vanish and I see the raw markdown formatting. There's not much difference between my staging server and my dev server, both runs Ubuntu with the same packag...

How third party sites can check if user agreed/pass sth on my site, so they can let him pass sth on their sites?

How third party sites can check if user agreed to something(i.e. click ok)/pass some test on my site, so they can let him pass to some hidden resources on ther site? The problem is, user should not be asked to register on those third party sites, and i give those sites only javascript to paste into their code and merely button and some t...

Question on Django: Displaying many to many fields

I seem to have a problem with Django when it comes Rendering ManyToManyField in a template. I can make it work partially, but I cannot make it work properly as I want it. Firstly I have an invoice template which displays Invoice details from my data base #invoice_details.html {% extends "base.html" %} {% block content %} <h2>Invoice D...

Django Generic object_list pagination. Adding instead of replacing arguments

Hi. I'm having some trouble with the django generic object_list function's pagination not really being "smart" enough to compensate my daftness. I'm trying to do a url for listing with optional arguments for page number and category. The url in urls.py looks like this: url(r'^all/(?:(?P<category>[-\w]+)/page-(?P<urlpage>\d+))?/$', ...

Changes to .py file cause Django site to throw error the first time it is loaded

I'm having a weird issue. Whenever i make changes to a .py file, the immediate refresh of a page in the browser throws up an invalid filter or some other similar error. Refresh again and it works. Does anyone know why this might be happening? A little vague i know, but does any potential reason for this jump out at you? Happy to provid...

Django proxy model and ForeignKey

How to make entry.category to be instance of CategoryProxy? See code for details: class Category(models.Model): pass class Entry(models.Model): category = models.ForeignKey(Category) class EntryProxy(Entry): class Meta: proxy = True class CategoryProxy(Category): class Meta: proxy = True entry = EntryProx...

How to properly iterate over a huge QuerySet in django?

I need to retrieve 5 objects that match a certain complex criteria, and I can't/don't want to pass that criteria to the WHERE clause(filter in django), so I need to iterate over the results, testing each record for the criteria until I get my 5 objects, after that I want to throw the query set away and never see it again. In most cases...