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 Cavalcanti <guiocavalca...@gmail.com> 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 <het.oos...@gmail.com> 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 <het.oos...@gmail.com> 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: Cron vs event triggered action
I deployed on on EC2 using apache + mod_wsgi and it worked. My APS setup is as follow: def start_notificator(): sched = Scheduler() sched.add_interval_job(notificator.send_notification, seconds=10) sched.daemonic = True t = Thread(target=fire_scheduler, args=[sched], name="Notificator") t.setDaemon(True) t.start() notificator.send_notification() is responsible for searching expired "events" entries on database and sending them via e-mail/twitter/sms. fire_scheduler just starts the scheduler (sched, defined up there) and sets up some configs. On Dec 14, 7:23 pm, Javier Guerra <jav...@guerrag.com> wrote: > On Mon, Dec 14, 2009 at 5:12 PM, Guilherme Cavalcanti > > <guiocavalca...@gmail.com> wrote: > > If are you going to choose A, take a look on Advanced Python Schedule > > (http://apscheduler.nextday.fi/). It's a python module that let you > > schedule some script to be executed periodically, it really makes the > > job easier. > > sounds really great; but, from the very first paragraph: > > APScheduler is a light but powerful in-process task scheduler > > the "in-process" part can make it very powerful while easy to use; but > can it run _after_ Django has returned the response to the web server? > IOW: does APScheduler run 'outside' the request-process-response > loop? or maybe it works with flup but not mod_wsgi, or the other way > around? > > in any case, it's worth some checking > > -- > Javier -- 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: Cron vs event triggered action
If are you going to choose A, take a look on Advanced Python Schedule (http://apscheduler.nextday.fi/). It's a python module that let you schedule some script to be executed periodically, it really makes the job easier. On Dec 14, 3:27 pm, Tim Daniel <redarrow...@hotmail.com> wrote: > Thanks for answering, I think I'm going to go with 'A' too. > > Guilherme I've had already looked after django-cron but don't know why > but it doesn't seem to work well, I've tried to increment a simple > counter in the database every 30 seconds and it doesn't work(using the > development server with django 1.1.1.). Also I don't see features > there to execute a job only once or to kill it. > > On django-jits all their sites seem to be offline : "Page > "InstallAndConfig" Not Found", and looking at the comments on the > first and only issue/ticket it seems to be an abandoned and not > finished project. So it isn't a reliable solution. > > And django-notification is not the thing I'm looking for because it > seems to be just for sending notifications to a user in the moment. > > So I'm still looking for a solution with better performance and less > overhead than 'A'. > > Creecode what do you mean with "custom management commands"? I just > wrote a simple python script that can be called from bash like this > python myscript.py, inside it I set up the enviroment to be able to > call my models and perform actions using the simplicity of the django > webframework. There I just check the entries on my cron-db table, and > if its time I perform the corresponding action (maybe having a type > field defining actions like sendmail or delete_account). > > On 14 dic, 12:30, Guilherme Cavalcanti <guiocavalca...@gmail.com> > wrote: > > > > > Tim, recently I've used the solution A too. > > > Take a look on these plugins: > > >http://code.google.com/p/django-cron/http://code.google.com/p/django-... > > > Pay attention specially on django-jits, it uses a little different > > approach based on your argument (threads). > > > Excuse my bad english. > > > On Dec 12, 7:58 pm, Tim Daniel <redarrow...@hotmail.com> wrote: > > > > Just want to figure out if there is a smarter solution for handling > > > the following problem: > > > > 1. An action is performed by a user (Normal django behaviour handling > > > a request and giving a response). > > > 2. Two hours later I want an automatic action to be done. > > > > Solution A: Have a datetime field with an expiry date and say every 10 > > > minutes a cron job checks the DB table for expired entries and > > > performs the programed action. > > > > Solution B: Have an event triggered cronjob that only executes once > > > and is created from Django(Python), after the 2 hours passed it > > > performs the programmed action only on the required entry. > > > > So how can I implement solution B? Is there a posibility to create a > > > cron on a user action that executes only one time? > > > > NOTE: I don't want to rely on a thread that should stay alive for two > > > hours ore more inside the server memory. -- 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: Cron vs event triggered action
Tim, recently I've used the solution A too. Take a look on these plugins: http://code.google.com/p/django-cron/ http://code.google.com/p/django-jits/ http://github.com/jtauber/django-notification/blob/master/docs/usage.txt Pay attention specially on django-jits, it uses a little different approach based on your argument (threads). Excuse my bad english. On Dec 12, 7:58 pm, Tim Danielwrote: > Just want to figure out if there is a smarter solution for handling > the following problem: > > 1. An action is performed by a user (Normal django behaviour handling > a request and giving a response). > 2. Two hours later I want an automatic action to be done. > > Solution A: Have a datetime field with an expiry date and say every 10 > minutes a cron job checks the DB table for expired entries and > performs the programed action. > > Solution B: Have an event triggered cronjob that only executes once > and is created from Django(Python), after the 2 hours passed it > performs the programmed action only on the required entry. > > So how can I implement solution B? Is there a posibility to create a > cron on a user action that executes only one time? > > NOTE: I don't want to rely on a thread that should stay alive for two > hours ore more inside the server memory. -- 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.