These are chat archives for django/django

21st
Apr 2016
Affan Sadiq
@affansadiq
Apr 21 2016 10:18
is there any other channel for python?
mpachas
@mpachas
Apr 21 2016 11:14
Hi! I need to get 2 foreign key selects work together on admin views. Now I load the related widget with no choices and use js+ajax to load related values when something change (via OnChange() ) on the first one. Do you know any app that could help me with this?
Joseph Muli
@josephmuli
Apr 21 2016 16:24
Hi everyone? I'm trying to create a method that sends a notification via email every monday, how do I make this method independent, or how do I go about this?
Aubrey Taylor
@aubricus
Apr 21 2016 17:06
Good PST morning to everyone. Lately I am working with ModelAdmins and I noticed that only some query string params are allowed when calling ModelAdmin urls. For example "app_name/model_name/?foo=1" redirects to "app_name/model_name/?e=1". I've done enough googling to know why / where this is happening in Django. My question for the room is, are there any docs on query string param validation in Django docs? I can't find any reference to this functionality anywhere. This is mostly to satisfy my curiosity. I've been up and down the django src, so i have a rough idea. But some official docs couldn't hurt. Thanks!
Mir Nazim
@mnazim
Apr 21 2016 17:09
@josephmuli What do you mean by "make independent"? Convert it to a celery task, if you haven't done that already.
Sean Perry
@shaleh
Apr 21 2016 17:45
@affansadiq here on Gitter? No. Other choices: various Python channels on freenode IRC, reddit has several very active Python subreddits, and StackOverflow or their other site CodeReview are also very active if you have specific issues.
Patrick Harding
@senorpatricio
Apr 21 2016 18:12
I want to create a user profile page after a user registers. They register with a username and password, but on the profile page I want them to be able to add more information by extending the User model. Any help?
Joseph Muli
@josephmuli
Apr 21 2016 18:36
thanks @mnazim
Mir Nazim
@mnazim
Apr 21 2016 18:36
@josephmuli :thumbsup:
Mir Nazim
@mnazim
Apr 21 2016 18:43

@senorpatricio 1) You will need to detect the first login. Simplest way to do so is to add a boolean field to user model, say is_first_login. Default it to True.
2) Make a view/form for profile edit.
3) Make simple middleware that checks for user.is_first_login. like,

class FirstTimeLoginMiddleware(object):
    def process_request(self, request):
        if request.user.is_authenticated and request.user.is_first_login:
            redirect('edit_profile_url')

and done!

You need to flip is_first_login field to False at some point in the flow so that user does not keep getting redirected to edit profile url again and again. For example, when user saves the profile.
Mir Nazim
@mnazim
Apr 21 2016 18:54
@senorpatricio Did not notice that you wanted help with extending User model too. Simply use this https://github.com/jcugat/django-custom-user. Follow the docs, it's pretty straightfoward.
Patrick Harding
@senorpatricio
Apr 21 2016 19:04
@mnazim thanks so much. that answers all my questions
Mir Nazim
@mnazim
Apr 21 2016 19:05
:thumbsup: @senorpatricio