django

What are your favorite general purpose Django apps?

What are the apps that you consider part of your core toolset for Django projects (including those shipped with Django)? For example, I just discovered Migratory for database migration management: I just love it, and I wish something like that would be included in Django. I took a look at DjangoPlugables.com and other such web sites, b...

How to combine 2 or more querysets in a Django view?

Hi, I am trying to build the search for a Django site I am building, and in the search I am searching in 3 different models. And to get pagination on the search result list I would like to use a generic object_list view to display the results. But to do that i have to merge 3 querysets into one. How can i do that? Ive tried this: resu...

Displaying a Django query result in HTML - table, list, css divs?

I am working on an django application that will return what historically was a table of information: ISSUE DESCRIPTION INITIATOR INITIATEDDATE ASSIGNEE FORECASTDATE STATUS REMARKS That will be the entrance point for users to sort / filter, etc the list of issues. The columns like ISSUE, DATES, NAMES are of relatively fixed widt...

Can I access constants in settings.py from templates in Django?

I have some stuff in settings.py that I'd like to be able to access from a template, but I can't figure out how to do it. I already tried {{CONSTANT_NAME}} but that doesn't seem to work. Is this possible? ...

Updating live server from VCS

I run all my Django sites as SCGI daemons. I won't get into the fundamentals of why I do this but this means that when a site is running, there is a set of processes running from the following command: /websites/website-name/manage.py runfcgi method=threaded host=127.0.0.1 port=3036 protocol=scgi All is fine until I want to roll out a...

How do I add a custom inline admin widget in Django?

This is easy for non-inlines. Just override the following in the your admin.py AdminOptions: def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'photo': kwargs['widget'] = AdminImageWidget() return db_field.formfield(**kwargs) return super(NewsOptions,self).formfield_for_dbfield(db_field,**k...

Column comparison in Django queries

I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage = models.IntegerField() I want to select all cars where mileage is less than mileage_limit, so in SQL it would be something like: select * from car where mileage < mileage_limit; Using ...

Filtering a complete date in django?

There are several filter methods for dates (year,month,day). If I want to match a full date, say 2008/10/18, is there a better way than this: Entry.objects.filter(pub_date__year=2008).filter(pub_date__month=10).filter(pub_date__day=18) ...

Cleaning up a database in django before every test method

By default when Django runs against sqlite backend it creates a new in memory database for a test. That means for every class that derives from unittest.TestCase, I get a new database. Can this be changed so that it is cleared before every test method is run? Example: I am testing a manager class that provides additional abstraction on ...

Django - Custom virtual model field with companion stored field

I would like to have a ConfirmationField field type. I want this field to work like a boolean field. I don't need to store this information on database instead I would like to store the date of confirmation on a seperate field. class MyModel(models.Model): confirmation = ConfirmationField() m = MyModel() m.confirmation # False m.c...

What should "value_from_datadict" method of a custom form widget return?

I'm trying to build my own custom django form widgets (putting them in widgets.py of my project directory). What should the value "value_from_datadict()" return? Is it returning a string or the actual expected value of the field? I'm building my own version of a split date/time widget using JQuery objects, what should each part of the...

Duplicating model instances and their related objects in Django / Algorithm for recusrively duplicating an object

I've models for Books, Chapters and Pages. They are all written by a User: from django.db import models class Book(models.Model) author = models.ForeignKey('auth.User') class Chapter(models.Model) author = models.ForeignKey('auth.User') book = models.ForeignKey(Book) class Page(models.Model) author = models.ForeignKey...

What is the best UI for selecting tags from a list of existing tags?

I am using django-tagging. My model simply contains a field with a comma separated list of tags. I would like the user to be able to select tags from a list of already existing tags and also allow the user to add tags. Still resulting a comma-separated list of tags. How would I do that? A pull down list doesn't work. I was thinking abou...

I've got an existing Django app with a lack of database indexes. Is there a way to automatically generate a list of columns that need indexing?

The beauty of ORM lulled me into a soporific sleep. I was thinking maybe some middleware that logs which columns are involved in WHERE clauses? but is there anything built into MySQL that might help? ...

How can I use multiple shipping values in satchmo?

There's already some shipping modules such as FEDEX, Flat Rate, Per pieced and UPS but how can I let the user choose its preferred shipping method and/or price? For those who don't know, Satchmo is a django app. ...

Applying taxes on Satchmo's cart total price

I can't seem to apply a tax value on the cart total value even though I : activated the "By Country/Area" tax module. added my country/region tax rate. checked the "Show With tax included" checkbox. here's attached a screenshot of the on-going problems, I've selected the areas where something's fishy. So basically, the cart shows "W...

What's wrong with "magic"?

I'm trying to decide whether to use a Rails or a Django guru to create a web app for me. I've been recommended to use Django because it uses less "magic". From my perspective however, the "magic" of Rails seems like a good thing since it could make development more concise for my contractor resulting in fewer billable hours at my expense...

Django custom SQL to return QuerySet where each object has additional properties

Let's say I have the following objects: squirrel_table - name - country_of_origin - id nut_table - id - squirrel_who_owns_me[fk to squirrel] I want to retrieve a list of all squirrels in a particular country. The returned squirrel objects can be in a QuerySet, but do not need to be. A list will suffice. Each squirrel will...

Pre-populate an inline FormSet?

I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table: class Event(models.Model): event_id = models.AutoField(primary_key=True) date = models.DateField() event_type = models.ForeignKey(Even...

What is the best approach to implement configuration app with Django?

I need to program kind of configuration registry for Django-based application. Requirements: Most likely param_name : param_value structure Editable via admin interface Has to work with syncdb. How to deal with a situation in which other apps depend on configuration model and the model itself has not been initialized yet in DB? Let's...