django

.order_by() Isnt working how it should/how i expect it to

In my django project i am using Product.objects.all().order_by('order') in a view, but it dosnt seem to be working properly. This is its output: Product Name Sort Evolution 2 Polarity 1 Jumbulaya 3 ...

Nginx + fastcgi truncation problem

I'm running a Django site using the fastcgi interface to nginx. However, some pages are being served truncated (i.e. the page source just stops, sometimes in the middle of a tag). How do I fix this (let me know what extra information is needed, and I'll post it) Details: I'm using flup, and spawning the fastcgi server with the followin...

Django: Model limit_choices_to={'user': user}

I went to all the documentation, also I went to the IRC channel (BTW a great community) and they told me that is not possible to create a model and limit choices in a field where the 'current user' is in a ForeignKey. I will try to explain this with an example: class Project(models.Model): name = models.CharField(max_length=100) emp...

Django/Python - Grouping objects by common set from a many-to-many relationships

This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that. In Python, it's worth mentioning that the problem is somewhat related to how-do-i-use-pythons-itertoolsgroupby. Suppose you're given two Django Model-derived classes: fro...

Django admin site not displaying ManyToManyField relationship

I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields. Here's my models.py: class Tech(models.Model): name = models.CharField(max_length = 30) class Project(models.Model): title = models.CharField(max_length = 50) techs = models.ManyToManyF...

Django and Python 2.6

I'm just starting to get into Django, and of course as of last night one of the two new Python versions went final (2.6 obviously ;)) so I'm wondering if 2.6 plus Django is ready for actual use or do the Django team need more time to finish with tweaks/cleanup? All the google searches I did were inconclusive, I saw bits about some ini...

Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields?

I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField). With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doing so (see below), but nothing...

Change Django Templates Based on User-Agent

I've made a Django site, but I've drank the Koolaid and I want to make an IPhone version. After putting much thought into I've come up with two options: Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework. Find some time of middleware that reads the user-agent, and changes the templa...

How would I package and sell a Django app?

Currently I am hosted a Django app I developed myself for my clients, but i am now starting to look at selling it to people for them to host themselves. My question is this: How can i package up and sell a Django app, but also protect my code from pirating or theft. Distributing a bunch of .py files doesn't sound like a good idea as the...

Django, mod_python, apache and wacky sessions

I am running a Django through mod_python on Apache on a linux box. I have a custom authentication backend, and middleware that requires authentication for all pages, except static content. My problem is that after I log in, I will still randomly get the log in screen now and again. It seems to me that each apache process has it's own py...

Django: How do I create a generic url routing to views?

I have a pretty standard django app, and am wondering how to set the url routing so that I don't have to explicitly map each url to a view. For example, let's say that I have the following views: Project, Links, Profile, Contact. I'd rather not have my urlpatterns look like this: (r'^Project/$', 'mysite.app.views.project'), (r'^Links/...

Is it possible to have separate SQLite databases within the same Django project?

I was considering creating a separate SQLite database for certain apps on a Django project. However, I did not want to use direct SQLite access if possible. Django-style ORM access to these database would be ideal. Is this possible? Thank you. ...

Django signals vs. overriding save method

I'm having trouble wrapping my head around this. Right now I have some models that looks kind of like this: def Review(models.Model) ...fields... overall_score = models.FloatField(blank=True) def Score(models.Model) review = models.ForeignKey(Review) question = models.TextField() grade = models.IntegerField() A ...

How do you develop against OpenID locally

I'm developing a website (in Django) that uses OpenID to authenticate users. As I'm currently only running on my local machine I can't authenticate using one of the OpenID providers on the web. So I figure I need to run a local OpenID server that simply lets me type in a username and then passes that back to my main app. Does such an Op...

Django UserProfile... without a password

I'd like to create a subset of Users that don't have a login... basically as a way to add a photographer field to photos without having a full blown account associated with that person (since in many cases, they'll never actually log in to the site). A caveat is that I'd also like to be able to enable an account for them later. So, I th...

Apache or lighttpd

For development, I use a local LAMP stack, for production I'm using MediaTemple's Django Container (which I'm loving BTW). MT's container uses lighthttpd. Honestly I've never had any other experience with it. I've always used Apache. I've been doing some reading: Onlamp TextDrive Linux.com Here's are questions: What strengths doe...

django development IDE

I have done a little django development but it has all been in a text editor. I was curious what more advanced development tools others are using in their django development. I am used to using Visual Studio for development and really like the intellisense, code completion, and file organization it provides and would like to find somet...

What is the best way to migrate data in django

After making some changes in my models (eg. new field in a model and a new model) what is the best way of reflecting these changes to my populated database? PS: I wanted to see many solutions in one place rated. Apparently more solutions are already listed here. ...

Keeping filters in Django Admin

What I would like to achive is: I go to admin site, apply some filters to the list of objects I click and object edit, edit, edit, hit 'Save' Site takes me to the list of objects... unfiltered. I'd like to have the filter from step 1 remembered and applied. Is there an easy way to do it? ...

In the Django admin interface, is there a way to duplicate an item?

Just wondering if there is an easy way to add the functionality to duplicate an existing listing in the admin interface? In data entry we have run into a situation where a lot of items share generic data with another item, and to save time it would be very nice to quickly duplicate an existing listing and only alter the changed data. Us...