django

Image resizing with django?

I'm new to Django (and Python) and I have been trying to work out a few things myself, before jumping into using other people's apps. I'm having trouble understanding where things 'fit' in the Django (or Python's) way of doing things. What I'm trying to work out is how to resize an image, once it's been uploaded. I have my model setup ni...

Is it safe to track trunk in Django?

I'm currently using Django 1.1 beta for some personal projects, and plan to start messing arround with the trunk to see the new stuff under the hood. But I might start using it on a professional basis, and I'd need to know if trunk is stable enough for using in production, or I should stick to 1.0 for mission critical systems. Edit Put...

A Django ORM query using a mix of filter() and Q objects.

Hi, I'm looking to create a slightly more complex query that is written fairly easily using raw SQL. Here's an example of the query in raw: SELECT my,fields FROM sales WHERE is_paid = False OR status = 'toship' AND otherfield = 'FOO' AND anotherfield = 'BAR' This is simple, it generates all the results that are is_paid = False and...

[Django] How do I filter the choices in a ModelForm that has a CharField with the choices attribute (and hence a Select Field)

I understand I am able to filter queryset of Foreignkey or Many2ManyFields, however, how do I do that for a simple CharField that is a Select Widget (Select Tag). For example: PRODUCT_STATUS = ( ("unapproved", "Unapproved"), ("approved", "Listed"), #("Backorder","Backorder"), ...

In Django, how do you construct a formset manaully in a template?

I am constructing the pieces of a formset manually in a template. How do I get the hidden fields TOTAL_FORMS and INITIAL_FORMS. Is there a hidden display widget with them in it already there that I can call? <label>formset title</label> #formset.TOTAL_FORMS #formset.INITIAL_FORMS {% for form in formset.forms %} {{form.field}} {{...

Executing code for a custom Django 404 page

I am getting ready to deploy my first Django application and am hitting a bit of a roadblock. My base template relies on me passing in the session object so that it can read out the currently logged in user's name. This isn't a problem when I control the code that is calling a template. However, as part of getting this app ready to be...

Middleware for both Django and Pylons

It appears to me that Django and Pylons have different ideas on how middleware should work. I like that Pylons follows the standardized PEP 333, but Django seems to have more widespread adoption. Is it possible to write middleware to be used in both? The project that involves said middleware is porting a security toolkit called ESAPI fr...

How do you setup a Django project with different sites using the same data?

I'm currently looking at the the documentation for Django sites: http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites which explains how to associate content with multiple sites. The example used is LJWorld.com and Lawrence.com. What does the Django project structure look like for the above? Is each site an app on...

django configuration, mod_rewrite, mod_alias.

I've made a django site for a magazine, and it's found in mag.org/django-site. the old site is still at mag.org/httpdocs (hosted by mediatemple). I would like it so that a hit to www.mag.org turns up the django site (as is currently the case, configured so in the conf file) while a hit to archive.mag.org serves the old site from httpd...

What is the state of the art Web Application framework?

I am wanting to develop a web application, what is the current state of the art to do so? Google Web Toolkit? Favorite languages: C#, Java, Python. If I understand correctly the respective best ways are ASP.NET, Spring, and Django correct? Also Rails is out there too. I'm just saying general purpose? Suppose you had a version of MSP...

Why Django does not "really" support automatic table update?

Recently I have been trying to learn web development in Django and i am very happy about it... But, one thing is really annoying -especially when you get the idea about 'simplicity' philosophy behind django. It is that updating a table in django is really far away from simplicity as i just experienced. For example, just like the real ...

Duplicate django query set?

I have a simple django's query set like: qs = AModel.objects.exclude(state="F").order_by("order") I'd like to use it as follows: qs[0:3].update(state='F') expected = qs[3] # throws error here But last statement throws: "Cannot update a query once a slice has been taken." How can I duplicate the query set? ...

Trying to understand Django's sorl-thumbnail

I have been playing around with sorl-thumbnail for Django. And trying to understand how it works better. I've read the guide for it, installed it in my site-packages, made sure PIL is installed correctly, put 'sorl.thumbnail' in the INSTALLED APPS in my settings.py, put 'from sorl.thumbnail.fields import ImageWithThumbnailsField' at th...

How to solve this complex recursive problem, pyramid point system

Hi, I'm trying to program a pyramid like score system for an ARG game and have come up with a problem. When users get into the game they start a new "pyramid" but if one start the game with a referer code from another player they become a child of this user and then kick points up the ladder. The issue here is not the point calculation...

django - circular import problem when executing a command

I'm developing a django application. Modules of importance to my problem are given below: globals.py --> contains constants that are used throughout the application. SITE_NAME and SITE_DOMAIN are two of those and are used to fill some strings. Here is how I define them: from django.contrib.sites.models import Site ... SITE_DOMAIN = Sit...

Google App Engine with Django 1.0.2

Earlier it was necesary to install google-app-engine-django helper and distribute Django in zip. But how should I use it now after that they updated Google App Engine with Django 1.0.2. ...

Djang-admin : How to display link to object info page instead of edit form , in records change list ?

I am customizing Django-admin for an application am working on . so far the customization is working file , added some views . but I am wondering how to change the records link in change_list display to display an info page instead of change form ?! in this blog post :http://www.theotherblog.com/Articles/2009/06/02/ extending-the-django...

Iterating over model attributes when creating a template in Django

I'm using Django in Google App Engine. If I have the class class Person(): first_name = StringProperty() last_name = StringProperty() and I have an instance where Person.first_name = Bob and Person.last_name = Vance, can I create a template that iterates over the Person attributes to produce: <tr> <td>First</td> <td>Bob</td>...

unique value field based on another field in django

Preface: I am new to django and to db design. SUPEREDIT: I made some significant changes, so the answers before my changes may reference things not here. I apologize. I'll get right to the code: models.py: class Player(models.Model): name = models.CharField() class Team(models.Model): name = models.CharField() members = m...

Django (?) really slow with large datasets after doing some python profiling

Hi, I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one. First, some context: I have a page that spits out reports of sales data. The data can be filter...