django

Django QuerySet Custom Ordering by ID

Given a list of ids/pks, I'd like to generate a QuerySet of objects ordered by the index in the list. Normally I'd begin with: pk_list = [5, 9, 2, 14] queryset = MyModel.objects.filter(pk__in=pk_list) This of course returns the objects, but in the order of the models meta ordering property, and I wish to get the records in the order ...

Django and PIL on Snow Leopard

I am trying to get PIL working with Django 1.2.1 and Python 2.7 on Snow Leopard I have followed instructions I found here on SO and I should be doing it right. The imports and selftest.py works fine and I both save and open images in the interactive python, but Django cannot use it. I get the error The _imaging C module is not instal...

Load Balancing Multiple Django Webservers

I was wondering if anyone had ever implemented multiple Django webservers pointing to a single database, essentially functioning as a single website via load balancing? What software did you use for load balancing? What additional setup/configuration did your Django webservers require? Did you need to modify your Django code in any wa...

Subtract two values

I'd like to subtract two values, one in the current record, then the next in the next record...they are time clock entries and I want to calculate the amount of time an employee spend on his/her break, so I'll have to subtract the time the employee clocked out, and the time the employee clocked back in. This will be done for several rec...

Django FloatField in ModelForm with 2 precision point

Hello All, I have a FloatField in one of my model. I Add/Edit it using ModelForms. What I need is that, when i edit, the Float value stored in FloatField to be rendered with exactly 2 precision points. i.e. if my stored value is 1000.0 or 1000.123, i want the input field of form to show initial value of 1000.00 or 1000.12. Any suggest...

Django Sessions getting dropped when redirected from another domain.

When a user visits my domain, a sessionid is issued by django. When he tries to do Oauth with Facebook, he clicks a button on my site which redirects to Facebook.com. Facebook redirects back to my domain, but at this point, the user's session is lost and Django seems to be issuing a new session variable. I want the dropped session to p...

How to display many-to-many field as a list of text input fields?

When I display the ToolBoxEditForm it uses a multiple select field. But what I want is a form that lets the user edit each tool he has in the toolbox as a text field. I cant figure out how to do this with the many-to-many field. class Tool(models.Model): tool_name = models.CharField(unique=True, max_length=200) ...... class ToolBox...

django queryset for many-to-many field

I have the following Django 1.2 models: class Category(models.Model): name = models.CharField(max_length=255) class Article(models.Model): title = models.CharField(max_length=10, unique=True) categories = models.ManyToManyField(Category) class Preference(models.Model): title = models.CharField(max_length=10, unique=Tru...

What's the most productive frontend framework to use with SOLR as the backend?

Want to build a web app using SOLR as the only backend. Most of the data will be stored in SOLR via offline jobs although there is some need for CRUD. Looking at popular web frameworks today like Rails, Django, web2py etc. despite NoSQL the sweet spot for productivity still seems to be around active record implementations sitting on top...

How to add a non database field to a database driven Django model, and set it via a QuerySet preserving its datatype?

I've got a Django model containing various database model fields. One of the manager's querysets retrieves various aggregations via some annotate calls. Some of those annotations are custom made and retrieve float values from the database. Those annotations are not part of the model's fields. However, when the queryset is created, thos...

Django / Python, getting field name from database get object?

Sorry if I'm missing something obvious here as my search isn't turning up anything relevant. I am doing a Django database get query and would like to get each field name during a for loop so that I can do evaluations of it ( if fieldname = "blah") and so on, but I can't seem to figure this out, any advice is appreciated db_get_data = Mo...

Determining the Bazaar version number from Python without calling bzr

I have a django (Python) project that needs to know what version its code is on in Bazaar for deployment purposes. This is a web application, so I don't want to do this because it fires off a new subprocess and that's not going to scale. import subprocess subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)...

Django get_FIELD_display in a template question

Hi Guys, I am using the regroup feature of Django to group by "team", here is my code: {% regroup show_detail.cast_set.all by team as cast_list %} <ul> {% for cast in cast_list %} <li>{{ cast.grouper }} <ul> {% for item in cast.list %} <li>{{ item.name }} </li> {% endfor %} ...

Django: no such table: django_session

Hello, I have found several topics with this title, but none of their solutions worked for me. I have two Django sites running on my server, both through Apache using different virtualhosts on two ports fed by my Nginx frontend (using for static files). One site uses MySql and runs just fine. The other uses Sqlite3 and gets the err...

Recompile Django without restarting Apache

Hello, I know there are topics on this and I am aware of using Daemon processes with mod_wsgi, but I am running on a Windows computer and I don't believe WSGIDaemonProcess is therefore available. Is there any other way I can recompile Django without restarting Apache with mod_wsgi on a Windows computer? If not that's fine but I ju...

Django uploading file not in MEDIA_ROOT path is giving me SuspiciousOperation error

I want to upload files to a path that is still in my django project, but in my MEDIA_ROOT path. When I try to do this I get a SuspiciousOperation error. Here are the paths as defined in my settings file: MEDIA_ROOT = os.path.join(os.path.dirname( __file__ ), 'static_serve') UPLOAD_DIR = os.path.join(os.path.dirname( __file__ ), 'upl...

With JS, jQuery, how do I save an AJAX response to a (text) file?

It seems like this question is asked periodically and the common response is "You shouldn't do that with AJAX anyway. Just set the window location to the file." But I'm trying to request a file that doesn't actually exist out on the server anywhere. It's dynamically generated (by a Django view) given the GET/POST context parameters. The...

Why is mod_python running entire django stack from beginning with each request?

My understanding is that mod_python loads the python process into apache, avoiding the overhead of doing that on each call. My expectation was that this would mean that my django stack would also only be loaded once. What I am observing, however, is that every request is running the entire django stack from the beginning, as though it ...

django, postgres 8.4, psycopg 2.2.2, python 2.7, mod_wsgi

I've installed django/postgres on local django server and works fine. I'm trying to get Apache working. I've set up the mod_wsgi and was able to get a "Hello World", and restart Apache. I'm almost there, but when I bring up localhost/index.html I get this server error: TemplateSyntaxError: Caught ImproperlyConfigured while rendering:...

Facebook authentication for Django projects

Hello, world! Which implementation is most correct, modern and easiest in your opinion: http://github.com/dickeytk/django_facebook_oauth or http://github.com/teebes/django-facebookconnect/ or http://github.com/tschellenbach/Django-facebook ? Thanks! ...