django

Manually logging out a user, after a site update in Django

I have a website,which will be frequently updated. Sometimes changes happen to User specific models and are linked to sessions. So after I update my site, I want the user to logout and log back in. So I would logout the user right then. If he logs back in, he will see the latest updates to the site.How do I do it? ...

Numeric for loop in Django templates

How do I write a numeric for loop in a Django template? I mean something like for i = 1 to n ...

How to use Django with GWT ?

So I know that I can communicate between those two using JSON, but I also know that I would have to manually recreate all Django objects in JS. Do you know of any tool or library that could help me do that? Or maybe even a better way of achieving the same goal? I only found these two: http://palantar.blogspot.com/2006/06/agad-tutorial-...

Returning MatPotLib image as string

I am using matplotlib in a django app and would like to directly return the rendered image. So far I can go plt.savefig(...), then return the location of the image What I want to do is: return HttpResponse(plt.renderfig(...), mimetype="image/png") Any ideas? ...

Separation of ORM and validation

Hi all, I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: o...

swfupload failing in my django runserver

Hi All, I have copied and pasted the code from http://demo.swfupload.org/v220/simpledemo/ into a django template, but when I upload a photo, the demo says "Server (IO) Error" before it actually uploads the entire file. The runserver is getting the request and returning a 200. Is there something I am missing here? What steps should I tak...

What is the most efficent way to store a list in the Django models?

Currently I have a lot of python objects in my code similar to the following: class MyClass(): def __init__(self, name, friends): self.myName = name self.myFriends = [str(x) for x in friends] Now I want to turn this into a Django model, where self.myName is a string field, and self.myFriends is a list of strings. from d...

Why does Django's signal handling use weak references for callbacks by default?

The Django docs say this on the subject: Note also that Django stores signal handlers as weak references by default, so if your handler is a local function, it may be garbage collected. To prevent this, pass weak=False when you call the signal’s connect(). I haven't been able to find any justification for why this is the ...

Django - Queryset spanning null relationships using Q

Consider the models: #Models class A(models.Model): fieldOfA = models.CharField(max_length = 4) class B(models.Model): fieldOfB = models.CharField(max_length = 4) class C(models.Model): classA = models.ForeignKey(A, blank=True, null=True) classB = models.ForeignKey(B, blank=True, null=True) When I create objects of C, ...

How to build an Ecommerce Shopping Cart in Django ?

Hello Is there a book or a tutorial which teaches how to build a shopping cart with django or any other python framework ? ...

How do Python and PHP compare for ecommerce?

If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP? And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. Is Python the future of Web Development ? Edit: I would like to clear out that i am not ask...

Lots of queries from django foreignkey fields

I've been drooling over Django all day while coding up an internal website in record time, but now I'm noticing that something is very inefficient with my ForeignKeys in the model. I have a model which has 6 ForeignKeys, which are basically lookup tables. When I query all objects and display them in a template, it's running about 10 que...

Where to put message queue consumer in Django?

I'm using Carrot for a message queue in a Django project and followed the tutorial, and it works fine. But the example runs in the console, and I'm wondering how I apply this in Django. The publisher class I'm calling from one of my models in models.py, so that's OK. But I have no idea where to put the consumer class. Since it just sit...

Creating a model and related models with Inline formsets

[I have posted this at the Django users | Google Groups also.] Using the example at http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets, I am able to edit objects belonging a particular model (using modelforms). I have been trying to follow the same pattern for creating new objects using inline formsets, but ha...

Django Dump Data For a Single Model?

Can you perform a 'dumpdata' in Django on just a single model (rather than the whole app) and if so, how? E.g. for an app it would be... python manage.py dumpdata myapp However, I want some specific model, (e.g. myapp.mymodel) to be dumped... reason being I have some huge datasets (3 million records plus) in the same app that I would...

django dynamic column query

i've got a dict generated at somewhere like this: d={ 'k1':'v1', 'k2':'v2', ... } and i want to build a query like: SomeModule.objects.filter( Q(k1=v1) | Q(k2=v2) | ... ) what should i do to build the query? ...

How do you Require Login for Media Files in Django

I'm serving "sensitive" information in downloadable PDF's and Spreadsheets within a user registration section of a site. Is there a way to allow the django authentication to secure this media without serving it (and not have to manually login using basic auth)? I'm guessing theres (fingers crossed) not a way to do it with the psuedo co...

How do include a dynamic template from another app in Django?

I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including app2.html: <!-- app1.html --> {% include "app2.html" %} app2 has some dynamic content: <!-- app2.html --> {% app2_value %} When I display app1.html, the value app2_value doesn't show up. What's the best way to handle the abo...

Django Model Inheritance And Foreign Keys

Basically, I have a model where I've created a superclass that many other classes share, and then each of those classes has some unique features that differ from each other. Let's say class A is the superclass, and class B, C, and D are children of that class. Both class B and class C can have multiples of class D, however I've seen tha...

django syndication: how to send a queryset containing all feeds to a template

I'd like to display all available feeds on one page, but I don't want to hard code each feed. Something like sending in a queryset of feeds would be perfect, like: {% for feed in feeds %} {{ feed.link }} {{ feed.name }} {{ feed.description }} {% endfor %} From what I understand, Feeds in the Django Syndication Framework are created as ...