Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7692043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:45:43+00:00 2026-05-31T20:45:43+00:00

My site has few global configurations. For example "smtp-server address", "company address", etc. Of

  • 0

My site has few global configurations. For example "smtp-server address", "company address", etc.

Of course I can:

  1. Create variables in settings.py and use it in templates and apps;
  2. Create a model (like Configuration) and write all needed fields there.

If I use the first way I can’t give access for changing these fields in django-admin.

If I use the seconds way it is not a beautiful solution, because everywhere in the code I have to use model_name.objects.get(id=1) and I need only one instance. Models were created for other tasks.

How can I solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:45:44+00:00Added an answer on May 31, 2026 at 8:45 pm

    This is what I did. Might not be the most optimal solution but works for me.

    1. Create a Configuration model and do all the usual stuff as in your point 2. Create a function (say in configuration.view) which will pull out and return the configuration values in a dict.

    2. Now in your settings.py, import your function and set the returned dict to a settings.py variable:
      CONFIG = configuration.view.get_config()

    3. Create a template context processor which will set this CONFIG dict in the template context.

      def init_site_settings(request):
          return settings.CONFIG
      
    4. Add this context processor to your TEMPLATE_CONTEXT_PROCESSORS

    5. Now you are free to use your configuration parameters in templates as {{my_config_key}}

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that has few request options (for example add photo, add
My site has a library full of games, nations, game scenarios, etc. library.php is
This site has a technique to pass xml data around in Microsoft SQL Server:
I'm working on a site that has quite a few pages that fall outside
Currently I have a few lists in my SharePoint site that has been hidden
My Magento site has a product which has a few Custom Options, one text,
Our site has a complex administrative hierarchy with a a few behavioral splits. To
My site has a few pages that point to the same child page. I'm
Our company site has a JavaScript problem that I'm desperately trying to solve, but
I'm developing a site that has a few files on it that I only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.