Testing email with the testserver

2010-03-26 Thread Ben Gerdemann
I found the Django documentation about testing E-mail services confusing. It says here http://docs.djangoproject.com/en/1.1/topics/testing/#e-mail-services "Django's test runner automatically redirects all Django-sent e-mail to a dummy outbox", but the example code shows using the 'mail' object

Modify value of a Django form field during clean()

2009-03-17 Thread Ben Gerdemann
I am adding custom validation to my forms and custom fields in my Django app. I would like to be able to modify the value of a field when triggering an error. For example, if there is an error, the form should be redisplayed with the field value corrected by clean() and an error message "Data has

Converting queryset filter() strings to their fields?

2009-02-06 Thread Ben Gerdemann
Hello, I think the best why to explain my question is with an example. I have a model T60CursoAdmin and a query string "a21__a21_ano" that I can use to search with like this: T60CursoAdmin.objects.filter(a21__a21_ano=2008) The models look like this: class T60Curso(models.Model): a21 =

Re: Problem with encoding and using ifequal in Django templates

2009-01-27 Thread Ben Gerdemann
Sometimes there's nothing like describing a problem to someone else to help you solve it. :) I should have marked the Python strings as Unicode like this and everything works now: def test(request): return render_to_response("test.html", { "s1":

Problem with encoding and using ifequal in Django templates

2009-01-27 Thread Ben Gerdemann
Hello, I'm having problems using {% ifequal s1 "some text" %} to compare strings with extended characters in Django templates. When string s1 contains ascii characters >127, I get exceptions in the template rendering. What am I doing wrong? I'm using UTF-8 coding throughout the rest of

Re: Frustration with custom Inline forms

2008-11-17 Thread Ben Gerdemann
Thank you thank you thank you! I knew I was doing something simple wrong. :) I've been enjoying my experience using Django so far, but one thing I have noticed is that the error messages (or in this case lack of error messages) can be frustrating. It sometimes takes me quite a while to figure

Re: Custom form/formset for edit inline

2008-11-17 Thread Ben Gerdemann
I'm having exactly the same problem which I posted about here http://groups.google.com/group/django-users/browse_thread/thread/bb4c792f13b2eceb# Have you figured out how to do this? Yours is the third message I've read by someone trying to customize an inline form without any solution. I'm

Re: Custom Inline Forms with InlineFormsets

2008-11-17 Thread Ben Gerdemann
I'm having a similar problem that I posted about here: http://groups.google.com/group/django-users/browse_thread/thread/bb4c792f13b2eceb# Did you find a solution that works for you? Sorry, I couldn't figure out from your post exactly what you did. I tried using inlineformset_factory() like you

Re: Frustration with custom Inline forms

2008-11-17 Thread Ben Gerdemann
Ok, so I just noticed that the a55_id field which is the primary key, was declared as an IntegerField instead of an AutoField which is why it was showing up on the inline form, but I still can't get any of the other fields excluded from the inline form so the problem is still there. Also, if it

Frustration with custom Inline forms

2008-11-17 Thread Ben Gerdemann
I'm trying to customize the inline forms of a model that are displayed when I'm editing it's parent, but I can't get anything to work! Can someone help? First, here are my models: class T22Pais(models.Model): a22_id = models.AutoField(primary_key=True) a22_nome_1 = models.CharField("Nome

Intercepting return from new ForeignKey popups? (RelatedObjectLookups.js)

2008-11-16 Thread Ben Gerdemann
I've been experimenting with an autocomplete widget for ForeignKey model fields following the very useful advice from Jannis here: http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/ The basic idea is to create a widget with a hidden text field that contains the

Re: Admin interface crashes when adding a new item with a ForeignKey

2008-11-10 Thread Ben Gerdemann
I figured out the problem. I used inspectdb to import my models from an existing database. I then marked the primary_key fields with primary_key=True, but I didn't should have also converted them from IntegerField to AutoField. Once I did that everything worked fine. I hope this message saves

Admin interface crashes when adding a new item with a ForeignKey

2008-11-10 Thread Ben Gerdemann
Good morning all, This problem sure seems like a bug, but it's such a common operation that I must be doing something wrong. I am using the admin interface to add a new student to my database. At the same time I also want to add the parents of the student, so I click on the "+" icon on the