django

How to work with unsaved many-to-many relations in django?

I have a couple of models in django which are connected many-to-many. I want to create instances of these models in memory, present them to the user (via custom method-calls inside the view-templates) and if the user is satisfied, save them to the database. However, if I try to do anything on the model-instances (call rendering methods,...

Django and fieldsets on ModelForm

I know you can specify fieldsets in django for Admin helpers. However, I cannot find anything useful for ModelForms. Just some patches which I cannot use. Am I missing something? Is there a way I could achieve something like fieldsets without manually writing out each field on my template in the appropriate tag. I would ideally like to...

Is there a HAML implementation for use with Python and Django

I happened to stumble across HAML, an interesting and beautiful way to mark up contents and write templates for HTML. Since I use Python and Django for my web developing need, I would like to see if there is a Python implementation of HAML (or some similar concepts -- need not be exactly identical) that can be used to replace the Django...

Add row to inlines dynamically in django admin

I have the following defined: class AnswerChoiceInline(admin.TabularInline): model = AnswerChoice # extra = 0 class QuestionAdmin(admin.ModelAdmin): inlines = [AnswerChoiceInline] admin.site.register(Question, QuestionAdmin) Obviously I get the default extras setting (default is 3). Is there a way built into the admin ...

Is there a way to auto-increment a Django field with respect to a foreign key?

I'm currently coding a site in Django (because you can never learn too many frameworks!), and am wondering if there's a way to auto-increment an object with respect to a related object. So for instance, say I have an Entry model and an EntryVersion model: Entry - title - slug EntryVersion - entry (foreign key) - version_number - conte...

Python + Django page redirect

How do I accomplish a simple redirect (e.g. cflocation in ColdFusion, or header(location:http://) in php)? ...

Django + Pydev/Eclipse + Google App Engine - possible?

Has anyone been able to get Google App Engine/Django working in Pydev/Eclipse? I tried this but had difficulty getting Pydev to recognize all of the externally linked folders (django plugins) that I was referencing. I ended up copying all of those folders into the project en masse, rather than referencing them, resulting in a massively b...

Is there a Python equivalent of Groovy/Grails for Java

I'm thinking of something like Jython/Jango? Does this exist? Or does Jython allow you to do everything-Python in Java including Django (I'm not sure how Jython differs from Python)? ...

How to externally populate a Django model?

What is the best idea to fill up data into a Django model from an external source? E.g. I have a model Run, and runs data in an XML file, which changes weekly. Should I create a view and call that view URL from a curl cronjob (with the advantage that that data can be read anytime, not only when the cronjob runs), or create a python scr...

Is there any reason why you can't compare a template filter to a string in Django template syntax?

I'm trying to do this, and failing. Is there any reason why it wouldn't work in Django template syntax? I'm using the latest version of Django. {% ifequal entry.created_at|timesince "0 minutes" %} ...

Django templates: create a "back" link?

I'm tooling around with Django and I'm wondering if there is a simple way to create a "back" link to the previous page using the template system. I figure that in the worst case I can get this information from the request object in the view function, and pass it along to the template rendering method, but I'm hoping I can avoid all this...

Django linked models - available fields in admin

I'm building a website for a friends's art exhibition. I currently define a model called Participant, every participant should also be able to log in to the system, so when a Participant is created a new User is also created. Now when editing or creating a new Participant, I would like to be able to display certain fields from User suc...

In Django, how can I find out the request.session sessionid and use it as a variable?

I'm aware that you can get session variables using request.session['variable_name'], but there doesn't seem to be a way to grab the sessionid as a variable in a similar way. Is this documented anywhere? I can't find it. Thanks for your help! ...

Best Django features that do work on Google App Engine?

I'm in the process of starting a new project on App Engine and Brandon's advice made me think. Many features of Django don't work on Google App Engine: the admin interface and the modeling framework for example. Considering that App Engine already has a simple framework built-in ("webapp") and I can freely pick from the many Python te...

Django form fails validation on a unique field

I have a simple model that is defined as: class Article(models.Model): slug = models.SlugField(max_length=50, unique=True) title = models.CharField(max_length=100, unique=False) and the form: class ArticleForm(ModelForm): class Meta: model = Article The validation here fails when I try to update an existing row...

How to add custom fields to InlineFormsets?

I'm trying to add custom fields to an InlineFormset using the following code, but the fields won't show up in the Django Admin. Is the InlineFormset too locked down to allow this? My print "ding" test fires as expected, I can print out the form.fields and see them all there, but the actual fields are never rendered in the admin. admin...

How would you populate a field based on another field

From the admin panel I want to populate a slug field based on a certain text field eg. Title: My Awesome Page would automaticaly populate Slug: my_awesome_page ...

Unhandled Exception in Flup

I am facing the dreaded "Unhandled Exception" raised by Flup. The sad part is its raised at the webserver (lighttpd+flup) level and not at the application level(Django). So no 500 email is raised about where the problem is. Our entire team struggled hard to cleanup the codebase, incase of any ambigous imports and someones of that sort,...

Differentiate nginx behaviour depending on URL

I have a Django application and I use nginx to serve static content. Unfortunately, all registered MIME types get displayed in client browser, while I would like to give an ability to download the same content, along with usual behaviour. Say, I have JPEG file under /media/images/image01.jpg and I want that nginx serves this file in usua...

Django - How to preopopluate admin form fields

I know that you can prepopulate admin form fields based on other fields. For example, I have a slug field that is automatically populated based on the title field. However, I would also like to make other automatic prepopulations based on the date. For example, I have an URL field, and I want it to automatically be set to http://www.mys...