Dynamic Django settings.

Overview
Comments
  • New version should be released for Django 1.6

    New version should be released for Django 1.6

    The current stable version of django-constance does not work out of the box on Django 1.6, which has now been released. The following exception is raised when viewing /admin:

    AttributeError at /admin/
    'Meta' object has no attribute 'object_name'
    

    Now, this has been fixed with the following commit: https://github.com/comoga/django-constance/commit/987e13f1ae24b419574d09d88097f41b7bd6ffc1. However, this commit was merged three months ago and the latest django-constance release (0.6) was released eight months ago.

    This forces users to install directly from Git if they are using Django 1.6. Instead, it would be great to see a new release of django-constance with the fix included.

    opened by nathan-osman 25
  • Unable to run migrations from scratch

    Unable to run migrations from scratch

    The problem

    I have a project with 50+ migrations in it and recently decided I want to use Constance for a couple of settings.

    Everything was OK while developing/adding dynamic settings. I guess it's due to the fact that I setup the Constance config first, did the migration and only then start to use dynamic settings values.

    Although when I want to do a test deploy (i.e. when starting up a new Vagrant VM) and run all the migrations from scratch it fails. I am unable to run python manage.py migrate database, python manage.py migrate or even python manage.py showmigrations.

      File "/vagrant/my_app/views.py", line 138, in MyViewSet
        my_variable = constance_config.MY_VARIABLE
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/utils/functional.py", line 239, in inner
        return func(self._wrapped, *args)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/constance/base.py", line 19, in __getattr__
        result = self._backend.get(key)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/constance/backends/database/__init__.py", line 74, in get
        value = self._model._default_manager.get(key=key).value
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
        return getattr(self.get_queryset(), name)(*args, **kwargs)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/query.py", line 374, in get
        num = len(clone)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/query.py", line 232, in __len__
        self._fetch_all()
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/query.py", line 1118, in _fetch_all
        self._result_cache = list(self._iterable_class(self))
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/query.py", line 53, in __iter__
        results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 894, in execute_sql
        raise original_exception
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 884, in execute_sql
        cursor.execute(sql, params)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/backends/utils.py", line 80, in execute
        return super(CursorDebugWrapper, self).execute(sql, params)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
        return self.cursor.execute(sql, params)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
        six.reraise(dj_exc_type, dj_exc_value, traceback)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/home/ubuntu/.virtualenvs/venv/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute
        return self.cursor.execute(sql, params)
    django.db.utils.ProgrammingError: relation "constance_config" does not exist
    LINE 1: ...ce_config"."key", "constance_config"."value" FROM "constance...
    

    So a table that is about to be created is referenced already.

    System configuration

    • Django version: 1.11.3
    • Python version: 3.5.2,
    opened by DusanMadar 24
  • Fixed model creation for Django1.8 ContentType change

    Fixed model creation for Django1.8 ContentType change

    Added in a hook to check for Django version on model creation. Not sure if this is the best way to get V1.8 compatibility, but it works for all my purposes.

    Cheers, Jonathan

    opened by jonzlin95 22
  • Google DMCA takedown notice

    Google DMCA takedown notice

    As an FYI, "Takedown Piracy LLC" sent a DMCA takedown notice for this repository to google on Dec 24th.

    The notice is posted at chilling effects... https://www.chillingeffects.org/notices/10281020

    and less exactly on google's transparency site (doesn't list exact github urls) http://www.google.com/transparencyreport/removals/copyright/requests/1763826/

    There's an article describing this problem here which made slashdot. http://motherboard.vice.com/read/porn-companies-are-going-after-github

    I just happened to notice and thought you might want to know.

    blocker 
    opened by jasonlttl 22
  • exception in thread django-main-thread error

    exception in thread django-main-thread error

    Describe the problem

    django_err

    Tell us about the problem you're having.

    I was trying to install djangorestframewok and i installed it then i had an issue running the server have attached the image file

    (localdev-EUbEEbsi) C:\Users\ASUS\Desktop\localdev\ecom>python manage.py runserver Watching for file changes with StatReloader Performing system checks...

    Exception in thread django-main-thread: Traceback (most recent call last): File "c:\users\asus\appdata\local\programs\python\python38-32\lib\threading.py", line 932, in _bootstrap_inner self.run() File "c:\users\asus\appdata\local\programs\python\python38-32\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Users\ASUS.virtualenvs\localdev-EUbEEbsi\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:\Users\ASUS.virtualenvs\localdev-EUbEEbsi\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "C:\Users\ASUS.virtualenvs\localdev-EUbEEbsi\lib\site-packages\django\core\management\base.py", line 392, in check all_issues = checks.run_checks( File "C:\Users\ASUS.virtualenvs\localdev-EUbEEbsi\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "C:\Users\ASUS.virtualenvs\localdev-EUbEEbsi\lib\site-packages\django\core\checks\urls.py", line 101, in check_url_settings if value and not value.endswith('/'): AttributeError: 'tuple' object has no attribute 'endswith'

    Steps to reproduce

    Tell us how to reproduce it.

    System configuration

    • Django version:
    • Python version:3.8.5
    • Django-Constance version:
    opened by narenpop 20
  • separate configs in blocks (not break anything)

    separate configs in blocks (not break anything)

    i think sometimes we need to make a block for differents types of values, for example, encapsulate finances values like tax and parity.

    so, i modify the code for add this function without break the Backward compatibility. new config looks like this:

    CONSTANCE_CONFIG = { 'TEST_1': (42, 'Answer to the Ultimate Question of Life, The Universe, and Everything'), 'TEST_2': ('prueba', 'string test'), 'TAX': (0.16, 'Tax','Finances'), 'USD_TO_MXN': (16.40, 'Dollar to mexican pesos','Finances'), }

    where finances is the new block Image

    opened by darkkaze 18
  • Allow override_config for pytest

    Allow override_config for pytest

    override_config is currently possible to apply only to unittest TestCase classes. This PR adds constance.test.pytest module that can be used as follows

    Examples can be found in doc

    It's still possible to do import as usual for unittest

    from constance.test import override_config
    
    ...
    
    opened by TamoshaytisV 15
  • 1.1 drops support for Django 1.7?

    1.1 drops support for Django 1.7?

    The doc claims that 1.1 adds support for Django 1.8 and 1.9, while <=1.6 are not supported any more. That's fine, except that 1.7(.10) support also seems to be gone. When clicking on the config in django admin, one gets:

    TypeError at /admin/constance/config/ object of type 'Config' has no len() ... Exception Location: .../python2.7/site-packages/django/utils/functional.py in inner, line 225

    This is while using pyhon 2.7. The net result is that one has to upgrade constance exactly at the time of a django upgrade, which is suboptimal. Is this really the case?

    opened by robert-kisteleki 15
  • can't compare offset-naive and offset-aware datetimes

    can't compare offset-naive and offset-aware datetimes

    @jezdez

    If trying to save a datetime type setting getting this in Django 1.5.4:

    TypeError
    Exception Value:    
    can't compare offset-naive and offset-aware datetimes
    Exception Location: constance/admin.py in changelist_view, line 119
    
    • http://stackoverflow.com/questions/7065164/how-to-make-an-unaware-datetime-timezone-aware-in-python
    • http://stackoverflow.com/questions/796008/cant-subtract-offset-naive-and-offset-aware-datetimes
    opened by littlepea 13
  • Forward the request when saving the form

    Forward the request when saving the form

    Hello. I would like to forward the request to the instance of ConstanceForm, when calling the save method. Help me understand if it is necessary to update any tests.

    opened by felippem 12
  • Backport command functonality from django-constance-cli

    Backport command functonality from django-constance-cli

    Backporting command function from https://github.com/NZME/django-constance-cli in as requested by @jezdez in NZME/django-constance-cli#2

    Basic usage:

    ./manage.py constance list
    ./manage.py constance get FOO
    ./manage.py constance set FOO bar
    

    A couple of issues to discuss before merging:

    • ~~Should it be possible to disable this command functionality? I could do this by moving the command to a sub-app (eg constance.cli), or with a setting?~~ ** I'm not sure it's necessary to allow this to be disabled (eg, I don't think it's a security risk - if you've got manage.py access then you can do anything anyway).
    • ~~The command line syntax could be expanded or altered, I've loosely modelled it on git config, any better suggestions?~~ ** I've updated as per discussion to positional arguments
    opened by therefromhere 12
  • Race-condition caused by when constance registers Django checks

    Race-condition caused by when constance registers Django checks

    Describe the problem

    Using django-constance with pytest causes race-condition in settings load because of a misplaced import:

    https://github.com/jazzband/django-constance/blob/b6f8e2c5b8e151b0a58ae999991580a3c1a1e28c/constance/init.py#L3

    Django documentation recommends in [link]:

    Lastly, your check function must be registered explicitly with system check registry. Checks should be registered in a file that’s loaded when your application is loaded; for example, in the AppConfig.ready() method.

    This is how the race-condition happens:

    1. Pytest plugin manager loads the constance/test/pytest.py file
    2. The constance/test/pytest.py file refers to constance/__init__.py in: https://github.com/jazzband/django-constance/blob/b6f8e2c5b8e151b0a58ae999991580a3c1a1e28c/constance/test/pytest.py#L8
    3. The constance/__init__.py causes checks to be registered in: https://github.com/jazzband/django-constance/blob/b6f8e2c5b8e151b0a58ae999991580a3c1a1e28c/constance/init.py#L3
    4. Important: This happens before pytest-django can set up Django here
      1. Whenever checks are loaded, it will cascade-load Django checks as well
      2. Django checks will try to load internal stuff like caches and database
      3. Whenever Django detects cache/database isn't configured, it will configure them before knowing what the final state of settings would be
    5. Pytest plugin manager will now trigger all the hooks for plugins to load correctly (eg. pytest_configure)
    6. The pytest-django plugin finally sets settings up - this is when constance should register its checks
    7. Important: Now if you compare django.conf.settings with django.db.connections.settings they can likely be different as below:
    (Pdb) from django.conf import settings
    (Pdb) p settings
    <dynaconf.base.LazySettings object at 0x1127de640>
    (Pdb) p settings.DATABASES
    <Box: {'default': {'NAME': 'local', 'USER': '', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '', 'CONN_MAX_AGE': 500, 'ENGINE': 'django.db.backends.postgresql_psycopg2'}}>
    (Pdb) from django.db import connections
    (Pdb) p connections
    <django.db.utils.ConnectionHandler object at 0x111fa4c40>
    (Pdb) p connections.settings
    {'default': {'ENGINE': 'django.db.backends.dummy', 'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'OPTIONS': {}, 'TIME_ZONE': None, 'NAME': '', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}}}
    

    Steps to reproduce

    I think this really depends on your set up. I was able to reproduce it using dynaconf probably because of the way it overrides Django settings. Nonetheless, I'm sure that if constance can load checks correctly this shouldn't be a problem.

    System configuration

    • Django version: 3.2
    • Python version: 3.9
    • Django-Constance version: 2.7
    opened by caioariede 0
  • Repeating queries when constance is installed

    Repeating queries when constance is installed

    Describe the problem

    Sentry is reporting that constance is performing a n + 1 query whenever the main page of my website loads. Strangely the main page does not use any configuration values from constance (as far as I can tell).

    Repeating query

    SELECT "constance_config"."id", "constance_config"."key", "constance_config"."value" FROM "constance_config" WHERE "constance_config"."key" = %s LIMIT 21
    
    N+1 Query SELECT constance_config id, constance_config key, constance_config value FROM constance_config WHERE c

    System configuration

    • Django version: 4.1.3
    • Python version: CPython 3.10.6
    • Django-Constance version: [database] 2.9.1
    opened by ericswpark 1
  • Advice needed: Wrap Redis backend with in-memory backend function?

    Advice needed: Wrap Redis backend with in-memory backend function?

    Describe the problem

    Using the Redis Backend, and calling config.VARIABLE repeatedly for the many variables slows down the performance ((tested)).

    I ask, from a theoretic standpoint:

    Is there something to gain from wrapping the calls to constance values with an in-memory cache (e.g get_constance_value(value, cache_ttl)) that will get the value from Redis the first time, and keep it in-memory (e.g. for 60 seconds)?

    opened by gabriels1234 1
  • Constance CLI does not work properly without django admin

    Constance CLI does not work properly without django admin

    Describe the problem

    It seems disabling django admin's app breaks the constance CLI. As I noticed constance/management/commands/constance.py imports ConstanceForm and get_values from admin configuration. The problem is admin.py tries to register the constance's config class and since the admin app is not present in INSTALLED_APPS django throws a LookupError.

    I think splitting ConstanceForm and get_values to a separate module (like forms.py) and importing them directly from that module can easily fix the problem.

    Steps to reproduce

    1. Remove django.contrib.admin from INSTALLED_APPS (And its URL pattern)
    2. Run python manage.py constance --help

    System configuration

    • Django version: 4.0.7
    • Python version: 3.10.7
    • Django-Constance version: 2.9.1
    opened by Alirezaja1384 1
Releases(2.9.1)
  • 2.9.1(Aug 11, 2022)

    What's Changed

    • Add support for using gettext in fieldset headers by @alexkiro in https://github.com/jazzband/django-constance/pull/489
    • Added support for Django 4.1. by @felixxm in https://github.com/jazzband/django-constance/pull/487
    • Fix text format for MultiValueField usage by @yuekui in https://github.com/jazzband/django-constance/pull/494
    • [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/jazzband/django-constance/pull/486
    • Preparing release 2.9.1 by @Natim in https://github.com/jazzband/django-constance/pull/497

    New Contributors

    • @alexkiro made their first contribution in https://github.com/jazzband/django-constance/pull/489
    • @Natim made their first contribution in https://github.com/jazzband/django-constance/pull/497

    Full Changelog: https://github.com/jazzband/django-constance/compare/2.9.0...2.9.1

    Source code(tar.gz)
    Source code(zip)
Owner
Jazzband
We are all part of this
Jazzband
Dynamic Django settings.

Constance - Dynamic Django settings A Django app for storing dynamic settings in pluggable backends (Redis and Django model backend built in) with an

Jazzband 1.5k Jan 04, 2023
MOHAconfig - Gerador de arquivo de configuração para Medal of Honor: Airborne

MOHAconfig Gerador de arquivo de configuração para Medal of Honor: Airborne MOHA - Gerador de arquivo de configuração. Essa aplicação foi feita em pyt

1 Dec 31, 2021
Tools to assist with the configuration and maintenance of fapolicyd.

Tools to assist with the configuration and maintenance of fapolicyd.

Concurrent Technologies Corporation (CTC) 7 Dec 27, 2022
🤫 Easily manage configs and secrets in your Python projects (with CLI support)

Installation pip install confidential How does it work? Confidential manages secrets for your project, using AWS Secrets Manager. First, store a secr

Candid™️ 63 Oct 30, 2022
Flexible Python configuration system. The last one you will ever need.

OmegaConf Description Project Code quality Docs and support OmegaConf is a hierarchical configuration system, with support for merging configurations

Omry Yadan 1.4k Jan 02, 2023
A lightweight Traits like module

Traitlets home https://github.com/ipython/traitlets pypi-repo https://pypi.org/project/traitlets/ docs https://traitlets.readthedocs.io/ license Modif

IPython 532 Dec 27, 2022
sqlconfig: manage your config files with sqlite

sqlconfig: manage your config files with sqlite The problem Your app probably has a lot of configuration in git. Storing it as files in a git repo has

Pete Hunt 4 Feb 21, 2022
environs is a Python library for parsing environment variables.

environs: simplified environment variable parsing environs is a Python library for parsing environment variables. It allows you to store configuration

Steven Loria 920 Jan 04, 2023
Load Django Settings from Environmental Variables with One Magical Line of Code

DjEnv: Django + Environment Load Django Settings Directly from Environmental Variables features modify django configuration without modifying source c

Daniel J. Dufour 28 Oct 01, 2022
KConfig Browser is a graphical application which allows you to modify KDE configuration files found in ~/.config

kconfig_browser KConfig Browser is a graphical application which allows you to modify KDE configuration files found in ~/.config Screenshot Why I crea

11 Sep 15, 2022
Pyleri is an easy-to-use parser created for SiriDB

Python Left-Right Parser Pyleri is an easy-to-use parser created for SiriDB. We first used lrparsing and wrote jsleri for auto-completion and suggesti

Cesbit 106 Dec 06, 2022
A small example project for efficiently configuring a Python application with YAMLs and the CLI

Hydra Example Project for Python A small example project for efficiently configuring a Python application with YAMLs and the CLI. Why should I care? A

Florian Wilhelm 4 Dec 31, 2022
Kubernates Config Manager

Kubernates Config Manager Sometimes we need manage more than one kubernates cluster at the same time. Switch cluster configs is a dangerous and troubl

周文阳 3 Jan 10, 2022
Strict separation of config from code.

Python Decouple: Strict separation of settings from code Decouple helps you to organize your settings so that you can change parameters without having

Henrique Bastos 2.3k Dec 30, 2022
Yamale (ya·ma·lē) - A schema and validator for YAML.

Yamale (ya·ma·lē) ⚠️ Ensure that your schema definitions come from internal or trusted sources. Yamale does not protect against intentionally maliciou

23andMe 534 Dec 21, 2022
A tool to manage configuration files, build scripts etc. across multiple projects.

A tool to manage configuration files, build scripts etc. across multiple projects.

8 Dec 14, 2022
Config files for my GitHub profile.

Hacked This is a python base script from which you can hack or clone any person's facebook friendlist or followers accounts which have simple password

2 Dec 10, 2021
Config files for my GitHub profile.

Config files for my GitHub profile.

Lukas Sales 7 May 17, 2022
Read configuration settings from python configuration files.

Maison Read configuration settings from python configuration files. Motivation When developing a python application, e.g a command-line tool, it can b

9 Jan 04, 2023
Napalm-vs-openconfig - Comparison of NAPALM and OpenConfig YANG with NETCONF transport

NAPALM vs NETCONF/OPENCONFIG Abstracts Multi vendor network management and autom

Anton Karneliuk 1 Jan 17, 2022