django

How to set up Django app to make cookies work on subdomain

Hi, I have deployed my application on subdomain.domain.com (it works only on that one subdomain). Everything works fine except the fact that from time to time users cannot log in to application (the message "Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again" is shown when ...

django join querysets from multiple tables

if i have queries on multiple tables like: d = Relations.objects.filter(follow = request.user).filter(date_follow__lt = last_checked) r = Reply.objects.filter(reply_to = request.user).filter(date_reply__lt = last_checked) article = New.objects.filter(created_by = request.user) vote = Vote.objects.filter(voted = article).filter(date__lt ...

Django admin, filter objects by ManyToMany reference

Hello! There's photologue application, simple photo gallery for django, implementing Photo and Gallery objects. Gallery object has ManyToMany field, which references Photo objects. I need to be able to get list of all Photos for a given Gallery. Is it possible to add Gallery filter to Photo's admin page? If it's possible, how to do it...

Developing a high-performance, scalable Comet application

Well, the title says most of it. I'm looking to develop a chat application that will hopefully become something more, and currently I'm considering my options for what I should build it on top of. I've taken a look at Tornado with Redis as my primary option - Tornado, being a Comet server, is perfect for long polling to retrieve the mes...

How to take advantage of subprocess within Django? - Django

Hi folks, I'm currently using os.popen() but have been recommended to use subprocess.popen() instead. Any ideas on how I can integrate this? It would be cool and fun to have a Python shell accessible on a Django app. But I reckon that it might be a bit complex to implement. I guess I would have to retrieve the subprocess, as a new re...

Run a shell command from Django

Hello, I'm developing a web page in Django (using apache server) that needs to call a shell command to enable/dissable some daemons. I'm try to do it with os.system(service httpd restart 1>$HOME/out 2>$HOME/error) and this command doesn't return anything. Any idea how can i fix this? ...

Get number of results from Django's raw() query function

I'm using a raw query and i'm having trouble finding out how to get the number of results it returns. Is there a way? edit .count() doesnt work. it returns: 'RawQuerySet' object has no attribute 'count' ...

Hacking Django Admin, hooks for login/logout.

How do I add hooks to the Django Admin, such that I can execute a function when the user logs in or out? ...

Django model manager use_for_related_fields and ModelAdmin relationships

I am having trouble getting my model manager to behave correctly when using the Admin interface. Basically, I have two models: class Employee(models.Model): objects = models.EmployeeManager() username = models.CharField(max_length=45, primary_key=True) . . . class Eotm(models.Model): #Employee of the Month date = models...

Django template Path

Hi I m following the tutorial on http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 in windows 7 envoirement. my settings file is TEMPLATE_DIRS = ( 'C:/django-project/myapp/mytemplates/admin' ) i got the base_template from the template admin/base_site.html from within the default Django admin template direc...

MacBook for django development?

Hi, I'm about to buy a new laptop (Asus G62) to replace my old ubuntu desktop. I will use it mostly for django development (and some legacy win32 stuff in a virtualbox). However, since I will need to do some iPhone development in the near future, I'm starting to think that it might be a wiser to buy a MacBook Pro, instead of the Asus a...

How do you update a Django Form Meta class fields dynamically from the form constructor?

I want to update the Meta.fields dynamically. Is it possible to do it from the Form constructor? I tried the following but year doesn't show up during the form generation. Only name and title are displayed. class Author(models.Model): name = ... title = ... year = ... class PartialAuthorForm(ModelForm): class Meta: ...

django, postgresql: moving dumped database data from one machine to another

I am trying to move dumped data from postgresql database to another. However, when syncdb is run on django, it inserts some values into the database. When I then want to insert the dump into the database, I get conflicts. What is the right way of moving some data from one django built database to another? ...

How to obtain and/or save the queryset criteria to the DB?

I would like to save a queryset criteria to the DB for reuse. So, if I have a queryset like: Client.objects.filter(state='AL') # I'm simplifying the problem for readability. In reality I could have # a very complex queryset, with multiple filters, excludes and even Q() objects. I would like to save to the DB not the results of t...

django-mptt: how to successfully move nodes around

django-mptt seems determined to drive me out of my mind. I'm trying to do something relatively simple: I'm going to delete a node, and need to do something reasonable with the node's children. Namely, I'd like to move them up one level so they're children of their current parent's parent. That is, if the tree looks like: Root | Gran...

Django colon syntax in template tags: only in newer versions?

I just deployed an application to a new server, and although I'm using virtualenv, I had to install a new environment on the production server, which has a different architecture. Anyway, I received no TemplateSytaxErrors in development, but on the production server, I get: Exception Type: TemplateSyntaxError Exception Value: Ca...

How can I receive percent encoded slashes with Django on App Engine?

I'm using Django with Google's App Engine. I want to send information to the server with percent encoded slashes. A request like http:/localhost/turtle/waxy%2Fsmooth that would match against a URL like r'^/turtle/(?P<type>([A-Za-z]|%2F)+)$'. The request gets to the server intact, but sometime before it is compared against the regex th...

Model inheritance and RSS Feed framework

I'm using model inheritance to manage a multiple models queryset: from django.db import models from django.contrib.sites.models import Site from django.contrib.auth.models import User from imagekit.models import ImageModel import datetime class Entry(models.Model): date_pub = models.DateTimeField(default=datetime.datetime.now) ...

Union on ValuesQuerySet in django

I've been searching for a way to take the union of querysets in django. From what I read you can use query1 | query2 to take the union... This doesn't seem to work when using values() though. I'd skip using values until after taking the union but I need to use annotate to take the sum of a field and filter on it and since there's no way ...

Best practice- How to team-split a django project while still allowing code reusal

I know this sounds kind of vague, but please let me explain- I'm starting work on a brand new project, it will have two main components: "ACME PRODUCT" (think Gmail, Meebo, etc), and "THE SITE" (help, information, marketing stuff, promotional landing pages, etc lots of marketing-induced cruft). So basically the url /acme/* will load st...