django

django sitemap efficiency

I saw on this page that it's possible to lower the limit on your sitemap so that it is paginated differently: http://stackoverflow.com/questions/2079786/caching-sitemaps-in-django But when I try to generate my sitemap, it hangs and hangs, and never comes up. Eventually, if I wait long enough, I get this error in Firefox: XML Parsing E...

Apache + Mod_wsgi returning 502 Bad Gateway!

Hi folks, I'm serving Django with mod_wsgi and Apache... unfortunately requests are returning 502 Bad Gateway error messages... Received a invalid response HttpResponse('OK') is affected by this render_to_response('...') is not! any ideas?!? ...

Django Sphinx Foreign key search

Hi, I'm trying to create full text search on model, everything goes fine when searching TextFields but I have a problem with ForeignKey field. How can i do that? Can anyone point me to the right direction? Thanks Model example: class Model1(models.Model): text_field =models.TextField(max_length=250) fk_field = models.ForeignKey('...

Webfaction apache + mod_wsgi + django configuration issue

A problem that I stumbled upon recently, and, even though I solved it, I would like to hear your opinion of what correct/simple/adopted solution would be. I'm developing website using Django + python. When I run it on local machine with "python manage.py runserver", local address is http://127.0.0.1:8000/ by default. However, on produc...

How to prevent HTTP 304 in Django test server

I have a couple of projects in Django and alternate between one and another every now and then. All of them have a /media/ path, which is served by django.views.static.serve, and they all have a /media/css/base.css file. The problem is, whenever I run one project, the requests to base.css return an HTTP 304 (not modified), probably beca...

forms problem in django 1.1

I have the following form: class ModuleItemForm2(forms.ModelForm): class Meta: model = Module_item fields = ('title', 'media', 'thumb', 'desc', 'default', 'player_option') The model is: class Module_item(models.Model): title = models.CharField(max_length=100) layout = models.CharField(max_length=5, choice...

Javascript JQUERY AJAX: When Are These Implemented

I'm learning javascript. Poked around this excellent site to gather intel. Keep coming across questions / answers about javascript, JQUERY, JQUERY with AJAX, javascript with JQUERY, AJAX alone. My conclusion: these are all individually powerful and useful. My confusion: how does one determine which/which combination to use ? I've co...

django-mptt fields showing up twice, breaking SQL

I'm using django-mptt to manage a simple CMS, with a model called Page, which looks like this (most presumably irrelevant fields removed): class Page(mptt.Model, BaseModel): title = models.CharField(max_length = 20) slug = AutoSlugField(populate_from = 'title') contents = models.TextField() parent = models.ForeignKey('s...

How do I specify which version of the app I want to use in settings' INSTALLED_APPS

hi, I've got a version of a module (South 0.6) installed system-wise and a newer version installed in my home. When I add 'south' to my INSTALLED_APPS, it uses the system-wise version. How can I tell Django to use the version in my home? Thanks Jul ...

Django: Unicode Filenames with ASCII headers?

I have a list of strangely encoded files: 02 - Charlie, Woody and You/Study #22.mp3 which I suppose isn't so bad but there are a few particular characters which Django OR nginx seem to be snagging on. >>> test = u'02 - Charlie, Woody and You/Study #22.mp3' >>> test u'02 - Charlie, Woody and You\uff0fStudy #22.mp3' I am using nginx as ...

Invalidating Memcached Keys on save() in Django

I've got a view in Django that uses memcached to cache data for the more highly trafficked views that rely on a relatively static set of data. The key word is relatively: I need invalidate the memcached key for that particular URL's data when it's changed in the database. To be as clear as possible, here's the meat an' potatoes of the vi...

Search over multiple fields

Hi there, I think I don't unterstand django-haystack properly: I have a data model containing several fields, and I would to have two of them searched: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, default=None) twitter_account = models.CharField(max_length=50, blank=False) My search index sett...

Django shopping app?

We are developing a django app for several restaurants, it's like a shopping chart. We need the restaurant admins to be able to create their own restaurants, menus and products, and clients must be able to browse the menus and choose the products and confirm their delivery, like a shopping app, which is the best approach? Are there djan...

create_or_update in ModelForm

I want to have a ModelForm that can create_or_update a model instance based on the request parameters. I've been trying to cobble something together, but am realizing that my python fu is not strong enough, and the ModelForm implementation code is a quite hairy. I found this update_or_create snipplet for working with a Model, but I thi...

Extending a form field to add new validations.

I've written an app that uses forms to collect information that is then sent in an email. Many of these forms have a filefield used to attach files to the email. I'd like to validate two things, the size of the file (to ensure the emails are accepted by our mail server. I'd also like to check the file extension, to discourage attachin...

Django: text fixture fails to load

Hi all, Did a dumpdata of my project, then in my new test I added it to fixtures. from django.test import TestCase class TestGoal(TestCase): fixtures = ['test_data.json'] def test_goal(self): """ Tests that 1 + 1 always equals 2. """ self.failUnlessEqual(1 + 1, 2) When running the test I get:...

django custom management command does not show up in production

I wrote a custom management command for django. Locally with my dev settings everything works fine. Now I deployed my project onto the production server and the management command does not show up, respectively is not available. But I did not get an error message deploying the project (syncdb). Any ideas where I could try to begin to s...

How do I get the number of objects per day using django?

I have a django model with a DateTimeField. class Point(models.Model): somedata = models.CharField(max_length=256) time = models.DateTimeField() I want to get a count of the number of these objects for each day. I can do this with the following SQL query, but don't know how to do it through django. SELECT DATE(`time`), Count(...

Use Django dumpdata to dump a subset of overall data?

I'm trying to use dumpdata to generate JSON for a database that is sufficiently large for django to take a long, long time to output. Is there any way to dump only a subset of the fields; say, 100, for testing? I'm using MySQL and Django 1.0. ...

how to get apache mod_cache work with mod_wsgi (django)?

I thought i'd speed up my django projects, by letting apache doing some caching for me. Unfortunately I see that apache never caches my dynamic pages. Has mod_cache problems with mod_wsgi served code ? My apache config: <VirtualHost *:80> ServerName myserver.com CacheEnable mem / # for testing only CacheIgnoreQueryString On Cache...