django

Python .pyc files removal problem in django app

Hi i have a following solution structure in python: main_app main_app/template_processor/ main_app/template_processor/models main_app/template_processor/views everything works just fine on my local machine. as soon as code gets to server (it stopped working after i removed all .pyc files from svn), it doesn't see the assembly (if it...

What's the easiest way of finding a child instance from a parent instance in Django?

My application uses class inheritance to minimize repetition across my models. My models.py looks kind of like this: class BaseModel(models.Model): title = models.CharField(max_length=100) pub_date = models.DateField() class Child(BaseModel): foo = models.CharField(max_length=20) class SecondChild(BaseModel): bar = models...

asset managers for django - choose which one?

I would like to bundle up css and javascript files. I also want to send far-future expire headers to clients, so I need file versioning. A quick search across the Internet has shown there are several asset managers developed for Django. Here is a list of those that I could reach: django-compress django-assets django-assetpackager dja...

Is there a way to specify a value from a list of one-to-many models at Django's Template?

Is there a way to specify a value from a list of one-to-many models at Django's Template? For example I can do this in the shell: author.book_set.get(publisher=my_publisher). However I want something like that in my template. I'm only passing Authors, a list of Author and publisher to the template. Models: class Publisher(models.M...

Django inline edit of model with FilePathField

I have this simple setup: class Artist(Model): ... class Download(Model): artist = ForeignKey(Artist) title = CharField() file = FilePathField(...) and the admin looks like this: class DownloadInline(TabularInline): model = Download class ArtistAdmin(ModelAdmin): inlines = [DownloadInline,] I get a validation error fo...

Server software choice for Django live/staging

For developing our Django web app, I'd like to move to an autonomous system that automatically updates the source (from VCS) of a staging copy of the app which has near identical properties to the live version of the application. The general idea of doing this has already been covered here on SO #625256. The Django documentation also t...

Django Admin: How to dynamically insert values into the add inline form

Let's say I have this model: class Foo(models.Model): bar = models.ForeignKey(Bar) currency = models.ForeignKey(Currency) # currency is just an example is_active = models.BooleanField() Now suppose Foo is an Inline of Bar. And I would always want to indicate a value on each currency? If I could replace those currency drop ...

Django Forms not rendering ModelChoiceField's query set

I have the following ModelForm: class AttendanceForm(forms.ModelForm): def __init__(self, *args, **kwargs): operation_id = kwargs['operation_id'] del kwargs['operation_id'] super(AttendanceForm, self).__init__(*args, **kwargs) self.fields['deployment'].query_set = \ Deployment.objects.filt...

Django Admin: Getting a QuerySet filtered according to GET string, exactly as seen in the change list?

Hi all In the Django admin, the user can set filters which limit the rows displayed in the change list. How can I get a QuerySet instance with filters set as defined by the query string? For instance, if I pass ?start_date_gte=2009-11-06, the Django admin will apply a qs.filter(start_date__gte...) somewhere. How can I access such a Quer...

django recursive relationships

My DjangoApp is using categories to generate a navigation and to put stuff in those categories. There are two types of categories: ParentCategories (top categories) ChildCategories (sub categories that have a ParentCategory as a parent) Because those to categories are so similar I don't want to use two different models. This is my c...

How to profile a Django custom management command exclusively

I would like to profile a custom management command that is relatively CPU intensive (renders an image using PIL). When I use the following command I get all sorts of Django modules (admin, ORM etc) in my profiling results: python -m cProfile manage.py testrender I have removed all imports that can potentially import Django but I am g...

Populate ModelChoiceField by comparing two or more tables

I have a sort of unique situation....I want to populate a ModelChoiceField based of several tables, reason being I want to have the search containing only active records. An example of one of the models is as follows: class ExteriorColour(models.Model): exterior_color = models.CharField(max_length=7, blank=False) def __unicode__(...

sorl.thumbnail : 'thumbnail' is not a valid tag library ?

I am trying to install sorl.thumbnail but am getting the following error message: 'thumbnail' is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module named PIL This error popped up in this question as well http://stackoverflow.com/questions/1356334/need-help-solving-sorl-thumbnail-error...

How to test custom template tags in Django?

I'm adding a set of template tags to a Django application and I'm not sure how to test them. I've used them in my templates and they seem to be working but I was looking for something more formal. The main logic is done in the models/model managers and has been tested. The tags simply retrieve data and store it in a context variable ...

Overhead of a Round-trip to MySql?

So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL. The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large amount of user specific content (ie photos, friends, other ...

handling multiple returned objects

I have a contact/address app that allows users to search the database for contact entries. The current view will return an object (Entry()) and display its fields. The code is as follows: def search_page(request): form = SearchForm() entrylinks = [] show_results = True if request.GET.has_key('query'): show_resu...

Show page items count in django pagination.

Hi, everyone! I'm trying to figure out how to show something like "Showing 1-10 of 52" using django pagination in my templates. I accomplished the pagination itself but nothing comes to my mind about this requirement. Any ideas? ...

Django multiple view parameters and duplicated named urls

I was just pondering if make two named urls the same produces any problems. I tried it and it works. So for example, I have a view that is able to do paging: def info(request, page_num = 1) and I would like to call it both ways, as: /info /info/page/1 so I made urls like: url(r'^info/$', 'views.info', name='info'), url(r'^info/(?P...

implementing a custom UploadHandler in django

We've got some clients sending a custom POST of a data blob to our django servers. They do things in a rather funky way that I'd rather not get into - and we've since moved on from making that particular format the norm. To make further implementations of our upload protocol more streamlined, I was looking to roll a custom UploadHandl...

Extending the admin panel in Django

I have several objects with some functions that I would like to be able to run via the admin panel. So far, I've not found a way to add them as actions to the admin interface. Is there a way to do it? ...