Categories
Python Answers

How to change Python Django settings at runtime?

Spread the love

Sometimes, we want to change Python Django settings at runtime.

In this article, we’ll look at how to change Python Django settings at runtime.

How to change Python Django settings at runtime?

To change Python Django settings at runtime, we can set the conf.settings dictionary.

For instance, we write

import django.conf as conf

conf.settings.DATABASES['default']['NAME'] = 'abc'

to set the conf.settings.DATABASES['default']['NAME'] field to a value in the entry point of our app.

Conclusion

To change Python Django settings at runtime, we can set the conf.settings dictionary.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *