Re: format date output in mail form
@Guilherme Cavalcanti I haven't thought of using a template for the mail. That will be my next approach for this problem. Thank you for this. For now I have this in my model: Aankomst = form.cleaned_data['Aankomst'] aankomst = str(Aankomst) message = aankomst + '\n' etc... from django.core.mail import send_mail send_mail(subject, message, sender, recipients) return render_to_response('thanks_nl.html', { 'message': message, }, context_instance = RequestContext(request)) Which results in a mail with this date: 2010-07-30 The output in the template thanks_nl.html is 2010-07-30 too. On 21 dec, 14:24, Guilherme Cavalcantiwrote: > Take a look: > > template = get_template("email/notification.html") > ctx = Context({'title': self.title, 'update_account_link': > "#", > 'update_km_link': "#", 'date': datetime.now(), 'user': > self.user_profile.user.username, 'text': self.text, 'aviseme_link': > "#", 'media_url': settings.MEDIA_URL }) > > rendered = template.render(ctx) > > On Dec 21, 10:22 am, Guilherme Cavalcanti > wrote: > > > Hello, > > > can you show how date is being printed? Maybe if you try to create an > > "template" using {{ date|date:"j N \d\e Y" }} (or what else format you > > want) and just call render passing an context with the datetime > > object. > > > On Dec 21, 9:26 am, rvandam wrote: > > > > I found some date formatting in forms/fields.py, forms/widgets.py and > > > in contrib/localflavor/generic/forms.py. I tried if small > > > modifications resulted in a different output, but nothing worked. I > > > also tried to change the local setting in settings.py. Is there a way > > > to modify the date ouptut format? > > > > On 18 dec, 11:21, rvandam wrote: > > > > > I saw a solution on the list to format a datefield in a template. > > > > Unfortunately i didnt find any solution for formatting a datefield in > > > > a mailform. I have this in my model: > > > > > Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput > > > > (format='%d/%m/%Y', attrs={ > > > > 'class':'formVeld', > > > > 'readonly':'readonly', > > > > 'size':'8' > > > > }), required=False) > > > > > This is a part of my view: > > > > > Aankomst = form.cleaned_data['Aankomst'] > > > > aankomst = str(Aankomst) > > > > message = aankomst > > > > > The date output in my mail is: > > > > > 2010-07-30 > > > > > I would like it to have it as: 03/07/2010 Is there a solution for this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: format date output in mail form
Take a look: template = get_template("email/notification.html") ctx = Context({'title': self.title, 'update_account_link': "#", 'update_km_link': "#", 'date': datetime.now(), 'user': self.user_profile.user.username, 'text': self.text, 'aviseme_link': "#", 'media_url': settings.MEDIA_URL }) rendered = template.render(ctx) On Dec 21, 10:22 am, Guilherme Cavalcantiwrote: > Hello, > > can you show how date is being printed? Maybe if you try to create an > "template" using {{ date|date:"j N \d\e Y" }} (or what else format you > want) and just call render passing an context with the datetime > object. > > On Dec 21, 9:26 am, rvandam wrote: > > > > > I found some date formatting in forms/fields.py, forms/widgets.py and > > in contrib/localflavor/generic/forms.py. I tried if small > > modifications resulted in a different output, but nothing worked. I > > also tried to change the local setting in settings.py. Is there a way > > to modify the date ouptut format? > > > On 18 dec, 11:21, rvandam wrote: > > > > I saw a solution on the list to format a datefield in a template. > > > Unfortunately i didnt find any solution for formatting a datefield in > > > a mailform. I have this in my model: > > > > Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput > > > (format='%d/%m/%Y', attrs={ > > > 'class':'formVeld', > > > 'readonly':'readonly', > > > 'size':'8' > > > }), required=False) > > > > This is a part of my view: > > > > Aankomst = form.cleaned_data['Aankomst'] > > > aankomst = str(Aankomst) > > > message = aankomst > > > > The date output in my mail is: > > > > 2010-07-30 > > > > I would like it to have it as: 03/07/2010 Is there a solution for this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: format date output in mail form
Hello, can you show how date is being printed? Maybe if you try to create an "template" using {{ date|date:"j N \d\e Y" }} (or what else format you want) and just call render passing an context with the datetime object. On Dec 21, 9:26 am, rvandamwrote: > I found some date formatting in forms/fields.py, forms/widgets.py and > in contrib/localflavor/generic/forms.py. I tried if small > modifications resulted in a different output, but nothing worked. I > also tried to change the local setting in settings.py. Is there a way > to modify the date ouptut format? > > On 18 dec, 11:21, rvandam wrote: > > > > > I saw a solution on the list to format a datefield in a template. > > Unfortunately i didnt find any solution for formatting a datefield in > > a mailform. I have this in my model: > > > Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput > > (format='%d/%m/%Y', attrs={ > > 'class':'formVeld', > > 'readonly':'readonly', > > 'size':'8' > > }), required=False) > > > This is a part of my view: > > > Aankomst = form.cleaned_data['Aankomst'] > > aankomst = str(Aankomst) > > message = aankomst > > > The date output in my mail is: > > > 2010-07-30 > > > I would like it to have it as: 03/07/2010 Is there a solution for this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: format date output in mail form
I found some date formatting in forms/fields.py, forms/widgets.py and in contrib/localflavor/generic/forms.py. I tried if small modifications resulted in a different output, but nothing worked. I also tried to change the local setting in settings.py. Is there a way to modify the date ouptut format? On 18 dec, 11:21, rvandamwrote: > I saw a solution on the list to format a datefield in a template. > Unfortunately i didnt find any solution for formatting a datefield in > a mailform. I have this in my model: > > Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput > (format='%d/%m/%Y', attrs={ > 'class':'formVeld', > 'readonly':'readonly', > 'size':'8' > }), required=False) > > This is a part of my view: > > Aankomst = form.cleaned_data['Aankomst'] > aankomst = str(Aankomst) > message = aankomst > > The date output in my mail is: > > 2010-07-30 > > I would like it to have it as: 03/07/2010 Is there a solution for this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.