django

example using django-proxy ?

Have you used django-proxy? Can you give me an example of when it would be a good idea to use it? Thanks. ...

How to debug Jinja2 template ?

I am using jinja2 template system into django. It is really fast and I like it a lot. Nevertheless, I have some problem to debug templates : If I make some errors into a template (bad tag, bad filtername, bad end of block...), I do not have at all information about this error. For example, In a django view, I write this : from jinja2 i...

Why does Django admin try to encode strings into ASCII rather than Unicode? Or is this error something different than it looks like?

I've got the following error: TemplateSyntaxError at /admin/results_cop/copsegmentresult/ Caught an exception while rendering: ('ascii', 'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96', 98, 99, 'ordinal not in range(128)') The fragment of the s...

How do I retain the whitespace in templates' blocks?

Hi, I'm using SHPAML (HAML for python) for Django, however, I'm facing problems converting SHPAML -> HTML because of whitespace issues when overriding some blocks, heres an example: In skeleton.shpaml: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmln...

Apps won't show in Django admin

I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine. My apps are in settings.py I have admin.autodiscover in my root urls.py file from django.conf.urls.defaults import * from django.conf import settings from django.views.generic.simple import direct_to_templ...

testing django app with legacy database - how to avoid recreating db per test?

I'm building web-application using Django1.1 framework with imposed database schema and data (in fact - db already exists - Postgresql). I wrote models already, now I want to perform some unit-testing. The problem: test runner destroys and reconstructs (using information from models) database after every test method, but that's undesira...

GQL with two tables

Hello i am doing a very small application in google appengine and i use python. My problem is that i have two tables using de db.model ("clients" and "requests"). The table "client" has got the email and name fields and the table "requests" has got the email and issue fields. I want to do a query that returns for each request the email, ...

Django: Setting context by url's GET

How can you make a specific action based on the url by base.html? I have two if -clauses as context statements in base.html. If there is algebra in the GET, then the given context should be shown. My url.conf from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^algebra/$', 'algebra'), (r'^mathematics/$', 'ma...

Why are django projects python packages?

Why aren't they simply directories? Any good advice says to keep as much as possible in the apps and not to couple them to the project. The very ability to import an app as project.application discourages this. Why does django-admin.py create the __init__.py at all? The project is perfectly useful without it. What is the justification? ...

Django File Access Security

Hello everyone, I want to restrict access to all but a few selected files per a user, but if I type: /media/userdocuments/FILENAME django happily spits back the file for even users who aren't logged in. How can I integrate the permission framework to work around this? Thanks! EDIT: I realize that the django development server is insec...

Implementating a logical parser in django-query

This is going to be a "long one". I'm including as much code and explanation as possible ... I'm not above throwing out code if necessary. I'm trying to implement a logical parser in a django query system. Where users can provide complex queries against tags that are applied to samples. This is essentially part of a scientific sample...

django lookups that span relationships - how to

Hi, I have an Address Model which has a ForeignKey to a Contact Model: class Address(models.Model): street = models.CharField(max_length=25) postal_code = models.CharField(max_length=25) city = models.CharField(max_length=50) country = models.CharField(max_length=50) contact = models.ForeignKey(Contact, related_name...

django form dropdown with all users in it

Hi, I want to create a form which has a dropdown with all users in it. I tried it like this, with no luck. class ContactFilterByClassificationForm(forms.Form): kam = forms.ChoiceField(choices=User.objects.all()) ...

Why is Django's Meta an old-style class?

I noticed that in Django models, there is a class Meta which makes some additional definitions about the model. My question is, why is this done as an old-style class? (i.e. not subclassing object?) Is there a reason for this or is this just a custom? Could I do it as a new-style class in my projects? ...

Django: Check if foreign key attribute is set

I have the following model: class A(models.Model): name = models.CharField(max_length=50) content_type = models.ForeignKey(ContentType) This model is supposed to be the root model in some inheritance tree and content_type attribute is a kind of a hint about what type is really stored. Obviously, I should calculate content_type...

Django - selecting distinct values from a ForeignKey

There's probably an obvious way to do this that I'm missing, so sorry for the noobish question. I've got models like this: class Speaker(models.Model): name = models.CharField(max_length=50) class Talk(models.Model): title = models.CharField(max_length=50) speaker = models.ForeignKey(Speaker) How can I elegantly get a li...

Searching in several tables with django-haystack

hi, I've got the Restaurant and Comment models shown below. The Comment model has a ForeignKey to Restaurant. How can I perform a search in some of the Restaurant fields and in the comment field of the Comment model which returns a list of Restaurant instances? Thanks class Restaurant(models.Model): name = models.CharField(max_le...

Need advice on how to setup this rather odd site (in Django)

I could really do with some advice here. I'm new to Django, but understand the fundamentals. Though I need some advice on how to setup this site (that's not too conventional really). I have a client who has a site that is mainly static HTML pages (alot of them) which he prefers as he does the content in Dreamweaver. Trust me, I've tried...

Django forms: reload view after post

Hi all, I have the following view code: def activate( request = '', actkey = "" ): message = "" if len( actkey ) != 40: message += str( len(actkey)) if request.method == 'POST': form = ActivateForm( request.POST ) if form.is_valid(): actkey = request.POST['actkey'] ...

django, access fields in intermediate model

I'm creating a Person Group and Membership as described in django docs for intermediate model. class Person(models.Model): name = models.CharField(max_length=128) def __unicode__(self): return self.name class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Memb...