if statement for development/production mode in templates?

26 views
Skip to first unread message

Alexander Joseph

unread,
Apr 23, 2018, 9:34:58 AM4/23/18
to Django users
Hello, is there a way to make an if statement that is based on whether you are running in development mode or production mode? Or based on which settings file you are using?

My app allows users to login with their office365 account instead of with django allauth and I'd like to only give them that option, however I do need to login with allauth while developing because the settings for logging in to Office365 dont work with a development server. So I'd like to display the allauth login form and allow the user to login if it is in development mode, otherwise I'd only like to display the Office365 login.

Thanks

Larry Martell

unread,
Apr 23, 2018, 9:49:25 AM4/23/18
to django...@googlegroups.com
Just pass in something in the context from the server to the template
and test that.

Alexander Joseph

unread,
Apr 23, 2018, 9:55:52 AM4/23/18
to Django users
I dont know what that means

Julio Biason

unread,
Apr 23, 2018, 9:59:00 AM4/23/18
to django...@googlegroups.com
You could, on your views, get the DEBUG setting (using django.conf) and pass it to the templates, as you do with all other variable.


From: django...@googlegroups.com <django...@googlegroups.com> on behalf of Alexander Joseph <alexander...@gmail.com>
Sent: Monday, April 23, 2018 10:55:52 AM
To: Django users
Subject: Re: if statement for development/production mode in templates?
 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5aae6def-df66-40a1-90cc-733b2afa22b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Larry Martell

unread,
Apr 23, 2018, 10:04:02 AM4/23/18
to django...@googlegroups.com
Somewhere in the code is a place where data is passed to the template.
Did you write the app?

On Mon, Apr 23, 2018 at 9:55 AM, Alexander Joseph
<alexander...@gmail.com> wrote:
> I dont know what that means
>
> On Monday, April 23, 2018 at 7:49:25 AM UTC-6, Larry....@gmail.com wrote:
>>
>> On Mon, Apr 23, 2018 at 9:34 AM, Alexander Joseph
>> <alexander...@gmail.com> wrote:
>> > Hello, is there a way to make an if statement that is based on whether
>> > you
>> > are running in development mode or production mode? Or based on which
>> > settings file you are using?
>> >
>> > My app allows users to login with their office365 account instead of
>> > with
>> > django allauth and I'd like to only give them that option, however I do
>> > need
>> > to login with allauth while developing because the settings for logging
>> > in
>> > to Office365 dont work with a development server. So I'd like to display
>> > the
>> > allauth login form and allow the user to login if it is in development
>> > mode,
>> > otherwise I'd only like to display the Office365 login.
>>
>> Just pass in something in the context from the server to the template
>> and test that.
>

Alexander Joseph

unread,
Apr 23, 2018, 10:16:29 AM4/23/18
to Django users
Reply all
Reply to author
Forward
0 new messages