django

Modpython and virtualenv

Is it any way to run django site on virtualenv without administration rights? How can I do it? Virtualenv is already installed. ...

Django: Model inheriting from base model with custom manager. Can the manager have dynamic variables?

I need to have all my models inherit this manager (Haven't tested this manager and it may be ridiculous so I'm completely open to suggestion/criticism on it as well): class AccountFilterManager(models.Manager): def __init__(self, account=None, *args, **kwargs): super(AccountFilterManager, self).__init__(*args, **kwargs) ...

Custom QuerySet and Manager without breaking DRY?

I'm trying to find a way to implement both a custom QuerySet and a custom Manager without breaking DRY. This is what I have so far: class MyInquiryManager(models.Manager): def for_user(self, user): return self.get_query_set().filter( Q(assigned_to_user=user) | Q(assigned_to_group__in=...

Timeout when using urllib2.urlopen with Django in GAE

When I run this code url = ('http://maps.google.com/maps/nav?'+ 'q=from%3A'+from_address+ '+to%3A'+to_address+ '&output=json&oe=utf8&key='+api_key) request = urllib2.Request(url) response = urllib2.urlopen(request) In a simple view in Django running in google app engine via the Google App Engine Helper for Django ...

Django: which is the widget that renders the foreign key in the admin page?

Which is the widget that renders the foreign key in the admin site? I saw that there is a widget called RelatedFieldWidgetWrapper (that print only the "+" icon) and another for the select, but I suppose that there is a widget that call both to render the entire field. Thanks ...

Caching images in Flash and Vary: cookie

Background I am working on a web application built on Django. I use the auth context_processor, which causes a Vary: Cookie header on each response (See http://code.djangoproject.com/ticket/6552) I return images through a Django view to check user permissions, etc. These images should be cached on the browser for an hour. The images...

Django: overriding to_python() on a ForeignKey field and what other methods are called before clean_<fieldname> when validating a form?

I'm trying to solve a problem that I outlined in this question. At the moment it looks like I will have to override the to_python() method on the ForeignKey field. But as far as I can see in django's source code, the ForeignKey class doesn't actually have a to_python() method declared, so it must be inheriting it from the Field class, wh...

Django: Queryset.clear() method on OneToOneField()

I need to avoid cascading deletes on a foreign key, but it's a OneToOneField(), like: class MyModel(models.Model): def delete(self): self.mysubmodel.clear() # Breaks because self.cartitem is not a QuerySet. super(MyModel, self).delete() class MySubModel(models.Model): mymodel = models.OneToOneField(MyModel) T...

Best way to make Django's login_required the default

I'm working on a large Django app, the vast majority of which requires a login to access. This means that all throughout our app we've sprinkled: @login_required def view(...): That's fine, and it works great as long as we remember to add it everywhere! Sadly sometimes we forget, and the failure often isn't terribly evident. If the...

Django FormWizard Dynamically Alter form_list

I'm having some issues with the form wizard, that maybe someone can shed some light on. According docstring in the method process_step: I can "dynamically alter self.form_list". So, based on my project needs, I'm appending forms to the form_list. The forms I'm appending contain questions and answers: http://dpaste.com/hold/152201/ Th...

Do inline model forms emmit post_save signals? (django)

So I have two models (Tables) related by a ForeignKey. In the admin, the edit page displays the first model (let's say ModelOne) along with the related instances of the second model, ModelTwo (TabularInline). What I want is perform some additional actions when the second model is being changed. I can do this with a post_save signal on M...

Objects won't persist in Django sessions under Apache

The setup: Django 1.0 default sessions (db, no caching) apache 2.2, mod_python, prefork, 5 processes What I am trying to do: initialize a new object (custom class, several dicts as member variables, a few methods) save it in the session. use that object from several subsequent requests Problem: The process that created the obje...

django cnotes not working

Hi, I have just installed django-cnotes But it wont work. It just throws up this error Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/core/servers/basehttp.py", line 279, in run self.result = application(self.environ, self.start_response) File "/Library/Python/2.5/site-packages/django/core/servers/ba...

In python django how do you print out an object's inrospection? The list of all public methods of that object (variable and/or functions)?

In python django how do you print out an object's inrospection? The list of all public methods of that object (variable and/or functions)? e.g.: def Factotum(models.Model): id_ref = models.IntegerField() def calculateSeniorityFactor(): return (1000 - id_ref) * 1000 I want to be able to run a command line in the Django shel...

Global state of long-running process in django

I have the need to kick off a long-running process in response to a form submission in django. Then, I'd like to be able to poll using ajax and have the view respond with the state of the process (started, stopped, or running). Additionally, I want to be able to stop the process. so my view looks like this: def start() . . . def s...

Custom address field in Django Model

What's the common practice to represent postal addresses in Django models? Is there a library for custom model fields that include postal address fields and potentially handle validation and formatting? If no library exists, how can I write one? Can I represent a composite field (a field that gets serialized to multiple columns in db)...

Custom product template in satchmo

I'm implementing a store in satchmo. I've created a custom product MyProduct by using model inheritance from the Product Model (as seen in http://thisismedium.com/tech/satchmo-diaries-part-one/). Now I'd like to have a custom product detail template for MyProduct, and only MyProduct. I tried creating a template in /project/templates/...

Django queries - id vs pk

Hi all, When writing django queries one can use both id/pk as query parameters. Object.objects.get(id=1) Object.objects.get(pk=1) I know that pk stands for Primary Key and is just a shortcut, according to django's documentation. However it is not clear when one should be using id or pk. Thanks! ...

xapian and django-haystack

Hi, I have a problem with django-haystack. According to this tutorial I got this apps: django-haystack xapian-haystack I set everything but i have this error: django.core.exceptions.ImproperlyConfigured: 'xapian' isn't an available search backend. Available options are: 'dummy', 'solr', 'whoosh' Why xapian is not available? Thanks f...

Modifying Dictionary in Django Session Does Not Modify Session

I apologize for "asking" a question to which I already know the answer, but this was frustrating enough that I thought the answer should be recorded on stackoverflow. If anyone has something to add to my explanation I will award the "answer". I couldn't find the answer by searching based on the problem, but after searching based upon t...