django

How do you reference related models' fields in the admin list_filter?

My Models: OrderInfo is one-to-one with Print, which is a Many-to-One with Painting, which itself is a Many-to-One with Club. class OrderInfo(models.Model): print_ordered = models.OneToOneField(Print, blank=True) class Print(models.Model): painting = models.ForeignKey(Painting) class Painting(models.Model): club = models....

Django and Sqlite Concurrency issue

I've done a bit of reading related to the concurrency issues with sqlite, but I don't see how they'd apply to Django since it's inherently single threaded. I'm not using any multiprocess modules either. I have absolutely no experience with concurrent programming either, so if someone can identify WHY the following code is causing an Oper...

Tiny MCE popups blank in Django admin

I have got tinyMCE working in the django admin, but all the popups are blank (eg. edit HTML, add image) The paths to the popup html pages all exist in the right places http://thatch.media/js/tiny_mce/themes/advanced/source_editor.htm?mce_rdomain=thatch The permissions are set to 777 on the whole js folder This is my Model class Pag...

How do I create a Django form that displays a checkbox label to the right of the checkbox?

When I define a Django form class similar to this: def class MyForm(forms.Form): check = forms.BooleanField(required=True, label="Check this") It expands to HTML that looks like this: <form action="." id="form" method=POST> <p><label for="check">Check this:</label> <input type="checkbox" name="check" id="check" /></p> <p><input t...

jQuery.getJSON doesn't trigger callback

Hi! I have a html code: <button>asd</button> <script type = "text/javascript"> $('button').click( function() { $.getJSON('/schedule/test/', function(json) { alert('json: ' + json + ' ...'); }); } ); </script> and corresponding view: def test(request): if request.method == 'GET': json = ...

Django templates - Regrouping by a string parameter

I have the following code in one of my Django templates that I want to refactor: {% ifequal sort_type "set" %} {% regroup cards by set as grouped %} {% endifequal %} {% ifequal sort_type "rarity" %} {% regroup cards by rarity as grouped %} {% endifequal %} It does work, but it's really ugly and I want to make it more like this: ...

Django - Set Up A Scheduled Job?

I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically. Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this. Does anyone know how to set this up? To cl...

How can I pass a standard, static variable from all views in Django?

I'm working on a blog application, and I want to have a sidebar that includes a list of all the months the blog has been in existence, to provide links to archives pages. Moreover, I'd like to make this automatically update when the month changes, rather than hardcoding it in the template. Of course, as far as I can tell, this means that...

Django Project structure, recommended structure to share an extended auth "User" model across apps?

I'm wondering what the common project/application structure is when the user model extended/sub-classed and this Resulting User model is shared and used across multiple apps. I'd like to reference the same user model in multiple apps. I haven't built the login interface yet, so I'm not sure how it should fit together. The following c...

Django - how do I _not_ dispatch a signal?

I wrote some smart generic counters and managers for my models (to avoid select count queries etc.). Therefore I got some heavy logic going on for post_save. I would like to prevent handling the signal when there's no need to. I guess the perfect interface would be: instance.save(dispatch_signal=False) How can I accomplish this? ...

Using only the DB part of Django

Does somebody know how "modular" is Django? Can I use just the ORM part, to get classes that map to DB tables and know how to read/write from these tables? If not, what would you recommend as "the Python equivalent of Hibernate"? ...

Model next available primary key

How can i know the next free primary key of some model? ...

Can the Django admin GUI filter on whether a text field is blank?

I have a Django model containing a text field. In the admin GUI, I'd like to be able to filter just those records containing text in this field. Is it possible? Code something like this will filter on the contents of textfield, but shows filters on 'All' and each distinct entry in the filter. I'd like to filter 'All' or 'Contains someth...

In Django, can you not use a string join on a ManyToManyField? Is ManyToMany not just a list?

I have two models in my Django project: Match Player Match has a ManyToMany property pointing at players, so that multiple players can compete in a match. I'd like to return an informative object name in the Django admin, something like "Richard Henry vs John Doe", by using a join on the players' full names. However the following fai...

Setting up Django with mod_python, Apache on SuSE with Alias

Hello guys, I'm having major problems getting Django working with my Apache configuration. I did not create the server, so I don't have too much leeway as to how the server works. Essentially there are three virtual hosts: board.site.org, students.site.org and insider.site.org The insider.site.org is the main one I'm concerned with. ...

pushing content to cell phones

I am working on a photo site and one of more active users (the jon skeet of the site ;) asked about pushing content to cell phones. The site is built on django, and I was wondering if anyone knows a good way of allowing users to download and store content (images) on their cell phones? As a side question... is it possible to accept paym...

Django model with 2 foreign keys from the same table

I wanted a Django model with 2 foreign keys from the same table. It's an event table which has 2 columns for employees: the 'actor' and the 'receiver'. But I get this error: Error: One or more models did not validate: tasks.task: Intermediary model TaskEvent has more than one foreign key to Employee, which is ambiguous and is not permi...

Django development server shutdown error

Hey all, Whenever i shut down my development server (./manage.py runserver) with CTRL+c i get following message: [24/Feb/2009 22:05:23] "GET /home/ HTTP/1.1" 200 1571 [24/Feb/2009 22:05:24] "GET /contact HTTP/1.1" 301 0 [24/Feb/2009 22:05:24] "GET /contact/ HTTP/1.1" 200 2377 ^C Error in atexit._run_exitfuncs: Traceback (most recent cal...

How does one enable authentication across a Django site, and transparently preserving any POST or GET data?

Suppose someone is editing a HTML form, and their session times out, how can one have Django re-authenticate that individual without losing the content the user had entered into the form? The snippet Django Snippets: Require login across entire site suggests how to do site-wide authentication, but I expect it will lose the GET component...

Database design of survey query system

Hello, guys I am working on a so-called Behavioral Risk Factor Surveillance System (BRFSS), a web query system dealing with questionnaires coming every year. I had hard time in coming up with a suitable database design for it. Here is the problem: Each questionnaire contains about 80 questions, with demographic info, e.g. age, educati...