django

Get a queryset of objects through an intermediary model

I want get all of the Geom objects that are related to a certain content_object (see the function I'm trying to build at the bottom, get_geoms_for_obj() class Geom(models.Model): ... class GeomRelation(models.Model): ''' For tagging many objects to a Geom object and vice-versa''' geom = models.ForeignKey(Geom) content_...

django newbie. Having trouble with ModelForm

Hi, i'm trying to write a very simple django app. I cant get it to show my form inside my template. <form ...> {{form.as_p}} </form> it shows absolutely nothing. If I add a submit button, it only shows that. Do I have to declare a form object that inherits from forms.Form ? Cant it be done with ModelForms? [UPDATE]Solved! (apologi...

How to best launch an asynchronous job request in Django view?

One of my view functions is a very long processing job and clearly needs to be handled differently. Instead of making the user wait for long time, it would be best if I were able to lunch the processing job which would email the results, and without waiting for completion notify the user that their request is being processed and let them...

Django Forms clean() method - need IP address of client

I am overriding the clean() method on a Django form. I want to have access to the IP address of the client (assuming this is a bound form). If I had a reference to the request object, I could get it easily from META("REMOTE_ADDR"). However, I do not have a reference to the request. Any ideas on how this could be done? ...

Django Categories with Subcategories, and urls

Hi guys, im trying to make Categories and Subcategories, im checking this models but i have this error: Truncated incorrect DOUBLE value: 'nacionales' where the "nacionales" is the parent Category, i know that my problem maybe are in the urls.py, but the true, i dont know how set the urls for this case... my model.py: # from ... cla...

Django: passing an argument to a method on a template variable

I am using the lxml library to define a variable (category) in a view. lxml provides a method .get to retrieve custom attributes. I'd like to use it in the template like so: {{ category.get("foo") }} I know that when using template variables it is unnecessary to use parenthesis, but I get the following error: {{ category.get "foo" }}...

Cannot import file in Python/Django

I'm not sure what's going on, but on my own laptop, everything works okay. When I upload to my host with Python 2.3.5, my views.py can't find anything in my models.py. I have: from dtms.models import User from dtms.item_list import * where my models, item_list, and views files are in /mysite/dtms/ It ends up telling me it can't find ...

How to Model a Foreign Key in a Reusable Django App?

In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the link model. That's al...

Django LEFT JOIN?

I have models, more or less like this: class ModelA(models.Model): field = models.CharField(..) class ModelB(models.Model): name = models.CharField(.., unique=True) modela = models.ForeignKey(ModelA, blank=True, related_name='modelbs') class Meta: unique_together = ('name','modela') I want to do a query that ...

Atlassian Bamboo with Django & Python - Possible?

At my company, we currently use Atlassian Bamboo for our continuous integration tool. We currently use Java for all of our projects, so it works great. However, we are considering using a Django + Python for one of our new applications. I was wondering if it is possible to use Bamboo for this. First off, let me say that I have a low ...

.filter across tables in Abstract model class - Django

My model is like this class Foo(models.Model): user = models.ForeignKey(User) class Meta: abstract = True class Bar(Foo): bar_thing = models.CharField(..) class Baz(Foo): baz_thing = models.CharField(..) I want to get all bar, baz (And other FooSubclasses) which have user__username = 'hello' i do Foo.object...

Is it possible for a Rails/Django project to become a Death March?

I've worked on Death March projects in the Java world - projects that are destined to fail from the beginning because of some combination of poor management and unwieldy, complex technology, usually spanning multiple systems and often tied to a waterfall approach. Rails and Django are touted as Agile development technologies, which mean...

Django Form Validation Framework on AppEngine: How to strip out HTML etc.?

I'm using the Django Form Validation Framework on AppEngine (http://code.google.com/appengine/articles/djangoforms.html), like this: data = MyForm(data=self.request.POST) if data.is_valid(): entity = data.save(commit=False) entity.put() I wonder if there's a way to preprocess the POST data (strip out malicious code, HTML etc...

Prepend BOM to XML response from Django

I use Django's render_to_response to return an XML document. This particular XML document is intended for a flash-based charting library. The library requires that the XML document start with a BOM (byte order marker). How can I make Django prepent the BOM to the response? It works to insert the BOM into the template, but it's inconv...

Making static file serve location configurable in Django?

I'm developing with Django on my computer, and the location of all my static files are different than on my host. Is there a way to make this a configurable parameter? For example, on my computer, I have to include jquery.js in my templates, which is located in /includes/jquery.js, but on my host, it's located at ../static/jquery.js, bu...

Komodo Edit - code-completion for Django?

I've been using Komodo Edit for a small project in Django. The code completion features seem to work pretty well for standard python modules, however, it doesn't know anything about Django modules. Is there any way to configure Komodo Edit to use Django modules for autocomplete as well? ...

Django 1.1 on Google App Engine

I am trying to get Django 1.1 working on Google App Engine. I followed instructions but, they didn't work. I get this error message: ImportError: Could not import settings 'settings' (Is it on sys.path? Does it have syntax errors?): No module named settings I bet Nick Johnson has the answer! ...

Django xml for flash?

Hi guy, how ill write a xml file for use with flash?, Django Doc dont have nothing about XML (just for Feeds).... Tutorial? Thansk ...

django-facebookconnect login not working in Firefox

I've set up django-facebookconnect on my Django-based site, and it works great — login, posting to the user's News Feed, etc. — except for the fact that login fails in Firefox. When you click the "Connect with Facebook" button, it pops up the window for the user to type in their Facebook login info like normal, but the original page, in...

Django ORM: Getting rows based on max value of a column

Hi, I have a class Marketorders which contains information about single market orders and they are gathered in snapshots of the market (represented by class Snapshot). Each order can appear in more than one snapshot with the latest row of course being the relevant one. class Marketorders(models.Model): id = models.AutoField(primary...