django

What are the best Django forum app options out there?

What do you guys recommend in the way of a forum app that can be dropped into my Django project? I found this page: http://code.djangoproject.com/wiki/ForumAppsComparison But looking for some recommendations. Thanks. ...

Can you have more than one app handle a 404 in Django?

Apparently, the way Django flatpages works is that it handles the 404 thrown by other apps. I was wondering if I could do another flatpages-type app that gets a crack at the 404 before flatpages does. I tried this without success so far. A template gets rendered but the data doesn't come through. Is it even possible? ...

clients' technology expectations - should I discuss or take them as it is?

// Don't know if it sould be community-wiki, it's for a proffessional advice, although can be subjective depending on various experience. Recently I had opportunities to get some casual freelance gigs, but most of them were marked with the popular technology keywords (f.ex. php/mysql/ezpublish). I understood the specification of the app...

Does order of declaration matter in models.py (Django / Python)?

I have something like this in models.py class ZipCode(models.Model): zip = models.CharField(max_length=20) cities = City.objects.filter(zip=self).distinct() class City(models.Model): name = models.CharField(max_length=50) slug = models.CharField(max_length=50) state = models.ForeignKey(State) zip = models.ManyToManyField(ZipCode) Whe...

Is there anything in the Django / Python world equivalent to SimplePie Plugin for Wordpress?

I know that SimplePie itself is derived from UFP, but the features I'm wondering about are the post-processing features that are available in SimplePie for WordPress plugin: http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress/processing Can I find something similar to this for my Django application? Can this be ...

How to limit choice field options based on another choice field in django admin

I have the following models: class Category(models.Model): name = models.CharField(max_length=40) class Item(models.Model): name = models.CharField(max_length=40) category = models.ForeignKey(Category) class Demo(models.Model): name = models.CharField(max_length=40) category = models.ForeignKey(Category) item =...

How to intersect SphinxQuerySet with QuerySet

Is it possible to intersect 2 querysets: SphinxQuerySet and normal django's QuerySet ? I need to filter SphynxQuerySet by ordinary django's filters. What the best way to do that? I try go this direction: ids = [] for obj in Object.search.query(query).all(): ids += [obj.id] qs = Object.objects.all().filter(id__in=ids).filter(s...

Is it possible to define names of model's fields dynamically?

Now I have this code: class Mymodel(models.Model): xxxx_count = ForeignCountField(filter={'foreign_table__xxxx': True}) yyyy_count = ForeignCountField(filter={'foreign_table__yyyy': True}) zzzz_count = ForeignCountField(filter={'foreign_table__zzzz': True}) qqqq_count = ForeignCountField(filter={'foreign_table__qqqq': Tr...

How to query filter in django without multiple occurrences

I have 2 models: ParentModel: 'just' sits there ChildModel: has a foreign key to ParentModel ParentModel.objects.filter(childmodel__in=ChildModel.objects.all()) gives multiple occurrences of ParentModel. How do I query all ParentModels that have at least one ChildModel that's referring to it? And without multiple occurrences... ...

Django caching - can it be done pre-emptively?

I have a Django view, which receives part of its data from an external website, which I parse using urllib2/BeautifulSoup. This operation is rather expensive so I cache it using the low-level cache API, for ~5 minutes. However, each user which accesses the site after the cached data expires will receive a significant delay of a few seco...

How do I JSON serialize a Python dictionary?

I'm trying to make a Django function for JSON serializing something and returning it in an HttpResponse object. def json_response(something): data = serializers.serialize("json", something) return HttpResponse(data) I'm using it like this: return json_response({ howdy : True }) But I get this error: "bool" object has no at...

Sending user to a page created based on their POST request in Django

I have a form in which the user selects a few items to display on "the following page". This selection is always unique, and we will store each set of selections made using a model, indexed by the id as is par with Django models. When the user selects her choices and POSTs using the submit button, I would like for our application to stor...

Print long integers in python

If I run this where vote.created_on is a python datetime: import calendar created_on_timestamp = calendar.timegm(vote.created_on.timetuple())*1000 created_on_timestamp = str(created_on_timestamp) created_on_timestamp will be printed with encapsulating tick marks ('). If I do int() or something like that, I'll get something like 12408...

WSGIServer errors when trying to run Django app

Firstly, here's my script: #!/usr/bin/python import sys, os sys.path.append('/home/username/python') sys.path.append("/home/username/python/flup") sys.path.append("/home/username/python/django") # more path stuff os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings" from django.core.servers.fastcgi import runfastcgi runfastcgi(me...

Django equivalent of PHP's form value array/associative array

In PHP, I would do this to get name as an array. <input type"text" name="name[]" /> <input type"text" name="name[]" /> Or if I wanted to get name as an associative array: <input type"text" name="name[first]" /> <input type"text" name="name[last]" /> What is the Django equivalent for such things? ...

How to put timedelta in django model?

With inspectdb I was able to get a "interval" field from postgres into django. In Django, it was a TextField. The object that I retrieved was indeed a timedelta object! Now I want to put this timedelta object in a new model. What's the best way to do this? Because putting a timedelta in a TextField results in the str version of the obje...

Django users groups

i needed a same funactional: authentificated users can add groups(if have permissions), add users (users added in groups that he create) and add permissions for groups or users. What are the best way for solve that task? ...

Merge two lists of lists - Python

This is a great primer but doesn't answer what I need: http://stackoverflow.com/questions/464342/combining-two-sorted-lists-in-python I have two Python lists, each is a list of datetime,value pairs: list_a = [['1241000884000', 3], ['1241004212000', 4], ['1241006473000', 11]] And: list_x = [['1241000884000', 16], ['1241000992000', 16...

How do you use FCKEditor's image upload and browser with mod-wsgi?

I am using FCKEditor within a Django app served by Apache/mod-wsgi. I don't want to install php just for FCKEditor andI see FCKEditor offers image uploading and image browsing through Python. I just haven't found good instructions on how to set this all up. So currently Django is running through a wsgi interface using this setup: impor...

Notify client about expired session - web programming

Is it posible to notify user that session has expired? Can browser act as server and receive such notifications? One solution would be to generate JavaScript that does countdown on client side and notifies client in the end, but I am iterested if it is postible to do it the first way? And what are the consequences of first approach? A...