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
  • Redis backend too many open files

    Redis backend too many open files

    Describe the problem

    We have implemented django constance with a redis backend and a 60 local cache. When there is a large amount of traffic, our service becomes unstable, our latency spikes, and we get a ton of logs which say "too many open files." We have isolated the django-constance change as the only change we are deploying when we do this.

    Could this issue possibly be related to this: https://stackoverflow.com/a/25283155/3858494?

    Steps to reproduce

    Enable django-constance with a Redis backend and a 60 second local cache. Subject the service to a heavy load.

    System configuration

    I don't want to reveal this in a public forum.

    • Django version:
    • Python version:
    • Django-Constance version:
    opened by mikelane 3
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)
Domain-driven e-commerce for Django

Domain-driven e-commerce for Django Oscar is an e-commerce framework for Django designed for building domain-driven sites. It is structured such that

Oscar 5.6k Jan 01, 2023
A Django app for working with BTCPayServer

btcpay-django A Django app for working with BTCPayServer Installation pip install btcpay-django Developers Release To cut a release, run bumpversion,

Crawford 3 Nov 20, 2022
Учебное пособие по основам Django и сопутствующим технологиям

Учебный проект для закрепления основ Django Подробный разбор проекта здесь. Инструкция по запуску проекта на своей машине: Скачиваем репозиторий Устан

Stanislav Garanzha 12 Dec 30, 2022
Chatbot for ordering and tracking a Pizza.

Pizza Chatbot To start the app, follow the below steps: Clone the repo using the below command: git clone Shreya Shah 1 Jul 15, 2021

A GitHub Action for checking Django migrations

🔍 Django migrations checker A GitHub Action for checking Django migrations About This repository contains a Github Action that checks Django migratio

Oda 5 Nov 15, 2022
Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot. A fully Django starter project.

Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot 🚀 Features A Django stater project with fully basic requirements for a production-ready

8 Jun 27, 2022
Strawberry-django-plus - Enhanced Strawberry GraphQL integration with Django

strawberry-django-plus Enhanced Strawberry integration with Django. Built on top

BLB Ventures 138 Dec 28, 2022
Django Pickled Model

Django Pickled Model Django pickled model provides you a model with dynamic data types. a field can store any value in any type. You can store Integer

Amir 3 Sep 14, 2022
Django's class-based generic views are awesome, let's have more of them.

Django Extra Views - The missing class-based generic views for Django Django-extra-views is a Django package which introduces additional class-based v

Andy Ingram 1.3k Jan 04, 2023
Tweak the form field rendering in templates, not in python-level form definitions. CSS classes and HTML attributes can be altered.

django-widget-tweaks Tweak the form field rendering in templates, not in python-level form definitions. Altering CSS classes and HTML attributes is su

Jazzband 1.8k Jan 02, 2023
Auth module for Django and GarpixCMS

Garpix Auth Auth module for Django/DRF projects. Part of GarpixCMS. Used packages: django rest framework social-auth-app-django django-rest-framework-

GARPIX CMS 18 Mar 14, 2022
MAC address Model Field & Form Field for Django apps

django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Pa

49 Sep 04, 2022
Python CSS/Javascript minifier

Squeezeit - Python CSS and Javascript minifier Copyright (C) 2011 Sam Rudge This program is free software: you can redistribute it and/or modify it un

Smudge 152 Apr 03, 2022
Use webpack to generate your static bundles without django's staticfiles or opaque wrappers.

django-webpack-loader Use webpack to generate your static bundles without django's staticfiles or opaque wrappers. Django webpack loader consumes the

2.4k Dec 24, 2022
Realworld - Realworld using Django and HTMX

Realworld - Realworld using Django and HTMX

Dan Jacob 53 Jan 05, 2023
Compresses linked and inline javascript or CSS into a single cached file.

Django Compressor Django Compressor processes, combines and minifies linked and inline Javascript or CSS in a Django template into cacheable static fi

2.6k Jan 03, 2023
A simple djagno music website.

Mrock A simple djagno music website. I used this template and I translated it to eng. Also some changes commited. My Live Domo : https://mrock.pythona

Hesam N 1 Nov 30, 2021
✋ Auto logout a user after specific time in Django

django-auto-logout Auto logout a user after specific time in Django. Works with Python 🐍 ≥ 3.7, Django 🌐 ≥ 3.0. ✔️ Installation pip install django-a

Georgy Bazhukov 21 Dec 26, 2022
A simple polling app made in Django and Bootstrap

DjangoPolls A Simple Polling app made with Django Instructions Make sure you have Python installed Step 1. Open a terminal Step 2. Paste the given cod

Aditya Priyadarshi 1 Nov 10, 2021
An app that allows you to add recipes from the dashboard made using DJango, JQuery, JScript and HTMl.

An app that allows you to add recipes from the dashboard. Then visitors filter based on different categories also each ingredient has a unique page with their related recipes.

Pablo Sagredo 1 Jan 31, 2022