These are chat archives for django/django

14th
Feb 2018
Roel
@roelzkie15
Feb 14 2018 04:47
@Cosbgn It is better to include what is the current output and what is the expected output
Marios Panagopoulos
@MariosPanag
Feb 14 2018 15:25
hi one fast question max_id = Example.objects.latest('id').id is causing an error when Example table is empty
what should i do ?
try except: didnt work
emihir0
@emihir0
Feb 14 2018 20:18
@MariosPanag max_id = getattr(Example.objects.latest('id').values('id'), 'id', None)
try something along those lines
Saba Khukhunashvili
@SabaKhukhu
Feb 14 2018 20:36
Hi guys. how do i check birthday of user in background and send a birthday wish to his/her email (even if user is not online on website)? can you guys PLEASE give me a good resource to learn more about this?
emihir0
@emihir0
Feb 14 2018 20:38
you are looking for async tasks. there are many different options on how to do them. for example you can have a cron process running every 24 hours that triggers a management command from django (which goes through users and sends the appropriate emails).
your first step is to make a management command: https://docs.djangoproject.com/en/2.0/howto/custom-management-commands/ - that goes through users, finds ones with bday today and sends them emails
then your next step is to not have to trigger it manually every day... and there are several approaches, just google for django async tasks and find a solution that works for you
Saba Khukhunashvili
@SabaKhukhu
Feb 14 2018 20:39
Thank you so much. That's exactly what i was looking for.
emihir0
@emihir0
Feb 14 2018 20:40
np
honestly I've never done it before as I'm new to these stuff as well, but i've been reading about it quite a lot and there are just so many approach to this...
there are also some django packages that make it easier, eg: https://github.com/Tivix/django-cron
Ghost
@ghost~5a83b5e1d73408ce4f8d0deb
Feb 14 2018 22:24
Hi everyone, i’m looking for a beginner’s tutorial on Django. I know python and flask. Looking for any resources on django