django

geodjango - search by city, state or zip code

How can I use geodjango to search by city and state or zip code in my django application? I am very new to geodjango and just trying to wrap my head around what would be involved in this. Also, does anyone know of an app that already implements this functionality? ...

How to paginate Django with other get variables?

I am having problems using pagination in Django. Take the URL below as an example: http://127.0.0.1:8000/users/?sort=first_name On this page I sort a list of users by their first_name. Without a sort GET variable it defaults to sort by id. Now if I click the next link I expect the following URL: http://127.0.0.1:8000/users/?sort...

How to try reusable django apps that don't provide templates inside?

Many of the reusable django apps don't include default templates inside. James Bennett says in his presentation Reusable Apps that providing truly portable default templates is very hard. He adds that most of the bug reports in the first release of his registration app were related to default templates. This is a valid point. But withou...

Django tutorial: What is choice_set?

There is this line in the Django tutorial, Writing your first Django app, part 1: p.choice_set.create(choice='Not much', votes=0) How is choice_set called into existence and what is it? I suppose the choice part is the lowercase version of the model Choice used in the tutorial, but what is choice_set? Can you elaborate? Update...

Broken request (or "broken link" report in Django) ?

I received strange broken link report: Subject: Broken link on googleads.g.doubleclick.net Referrer: (url on **my** site!) Requested URL: /pagead/ads?(...) User agent: (...) IP address: (some foreign country) So I took a look at CommonMiddleware, responsible for sending those reports. It goes like this (Django 1.1 license apply here...

Dynamical model fields in django

Hello. I want that objects of one model(Thing, list of everyday things, variable length) will be fields of model Day(date, thing1, thing2, ...). It's possible? If it's not possible, i will use Day(date, fk->Thing), but how in Django admin interface i may list table, where in column - no of exercise repeats and in row - dates and how edi...

Django - split large model using FormWizard

Hello, I am a python/django newbie trying to accomplish the task below. Any help will be greatly appreciated. I have a model with around 50 or so fields. I need to break them up and provide a wizard like functionality. class ABC(models.Model): field_1 = models.IntegerField('Field 1') field_2 = models.CharField('Field 2') .. ...

Django: Unexpectedly persistent module variables

I noticed a strange behaviour today: It seems that, in the following example, the config.CLIENT variable stays persistent accross requests – even if the view gets passed an entirely different client_key, the query that gets the client is only executed once (per many requests), and then the config.CLIENT variable stays assigned. It does ...

Determining whether a user is associated with an object through another class in a django template

I have a user model, an item model, and a possession model to store data about a user possessing an item. When a user is logged in and viewing an item, I want to display an 'add to my items' button, unless the user already has the item. I was trying this code in the template: {% if not user.possession_set.filter(item=item.id) %} <i...

Django/Python - Try/except problem

Hello, i have code like this: try: var = request.POST['var'] except NameError: var = '' Why always code after "except" is executing? Even if request.POST['var'] exist. ...

[Django] Table with Million of rows

Hi at all. I have a project with 2 applications ( books and reader ). Books application has a table with 4 milions of rows with this fields: book_title = models.CharField(max_length=40) book_description = models.CharField(max_length=400) To avoid to query the database with 4 milions of rows, I am thinking to divide it by subject ( ...

Email templating in django

As we all know (or should), you can use Django's template system to render email bodies: def email(email, subject, template, context): from django.core.mail import send_mail from django.template import loader, Context send_mail(subject, loader.get_template(template).render(Context(context)), '[email protected]', [email,]) T...

django combine models.DecimalField with forms -> error: quantize result has too many digits for current context

Hi, I want to combine a model decimal field with a forms choice field. The field in the model: sum = models.DecimalField(max_digits=2, decimal_places=2) The field in the form: sum = forms.ChoiceField(choices=WORK_HOUR_CHOICES, label='Sum Working Hours', required=True) The choices: WORK_HOUR_CHOICES = ( (0, '0'), (0.5, '0...

creating 2 foreign keys that relate to one another

class Product(models.Model): name = models.CharField(max_length = 127) description = models.TextField() code = models.CharField(max_length = 127) def __unicode__(self): return self.name class ProductLot(models.Model): product = models.ForeignKey(Product) code = models.ForeignKey(Product) l...

How to set up PyAMF Django gateway so it uses AMF3?

How to set up PyAMF Django gateway so it uses AMF3 instead of the default AMF0? ...

How to use a Django include tag for a separate HTML template?

I am trying to use the include Django template tag, and inside it I reference a template which handles the format of the form. When I reference this though inside my template it outputs each of the dynamic parts, each character per new line, it is really strange. For example here is a snippet of the output: <form action="/admin/events...

Threading in a django app

I'm trying to create what I call a scrobbler. The task is to read a Delicious user from a queue, fetch all of their bookmarks and put them in the bookmarks queue. Then something should go through that queue, do some parsing and then store the data in a database. This obviously calls for threading because most of the time is spent waitin...

How to throttle Django error emails.

I use django error reporting via email. It is normally a very helpful feature, except that now we have 5 minutes of database downtime and I got 2000 emails. Is there any middleware that will help me throttle the number of emails django can send out per minute? ...

Uploading files to App Engine using webapp and Django forms

My basic question is this: Is there an equivalent of form = MyForm(request.POST, request.FILES) when handling file uploads using the webapp framework on Google App Engine? I know that I can pull out specific uploaded file data using self.request.get('field_name') or a FieldStorage object using self.request.params['field_name'], but...

django inlineformset_factory - how to judge whether a form out of the formset was empty

A formset created based on the inlineformset_factory always returns True if all forms in the formset are valid. It returns also True when the forms in the formset are not filled out. Not filled out means here, that the user did not inserted at least one value. At least this is what I discovered. Is there a way to get to know that a for...