django

How do you print out the exact text "{{text}}" in a Django template?

How do you print out "{{text}}" in a Django template? If I type it into a Django html template it gets interpreted as the variable text. I want the actual text: {{text}} To appear in the html output. ...

Django-tagging: Grabbing objects by specifying multiple tags?

I currently have an entry in urls.py which fetches lone permalinks for my bugs: from django.conf.urls.defaults import * from tagging.views import tagged_object_list from bugs.models import Bug # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Ex...

Organizing django-tagging tags or assigning properties to tags?

I'd like to categorize my tags. Here's an example of the tags I have now: css, internet-explorer, firefox, floats Each of those are separate tags ( 4 in total obviously ). I would like to mark the internet-explorer and firefox tags as browsers. Does django-tagging offer some sort of way for doing this or do I have to manually edit the ...

Broken Link On Django Admin Interface

I'm currently reading Practical Django Projects and in the Django admin interface there is an option to "View on site" when entering information. But after finishing chapter 5 of the book I started to tinker with the admin interface and found that clicking this link with my categories app doesn't work as it isn't appending weblog to the...

Preserving an html/non-html version of a WMD textarea in Django?

I setup the default wmd.js to my admin textareas for my Bug models. Now it gets saved as HTML and when I go to edit the entry in the admin, I see the literal html: <p>foo</p> What strategy could I use so it only renders this <p>foo</p> in the views/html instead of the edit view? ...

Ruby HAML with Django?

Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML. I also love Python and Django. So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning HAML-like syntax in Python (SHPAML and other...

Custom properties in a query

Given the simplified example below, how would I access my custom "current_status" property within a queryset? Is it even possible? At the moment, I want to list the all the current Events and show the current status. I can get the property to display in a template ok, but I can't order the queryset by it. Alternatively, would I need to ...

IntegrityError: (1062, "Duplicate entry '1830327-1792993' for key 'some_instance_A_id'") but no UNIQUE constraint

I'm rarely getting such exception when adding model instance to many2many field, i.e.: some_instance_A.my_m2m.add(some_instance_B)). It works say 99/100 times. What looks strange to me, is that dash sign - as primary keys are integers.. Model field is defined like this: my_m2m = ManyToManyField(B) so it's the simplest M2M defi...

customizing basic existing Django apps that already have "nice looking" CSS/HTML templates?

I am looking for a basic Django application that "looks good" and has basic menus etc. that I could adapt for my own use. I am not doing any fancy processing of user input, but I do want to reuse an existing templates so that I don't have to worry about writing my own CSS/HTML to get clean, valid good looking webpages. Many of the Djan...

Is it possible to use Google Apps Standard user accounts with OpenID?

I am using Google Apps Standard for all of my email and calendaring. I am trying to implement a Single Sign On solution with a Django app that I am building, but I am running into an issue with using my Apps account to login. I have all of the authentication code in place to authenticate with OpenID's in Django. When I hit the /admin pa...

Django: return one filtered object per foreign key

Is it possible to return querysets that return only one object per foreign key? For instance, I want the to get the latest comments from django_comments, but I only want one comment (the latest comment) per object, i.e., only return the latest comment on an object and exclude all the past comments on that object. I guess this would be ...

Some questions about Django localisation

I intend to localise my Django application and began reading up on localisation on the Django site. This put a few questions in my mind: It seems that when you run the 'django-admin.py makemessages' command, it scans the files for embedded strings and generates a message file that contains the translations. These translations are mappe...

django dynamic forms with widgets

I am using the tutorial at http://proteus-tech.com/blog/cwt/django-dynamic-form/ for creating dynamic forms. It works perfect for creating the forms, but I would like to use some of the inputs with a Textarea widget. This is the code that is working from the tutorial, without any widgets defined: from django import forms form_config = ...

Does it make sense categorizing entries that are tagged?

The reason for this is that I want somewhat categorized permalinks. Let's say I file a bug and I want the permalink to be /css/ie-bug/ while being tagged as floats, double-margin, margin. Would it go against the whole purpose of having tags by not tagging this as css but instead categorizing the entry? I would also not tag this as inter...

Get view function from request uri?

Given a uri like /home/ I want to find the view function that this corresponds to, preferably in a form like app.views.home or just <app_label>.<view_func>. Is there a function that will give me this? Excellent! This is what I built out of it: def response(request, template=None, vars={}): if template is None: view_func =...

Removing fields from json

I have a view function which renders json. I am able to specify which columns I want in my json but I don't know how to change the name of the key fields. Like the field "pk" should be "id". I am using this autocomplete control (http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/) and it requires the json to h...

Django - Count a subset of related models - Need to annotate count of active Coupons for each Item

I have a Coupon model that has some fields to define if it is active, and a custom manager which returns only live coupons. Coupon has an FK to Item. In a query on Item, I'm trying to annotate the number of active coupons available. However, the Count aggregate seems to be counting all coupons, not just the active ones. # models.py cla...

Where do I place this hit counter incrementer code?

Snippet taken from this question from django.db.models import F ... MyModel.objects.filter(id=...).update(hit_count=F(hit_count)+1) It was suggested to put in the middleware and I read up a bit on middleware but would greatly appreciate if someone could point out what they would do in this situation. Using my Bug model as an example i...

Flexible Django

There is a remarkable book "Flexible Rails" http://www.manning.com/armstrong/. Is there something similar about integration Django and Flex? ...

Django 1.2 admin - are the datetime widgets not working properly?

If you have a date time field within the admin, and you invoke the "Today" link it seems it throws an exception from calendar.js where it references an undefined global method get_format. This doesn't seem to be defined in any of the latest admin js files. Edit: It seems like it was using a different i18n.py file from my standard djan...