Re: Sending mass, yet personalised email newsletters using Django

2008-11-12 Thread Patrick J. Anderson
On Tue, 11 Nov 2008 00:27:06 -0800, [EMAIL PROTECTED] wrote: > Hello Patrick, > > On Nov 11, 1:53 am, "Patrick J. Anderson" <[EMAIL PROTECTED]> > wrote: >> >> Some of the main requirements are: >> >> * Personalised HTML/text messages &g

Sending mass, yet personalised email newsletters using Django

2008-11-10 Thread Patrick J. Anderson
I'm in the process of writing a simple newsletter managers with a web interface and since I've been a Django user for the past 2 years, I thought of using Django for this task. Some of the main requirements are: * Personalised HTML/text messages * Manual delivery twice a week * Message logging

mod_wsgi and 500 error

2008-10-01 Thread Patrick J. Anderson
I'm running mod_wsgi, and I'm wondering if anybody else who uses mod_wsgi has experienced problems with Django directing requests to 500.html template when the server returns 500 status code. Is there any configuration that needs to be set? When running mod_python, this was wroking fine.

limiting choices in admin.ModelAdmin based on request.user

2008-08-24 Thread Patrick J. Anderson
How should I limit choices for ForeignKey fields in admin.ModelAdmin instances based on request.user attributes, since I can't pass a request object to the forms.ModelForm constructor? --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Re: Authenticated user from models.py

2008-05-23 Thread Patrick J. Anderson
On Thu, 22 May 2008 09:32:40 -0700, jonknee wrote: > On May 21, 9:33 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > >> Well, newforms-admin is being written to make the HttpRequest object >> available as an argument to the various ModelAdmin methods, which means >> that when you set up your ow

Re: Authenticated user from models.py

2008-05-21 Thread Patrick J. Anderson
On Wed, 21 May 2008 20:33:35 -0500, James Bennett wrote: > On Wed, May 21, 2008 at 8:23 PM, Patrick J. Anderson > <[EMAIL PROTECTED]> wrote: >> Passing a Request object should work in application views, but what if >> one wants to capture that information on every save

Re: Authenticated user from models.py

2008-05-21 Thread Patrick J. Anderson
On Wed, 21 May 2008 19:46:20 -0500, James Bennett wrote: > On Wed, May 21, 2008 at 7:35 PM, Juanjo Conti <[EMAIL PROTECTED]> wrote: >> Ugly. Is this the only way? > > Sigh. > > No, "ugly" is magical global variables and things that appear out of > thin air. > > Code that's clean and understand

Re: TypeError on forms.ChoiceField

2008-01-30 Thread Patrick J. Anderson
On Wed, 30 Jan 2008 10:30:04 +0200, Eren T�rkay wrote: > On 30 Jan 2008 Wed 05:49:28 Patrick J. Anderson wrote: >> How can I inject a subset of related photoalbums into this form? > > I don't know much about iteration of models, but in traditional ways, > you can crea

TypeError on forms.ChoiceField

2008-01-29 Thread Patrick J. Anderson
I'm using newforms and ModelForm and I'm getting a TypeError on the following code: class PhotographForm(forms.ModelForm): album = forms.ChoiceField(choices = PhotoAlbum.objects.all()) class Meta: model = Photograph The error message states: "'PhotoAlbum' object is not

newforms SelectDateWidget preventing errors

2007-09-11 Thread Patrick J. Anderson
Hi, I know that this might not belong in the framework, but since this widget is part of the newforms, I thought I could ask this. I was wondering if this widget could be modified so that when rendering an unbound form, the initial values for month, day and year could be set, as to force the user

How could/should I save subsequent objects when I save an object?

2007-02-23 Thread Patrick J. Anderson
I'm trying to come up with the best working solution to allow my application to save subsequent objects when I save an object. Here's my model: class Milestone(models.Model): """Catalogue of project milestones""" ... deadline = models.DateField() ... def save(self):

Re: plotting queryset objects into a calendar

2007-02-12 Thread Patrick J. Anderson
On Mon, 12 Feb 2007 17:54:55 +, Patrick J. Anderson wrote: > On Mon, 12 Feb 2007 13:06:19 +0000, Patrick J. Anderson wrote: > >> I want to plot my milestones into a 28-week calendar using Django. What >> would be the best approach to doing that? >> >

Re: plotting queryset objects into a calendar

2007-02-12 Thread Patrick J. Anderson
On Mon, 12 Feb 2007 13:06:19 +, Patrick J. Anderson wrote: > I want to plot my milestones into a 28-week calendar using Django. What > would be the best approach to doing that? > > I have the following code: > > > [dashboardcalendar.py (custom template tag)] >

plotting queryset objects into a calendar

2007-02-12 Thread Patrick J. Anderson
I want to plot my milestones into a 28-week calendar using Django. What would be the best approach to doing that? I have the following code: [dashboardcalendar.py (custom template tag)] from datetime import datetime, timedelta from django.template import Library,Node register = Library() de

Re: date template filter + ifequal weirdness?

2007-02-12 Thread Patrick J. Anderson
On Mon, 12 Feb 2007 05:50:32 +, Patrick J. Anderson wrote: > On Mon, 12 Feb 2007 15:32:07 +1100, Malcolm Tredinnick wrote: > >> On Mon, 2007-02-12 at 03:49 +0000, Patrick J. Anderson wrote: >>> I think I might be missing something, but I have a problem with >>>

Re: date template filter + ifequal weirdness?

2007-02-11 Thread Patrick J. Anderson
On Mon, 12 Feb 2007 15:32:07 +1100, Malcolm Tredinnick wrote: > On Mon, 2007-02-12 at 03:49 +0000, Patrick J. Anderson wrote: >> I think I might be missing something, but I have a problem with >> date filter. Why doesn't this template code work? >> >&g

date template filter + ifequal weirdness?

2007-02-11 Thread Patrick J. Anderson
I think I might be missing something, but I have a problem with date filter. Why doesn't this template code work? {% ifequal d|date:"l" "Sunday" %} {% else %} {% endifequal %} {{ d|date:"l" }} But inside the HTML list item {{ d|date:"l" }} produces full weekday names. Can and

compare date string in template

2007-02-11 Thread Patrick J. Anderson
Hi, I'm building a calendar for my site and in my template I need to evaluate whether the day is the first of the month. But I cannot do this, or it doesn't work as I expected: {% if equal "1" day|date:"j" %}do something{% endifequal %} or {% if equal "01" day|date:"d" %}do something{% endifequa

Context-sensitive 'upload_to' parameter for FileField

2007-01-19 Thread Patrick J. Anderson
Hi, I was wondering if it is possible, and if so then how, to have a context-sensitive 'upload_to' parameter set for FileField. Let's say, I have the following model concept: class MyModel(models.Model): folder = models.CharField(maxlength = 8) file_html = models.FileField(uploa

Re: Internationalization problem in template system

2007-01-18 Thread Patrick J. Anderson
On Thu, 11 Jan 2007 16:58:34 -0600, Jacob Kaplan-Moss wrote: On 1/11/07 2:35 PM, Nuno Mariz wrote: Any idea to resolve this , this don't scale. If I what to add another language, I have to patch all of my templates. If I were you, I'd write a simple accessor on your model to get the current

Re: Portuguese (pt) request.LANGUAGE_CODE problem

2007-01-17 Thread Patrick J. Anderson
On Wed, 17 Jan 2007 17:27:05 +, Nuno Mariz wrote: Hi, I'm portuguese and I'm going to translate django to pt-pt in this month. Stay tune. Nuno Mariz That'd be great! Looking forward to it being included in the framework! --~--~-~--~~~---~--~~ You recei

Re: Portuguese (pt) request.LANGUAGE_CODE problem

2007-01-16 Thread Patrick J. Anderson
James Bennett wrote: On 1/16/07, Patrick J. Anderson <[EMAIL PROTECTED]> wrote: I'd appreciate some help with figuring out how to go about adding that locale to my site in simplest and sensible way. The simplest way is to produce a translation for the 'pt' lo

Portuguese (pt) request.LANGUAGE_CODE problem

2007-01-16 Thread Patrick J. Anderson
Hi, everybody! I wanted to post about a little problem I have while developing multilingual site I'm working on. I plan to include content in various languages, focusing on 3 at the moment: English, Spanish and Portuguese. I have followed the docs on i18n and this are working great, except

Re: a candidate for a custom decorator?

2007-01-11 Thread Patrick J. Anderson
Brian Beck wrote: > I think your problem is the return values. args is a tuple and request > should be there instead. In both of your decorators, return fn(request, > *args, **kwargs) instead of fn(args, kwargs). > > > > > Yes, Brian, that was the problem. Thanks for your help. --~--~--

a candidate for a custom decorator?

2007-01-11 Thread Patrick J. Anderson
Hello, I wanted to ask for some advice on a little issue I have with implementing decorators in my views. I have this piece of code, which I include in each view, to redirect anonymous and staff users to a notice page (I don't want them to access site members stuff): def my_view(request):

Re: filters on form objects

2006-10-26 Thread Patrick J. Anderson
RajeshD wrote: > >> Or do I have to pass this list of >> albums to the template: >> >> my_albums = Album.objects.filter(owner = request.user) > > This will work. > >> and then construct a select box based on that list. If so, I'd probably >> "break out" of {{ form.albums }} and loose {{ form.er

filters on form objects

2006-10-26 Thread Patrick J. Anderson
Thanks for excellent advice and suggestions posted on this list. I'm still learning Django and Python, though I decided to give it a try in one of my larger projects. I'm trying to add a few forms to my templates and I have a question about filtering some form elements, particularly in related

Re: date navigation inclusion tag (problems with context)

2006-10-25 Thread Patrick J. Anderson
Patrick J. Anderson wrote: > Here's one of the inclusion tags I wrote this morning for my blog date > navigation: > > --- > > from django.template import Library,Node > from project.apps.

date navigation inclusion tag (problems with context)

2006-10-25 Thread Patrick J. Anderson
Here's one of the inclusion tags I wrote this morning for my blog date navigation: --- from django.template import Library,Node from project.apps.news.models import Article register = Library() def articles_months(context):

Accessing session variables in templates

2006-10-12 Thread Patrick J. Anderson
Hi! I have a member_id session variable, which I set at login (it is different than "user"). I need to check that variable in my templates to display member-specific navigation. How can I check do this? Or do I need to do the checking in each view function and pass the value in a template va

Re: NullBoolean/Boolean Field weirdness

2006-10-11 Thread Patrick J. Anderson
Malcolm Tredinnick wrote: > On Wed, 2006-10-11 at 22:45 -0500, Patrick J. Anderson wrote: > [...] >> Thanks for your comments, Malcolm. I realize that a determined person >> could submit an altered form and edit other profiles. >> >> I guess this is not a Djan

Re: NullBoolean/Boolean Field weirdness

2006-10-11 Thread Patrick J. Anderson
Malcolm Tredinnick wrote: > On Wed, 2006-10-11 at 22:45 -0500, Patrick J. Anderson wrote: > [...] >> Thanks for your comments, Malcolm. I realize that a determined person >> could submit an altered form and edit other profiles. >> >> I guess this is not a Djan

Re: NullBoolean/Boolean Field weirdness

2006-10-11 Thread Patrick J. Anderson
Malcolm Tredinnick wrote: > On Wed, 2006-10-11 at 21:33 -0500, Patrick J. Anderson wrote: > [...] >> I guess the concept of approving members needs to be refined. My project >> has some "special" requirements and this is one of them. > > There's no prob

Re: NullBoolean/Boolean Field weirdness

2006-10-11 Thread Patrick J. Anderson
Malcolm Tredinnick wrote: > On Wed, 2006-10-11 at 21:33 -0500, Patrick J. Anderson wrote: > [...] >> I guess the concept of approving members needs to be refined. My project >> has some "special" requirements and this is one of them. > > There's no prob

Re: NullBoolean/Boolean Field weirdness

2006-10-11 Thread Patrick J. Anderson
Malcolm Tredinnick wrote: > On Wed, 2006-10-11 at 15:07 -0500, Patrick J. Anderson wrote: >> I have extended Django User model (site members as opposed to users) and >> I want to approve them before they can use all site features. Below is >> my model: >> &

NullBoolean/Boolean Field weirdness

2006-10-11 Thread Patrick J. Anderson
I have extended Django User model (site members as opposed to users) and I want to approve them before they can use all site features. Below is my model: class Member(models.Model): user = models.ForeignKey(User) ... is_approved - models.NullBooleanField(default = False)

Re: global template tags

2006-10-04 Thread Patrick J. Anderson
RajeshD wrote: > Firstly, the statement "user = User.objects.get(id=request.user.id)" is > redundant -- you could directly use request.user instead of that query > with the same effect. > > As far as the actual problem is concerned, your Queryset is returning > multiple rows because request.user.

Re: global template tags

2006-10-04 Thread Patrick J. Anderson
RajeshD wrote: > You could use: > > 1. a regular tag or > 2. an inclusion tag with takes_context=True > (See: > http://www.djangoproject.com/documentation/templates_python/#inclusion-tags) > > In both cases, your render or tag function will get called with a > context object from which you can

Re: global template tags

2006-10-04 Thread Patrick J. Anderson
Waylan Limberg wrote: > On 10/4/06, Patrick J. Anderson <[EMAIL PROTECTED]> wrote: >> Hi, everyone! >> >> I have a question I've been trying to find answers to in the docs, but >> perhaps I'm not looking in the right places, because I can'

global template tags

2006-10-04 Thread Patrick J. Anderson
Hi, everyone! I have a question I've been trying to find answers to in the docs, but perhaps I'm not looking in the right places, because I can't find it. I'm wondering about the use of templatetags in project instead of application scope. I put my applications in 'apps' subdirectory and unde

Re: User object available in base template

2006-10-04 Thread Patrick J. Anderson
Don Arbow wrote: > On Oct 3, 2006, at 9:30 PM, Patrick J. Anderson wrote: >> def main(request): >> posts = Post.objects.filter(is_approved = >> True).order_by('-time_added')[:5] >> t = loader.get_template('homepage.html') >> c

Re: User object available in base template

2006-10-03 Thread Patrick J. Anderson
Forgot to add my specific error: Exception Type: AttributeError Exception Value:'dict' object has no attribute 'user' Exception Location: /usr/lib/python2.4/site-packages/django/core/context_processors.py in auth, line 17 Patrick J. Anderson Patrick J.

User object available in base template

2006-10-03 Thread Patrick J. Anderson
In my project, I have a root template called base.html, which all other templates extend. I'd like to create a simple navigation with user information, which I want to write once and put in the base template to be shown on every page. I'm not sure what the best way of retrieving information fr

slug field and generic create view

2006-10-03 Thread Patrick J. Anderson
Is there a simple way to add the slug field to a custom form template? I'm using django.views.generic.create_update.create_object and my model has a slug field. Whenever I try to add a new item to database, I receive error saying that my "title" is similar to the on existing in the database, s

__str__ question

2006-09-14 Thread Patrick J. Anderson
I'm not totally clear, perhaps it's a Python and not Django-specific question, but in my e-commerce app model, I have Currency and ExchangeRate classes: class Currency(models.Model): name = models.CharField(maxlength = 50) code = models.CharField(maxlength = 3) class Meta:

Re: LANGUAGES in template

2006-09-07 Thread Patrick J. Anderson
gjiro wrote: > Hi Patrick, > > Check if your settings.py conforms to: > http://www.djangoproject.com/documentation/settings/#languages > > The context processor that exposes LANGUAGES to the template's > "context": > http://code.djangoproject.com/browser/django/trunk/django/core/context_processo

LANGUAGES in template

2006-09-07 Thread Patrick J. Anderson
I'm following the docs on i18n. In there, there's a sample of template code for a language selection form: {% for lang in LANGUAGES %} {{ lang.1 }} {% endfor %} But LANGUAGES is empty for me in the template. How can I use LANGUAGES variable in the templ

how to return unique days in month_archive generic view

2006-08-03 Thread Patrick J. Anderson
Hi! I'm building a day-based navigation for my blog posts. I'm using generic view (month_archive) object_list to get all post for a specific month. How can I get unique days in my template loop on object_list if I have multiple posts per day? Is there a way to do it "generically", or do I nee

Re: logged-in user id as default value on ForeignKey relation

2006-07-17 Thread Patrick J. Anderson
Malcolm Tredinnick wrote: > On Mon, 2006-07-17 at 09:41 -0700, Patrick J. Anderson wrote: >> Sorry, but would you be able to explain this in detail? I was thinking >> about acomplishing this in model classes, not in views, so I'm not sure >> if I understand what you m

Re: logged-in user id as default value on ForeignKey relation

2006-07-17 Thread Patrick J. Anderson
Sorry, but would you be able to explain this in detail? I was thinking about acomplishing this in model classes, not in views, so I'm not sure if I understand what you mean. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

logged-in user id as default value on ForeignKey relation

2006-07-17 Thread Patrick J. Anderson
In my model I'd like to keep track of who added/updated a particular record. class Entry(models.Model): ... time_added = models.DateTimeField(auto_now_add = True, editable = False) user_added = models.ForeignKey(User, default = ?, editable = False) time_updated = models.DateT

Re: ManyToMany and filter_interface

2006-07-12 Thread Patrick J. Anderson
[EMAIL PROTECTED] wrote: > I can't seem to get filter_interface on M2M relationships to work. > There are no errors but the admin interface looks identical with and > without the extra directive in there. Here's the relevant field: > > attributes = models.ManyToManyField(Attribute, > filter_

Populating multiple text fields from a set of values. Possible?

2006-06-29 Thread Patrick J. Anderson
I am wondering if it is possible to populate a list of text input fields in admin forms from a default store (database or text). Perhaps a problem I'm trying to solve will illustrate it better. Code: class Project(models.Model): """ Production Projects """ name

Re: SuspiciousOperation: User tampered with session cookie

2006-06-28 Thread Patrick J. Anderson
On Tue, 27 Jun 2006 23:30:56 -0500, Patrick .J. Anderson wrote: > Malcolm Tredinnick wrote: >> [quoted text muted] > > Hi, Malcolm > > Yes, I noticed that too. Perhaps it would be good if I tested this > behaviour on another distro, but I don't want to resetup m

Re: SuspiciousOperation: User tampered with session cookie

2006-06-27 Thread Patrick .J. Anderson
Malcolm Tredinnick wrote: > On Tue, 2006-06-27 at 23:09 -0500, Patrick .J. Anderson wrote: >> Jacob Kaplan-Moss wrote: >>> Hi Patrick -- >>> >>> What happens when you clear out your sessions table? >>> >>> FYI, there's nothing about Ub

Re: SuspiciousOperation: User tampered with session cookie

2006-06-27 Thread Patrick .J. Anderson
Jacob Kaplan-Moss wrote: > Hi Patrick -- > > What happens when you clear out your sessions table? > > FYI, there's nothing about Ubuntu versus mod_python that would/could > cause this (I use both). > > Jacob > > > > I cleared the session table and tried to login using my apache/mod_python

Re: SuspiciousOperation: User tampered with session cookie

2006-06-27 Thread Patrick .J. Anderson
Nikolaus Schlemm wrote: >> I've heard that the problem might be related to md5 hashing (someone >> just recently posted it here in the groups with the same error >> message). I looked at the django code and that where that error message >> is thrown and it seemed to confirm that, but I don't know

Re: SuspiciousOperation: User tampered with session cookie

2006-06-27 Thread Patrick .J. Anderson
Patrick .J. Anderson wrote: > [EMAIL PROTECTED] wrote: >> Clear the cookies in your browser and the problem will go away. >> >> > clearing the cookies doesn't help (I guess you answered that one). > > hmm, i don't know exactly what to do here, as I haven

Re: SuspiciousOperation: User tampered with session cookie

2006-06-27 Thread Patrick .J. Anderson
[EMAIL PROTECTED] wrote: > Clear the cookies in your browser and the problem will go away. > > > > > clearing the cookies doesn't help (I guess you answered that one). hmm, i don't know exactly what to do here, as I haven't tampered with anything. I'll try to recreate the project (extra work,

Re: SuspiciousOperation: User tampered with session cookie

2006-06-27 Thread Patrick J. Anderson
Hmm, I haven't changed domains. I simply took my previous setup on Fedora Core 5 with apache+mod_python and put it on Ubuntu Dapper with apache+mod_python. I've heard that the problem might be related to md5 hashing (someone just recently posted it here in the groups with the same error message).

SuspiciousOperation: User tampered with session cookie

2006-06-26 Thread Patrick .J. Anderson
I installed Ubuntu Dapper today and got django set up. I restred a Django application I was working on previously and when I tried to login to the admin section, I received this error: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_

Re: list_display (ManyToManyField)

2006-06-23 Thread Patrick J. Anderson
Thanks, that works well. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL

list_display (ManyToManyField)

2006-06-23 Thread Patrick J. Anderson
I'd like to display a list of tags (ManyToMany relationship to Articles) in admin list_display. I'm getting a reference to an object. Is there a way to do this in Admin class inside my model? Below is a code chunk from my model: class Article(models.Model): #... tags= mo

Re: Comments: Failed lookup for key [id] in ''

2006-06-22 Thread Patrick J. Anderson
That's right! Thanks for spotting this silly mistake. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this

Re: Best way to resuse admin pagination?

2006-06-22 Thread Patrick J. Anderson
Yes, that's true, but what would be the easiest way to reuse the pagination "widget" (if you can call it that) instead of writing my own? Sorry, if I haven't explained it in more detail --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Comments: Failed lookup for key [id] in ''

2006-06-22 Thread Patrick J. Anderson
Following documentation found on http://code.djangoproject.com/wiki/UsingFreeComment, I run into this problem. Below is my template: {% load comments.comments %} {% for p in latest %} {% get_free_comment_count for blog.post object.id as comment_count %} {{ p.title }}

Best way to resuse admin pagination?

2006-06-22 Thread Patrick J. Anderson
What is the best way to reuse admin pagination in a generic object_list view template? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegr

Re: Problem with date_based generic views

2006-06-21 Thread Patrick J. Anderson
Well, that fixed it. I guess development using mod_python can be a little cumbersome. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegro

Re: Problem with date_based generic views

2006-06-21 Thread Patrick J. Anderson
I'm trying to display my records based on date. I've removed object.list... same result, page returns the same error message. It's weird, because it was working fine just a few minutes ago. --~--~-~--~~~---~--~~ You received this message because you are subscribe

Problem with date_based generic views

2006-06-21 Thread Patrick J. Anderson
Hi, I've been working with date_based generic views in my application, and while everything was going great, all of a sudden I'm getting this error on, while trying to access records for a specific month: ViewDoesNotExist at /projects/2006/jun/ Could not import django.views.generic.date_based.ar

Re: How would Django handle a large number of records

2006-06-21 Thread Patrick J. Anderson
Thanks, guys! That's what I thought, but it helps to have a conformation, Wilson:). Great job on Django! There are a few small admin interface issues I'd still need to work out, mainly I might have a similar number of records related to articles (the number of article assignments might be slighlt

ManyToManyField on 2 external tables

2006-05-22 Thread Patrick J. Anderson
I'm building a workflow manager for our organisation and decided to give Django a try. In about 1 hour, I was able to start creating a very basic model for 'projects' app. - from django.db import mode