Giter Club home page Giter Club logo

django-constance's People

Contributors

aleszoulek avatar bouke avatar browniebroke avatar bufke avatar camilonova avatar chornsby avatar chrisclark avatar farin avatar farooqaaa avatar felixxm avatar flisky avatar iamkhush avatar jdufresne avatar jezdez avatar kerl13 avatar martey avatar merino avatar mogost avatar petrdlouhy avatar pre-commit-ci[bot] avatar prokaktus avatar rotzbua avatar rvernica avatar sebcorbin avatar sergei-iurchenko avatar therefromhere avatar trbs avatar utapyngo avatar whiskybar avatar whs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-constance's Issues

Values are off

Hi,

Thanks for a great app to work with live settings.

I have a weird problem where there seems to be a mismatch in the admin form between the settings and their default values as retrieved from settings.py and the values from the database. Some of the values from the database do not appear in the correct fields, for example I have the following settings in settings.py:

business_name -> default value: "My Business", value in form: "09980 122112"
business_phone -> default value: "09980 122112" value in form: "My Business"

So, the phone number and business name have somehow been switched.

For some reason constance seems to mix up settings and values. Any idea? Thanks.

improve support for constance keys as lists

Given that we can now store lists in constance (thanks #54), we now ought to improve support for lists as keys in constance.

Specifically, we ought to either:

  • document proper use of defining and using lists as keys
  • improve constance handling of lists to simplify use of lists in constance

As an example, lists come out as unicode strings and need something like eval():

>>> from constance import config
>>> config.EMAIL
u"['[email protected]',]"
>>> email = eval(config.EMAIL)
>>> email
['[email protected]']

How should this be addressed?

Django 1.8 ContentType Model change

Hi all,

Love constance, and I've been using on my projects for a while now. I've been playing around with the dev version of Django (1.8a1/1.8b1), and noticed a change in the ContentTypes Model that breaks Constance on manage.py migrate.

https://docs.djangoproject.com/en/1.8/ref/contrib/contenttypes/
name
The human-readable name of the content type. This is taken from the verbose_name attribute of the model.
Changed in Django 1.8:
Before Django 1.8, the name property was a real field on the ContentType model.

In particular, the error is

File "/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1369, in names_to_path
    "Choices are: %s" % (name, ", ".join(available)))
django.core.exceptions.FieldError: Cannot resolve keyword 'name' into field. Choices are: app_label, id, logentry, model, permission

from

File "/lib/python2.7/site-packages/constance/models.py", line 16, in create_perm
    model='config')

I was able to hack around it simply by removing the name='config' line from constance/models.py
Thanks for all the hard work!

Cheers,
Jonathan

Support for django 1.3

I tried constance with Django 1.3 but I am getting --- Meta' object has no attribute 'abstract' --- , when viewing pages after installation. Looking at your admin.py file in the class Config(), I am not seeing any abstract being defined. Does constance support 1.3 at all?

Django-constance and django-grappelli support

Hello!

Do you can maintain django-grappelli support for django-constance? Somebody should overwrite default django-grappelli templates for django-constance, because django-grappelli don't have support for "version" field in django-grappelli/grappelli/templates/admin/constance/change_list.html.

Greetings,
Adam Dobrawy

Error in documentation re. database backend

I think you forgot the quotes around the CONSTANCE_BACKEND property value in your documentation. It should be set like this:
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'

Minor issue regarding the docs

Under Database.

CONSTANCE_BACKEND = constance.backends.database.DatabaseBackend

Should be:

CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend '

Allow line breaks in config descriptions

It would be great to allow line breaks in the help text of the various config options. E.g.:

CONSTANCE_CONFIG = {
    'MY_SETTING': ('foo', 'This is some help text\n\nWith line breaks!')
}

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.

Custom admin widgets

What did you think about overriding default field and widgets from FIELD.
I think that adding some custom widgets, like forms.widget.Select, it's a good idea.

For back capailty i want to add separate settings FIELD_OVERRIDE.
It will be something like this.

CONSTANCE_CONFIG = {
    'MY_SETTINGS_KEY': (42, 'the answer to everything'),
}

FIELD_OVERRIDE = {
    'MY_SETTINGS_KEY': (fields.ChoiceField,
                        {
                            'widget': forms.Select,
                            'choices': ((42, 'it is'),
                                        (37, 'not so good'))
                        })
}

What did you think about it ?
If you agreed with me that it's quit usefull i will implement it and create a pull requst.

Using database backend

I just followed the readme :
added picklefield, constance, constance.database.backend, in this order, but the app still wants the redis-py component install to start :

File "snip/site-packages/constance/init.py", line 3, in
config = Config()
File "snip/site-packages/constance/config.py", line 9, in init
utils.import_module_attr(settings.BACKEND)())
File "snip/site-packages/constance/backends/redisd.py", line 27, in init
"The Redis backend requires redis-py to be installed.")
django.core.exceptions.ImproperlyConfigured:
The Redis backend requires redis-py to be installed.

If I install redis-py to overcome the warning, I then get :
ConnectionError: Error 61 connecting localhost:6379. Connection refused.

So at this moment, classic database backend is not possible it seems

Proper documentation is missing.

Dear developers, I looked upon code, there isn't a proper documentation about using. Installing is quite easy but using is harsh (for example which models does constance support). This also implies #38 .

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: 987e13f. 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.

Update docs to describe how to write tests for code using constance?

I'll be happy to submit a pull request if I can figure this out, as someone else might have similar issues.

I'm trying to update my tests for code that used to make use of static settings in my settings.py file, now that I have switched to using constance.

Previously:

# settings.py
...
MY_SETTING = ''

# models.py
from django.conf import settings

def foo():
    if settings.MY_SETTING == 'VALUE':
        return 'foo'
    return 'bar'

# tests.py
import unittest
from django.conf import settings
from .models import foo

class MyTest(unittest.TestCase):
    def test_foo(self):
        settings.MY_SETTING = 'VALUE'
        self.assertEqual(foo(), 'foo')

And then for all my tests I could try setting settings.MY_SETTING appropriately and test the response:

Creating test database for alias 'default'...
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
Destroying test database for alias 'default'...

I tried converting this converted this to:

# settings.py
...
INSTALLED_APPS += ('constance',)
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
CONSTANCE_CONFIG = {
    'MY_SETTING': ('', ''),
}


# models.py
import constance

def foo():
    if constance.config.MY_SETTING == 'VALUE':
        return 'foo'
    return 'bar'

And attempted to test it by setting the value directly:

# tests.py
import unittest
from . import models

class MyTest(unittest.TestCase):
    def test_foo(self):
        models.constance.config.MY_SETTING = ('VALUE', '')
        self.assertEqual(models.foo(), 'foo')

Which returns:

Creating test database for alias 'default'...
E
======================================================================
ERROR: test_foo (foo.tests.MyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ianlee1521/foo/foo/tests.py", line 6, in test_foo
    models.constance.config.MY_SETTING = ('VALUE', '')
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/utils/functional.py", line 253, in __setattr__
    setattr(self._wrapped, name, value)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/constance/base.py", line 27, in __setattr__
    self._backend.set(key, value)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/constance/backends/database/__init__.py", line 82, in set
    key=self.add_prefix(key), defaults={'value': value}
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 422, in get_or_create
    return self.get(**lookup), False
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 351, in get
    num = len(clone)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 122, in __len__
    self._fetch_all()
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 966, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 265, in iterator
    for row in compiler.results_iter():
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 485, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: no such table: constance_config

----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (errors=1)
Destroying test database for alias 'default'...

Alternatively, I tried using mock:

# tests.py
import unittest
import mock
from .models import foo

class MyTest(unittest.TestCase):
    @mock.patch('foo.models.constance.config.MY_SETTING')
    def test_foo(self, mock_config):
        mock_config.return_value = 'VALUE'
        self.assertEqual(foo(), 'foo')

But with very similar results:

Creating test database for alias 'default'...
E
======================================================================
ERROR: test_foo (foo.tests.MyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/mock.py", line 1193, in patched
    arg = patching.__enter__()
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/mock.py", line 1268, in __enter__
    original, local = self.get_original()
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/mock.py", line 1236, in get_original
    original = getattr(target, name, DEFAULT)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/utils/functional.py", line 225, in inner
    return func(self._wrapped, *args)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/constance/base.py", line 17, in __getattr__
    result = self._backend.get(key)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/constance/backends/database/__init__.py", line 72, in get
    value = self._model._default_manager.get(key=key).value
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 351, in get
    num = len(clone)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 122, in __len__
    self._fetch_all()
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 966, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/query.py", line 265, in iterator
    for row in compiler.results_iter():
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/ianlee1521/.local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 485, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: no such table: constance_config

----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (errors=1)
Destroying test database for alias 'default'...

Any thoughts? This seems like it is related to #84? And maybe similar (ish) to #77?

[Docs] Supported value types.

I suggest to provide some info in README or wherever you might think it should be about supported value types and their cast logic for both Redis and Database backends with screenshots of admin site.

For example:
I need to store/retrieve/edit tuple of strings in certain key, but how it will looks like in admin site? as value, value,… or (u'value', u'value',…)?

Thanks in advance for your reply.

question: is it possible to override a variable in settings.py with a constance value?

is it possible to override a variable in settings.py with a constance value?
My use case is that I want to be able to set DEBUG = True or Debug = False in the constance admin panel.
Also I would like to be able to configure MANDRILL_API_KEY from https://github.com/brack3t/Djrill with a constance variable.

I have been unsuccessful in getting this to work, because constance appears to import from settings.py and when I put 'from constance import config' therefore there is a circular import in my settings.py file.

ImproperlyConfigured

Hello,

I'm trying this app with Django 1.7b3 and I'm getting this error:

Traceback (most recent call last):
  File "/home/humitos/Source/chap/chap/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/humitos/.virtualenvs/chap/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 427, in execute_from_command_line
    utility.execute()
  File "/home/humitos/.virtualenvs/chap/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 391, in execute
    django.setup()
  File "/home/humitos/.virtualenvs/chap/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/humitos/.virtualenvs/chap/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/humitos/.virtualenvs/chap/local/lib/python2.7/site-packages/django/apps/config.py", line 87, in create
    module = import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/humitos/.virtualenvs/chap/src/django-constance/constance/__init__.py", line 3, in <module>
    config = Config()
  File "/home/humitos/.virtualenvs/chap/src/django-constance/constance/config.py", line 10, in __init__
    utils.import_module_attr(settings.BACKEND)())
  File "/home/humitos/.virtualenvs/chap/src/django-constance/constance/backends/database/__init__.py", line 27, in __init__
    "The constance.backends.database app isn't installed "
django.core.exceptions.ImproperlyConfigured: The constance.backends.database app isn't installed correctly. Make sure it's in your INSTALLED_APPS setting.

I installed it by running: pip install django-constance[database] and my settings are:

INSTALLED_APPS += (
    'constance',
    'constance.backends.database',
)

TEMPLATE_CONTEXT_PROCESSORS += (
    # django-constance context processors
    'constance.context_processors.config',
)

CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
CONSTANCE_DATABASE_PREFIX = 'constance:chap:'
# allow only SUPER USERS to change settings by the admin interface
CONSTANCE_SUPERUSER_ONLY = True

Can you help me with this issue?

Can we have validations?

For example if you need to validate a range in a setting, we should be able to add a validation before the setting is saved.

@jezdez what do you think?

Route /admin/constance gives 500

When I go to /admin/constance it gives 500 error:

AttributeError at /admin/constance/
'Meta' object has no attribute 'concrete_model'
Request Method: GET
Request URL: http://192.168.50.100:8000/admin/constance/
Django Version: 1.5.5
Exception Type: AttributeError
Exception Value:
'Meta' object has no attribute 'concrete_model'
Exception Location: /var/www/project/venv/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py in _get_opts, line 22

Using Django-CMS 2.4.3 and pretty much the default admin that comes with it.

Going to http://192.168.50.100:8000/admin/constance/config/ is fine - configs are visible and editable. Any ideas?

Gevent support

Hi,

During usage of django-constance in our project I realized db backend uses db_cache as a global and causes gevent to attempt reading wrong values when project is run as threaded. Both tested with gunicorn + gevent and eventlet. Here is the error:

This socket is already used by another greenlet: <bound method Waiter.switch of <gevent.hub.Waiter object at 0x57536e0>>
constance/backends/database/init.py ? in get (application)
value = db_cache.get(key)

Which leeds to read wrong values and crashes the view.

Solution:
I have moved db_cache variable under DatabaseBackend class and moved its initializations under class init. Renamed all db_cached to self.db_cached and so on. This helped to create connection each time a constance wanted, which is inefficient but solved the errors. Didn't send pull request as I use fairly old version of django-constance but I see code in the repo still contains the same error.

Thanks

Update: that didn't actually solved the problem, so thinking on creating a test for gevent

AppRegistryNotReady on Django 1.7rc2

I'm gettting the following traceback when starting runserver on Django 1.7rc2.

Traceback (most recent call last):
  File "./testapp/manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/media/Files/projects/testapp/env/src/django/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/media/Files/projects/testapp/env/src/django/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/media/Files/projects/testapp/env/src/django/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/media/Files/projects/testapp/env/src/django/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/media/Files/projects/testapp/env/src/django/django/apps/config.py", line 112, in create
    mod = import_module(mod_path)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/media/Files/projects/testapp/env/src/django-constance/constance/apps.py", line 5, in <module>
    class ConstanceConfig(AppConfig):
  File "/media/Files/projects/testapp/env/src/django-constance/constance/apps.py", line 7, in ConstanceConfig
    verbose_name = _('Constance')
  File "/media/Files/projects/testapp/env/src/django/django/utils/translation/__init__.py", line 83, in ugettext
    return _trans.ugettext(message)
  File "/media/Files/projects/testapp/env/src/django/django/utils/translation/trans_real.py", line 325, in ugettext
    return do_translate(message, 'ugettext')
  File "/media/Files/projects/testapp/env/src/django/django/utils/translation/trans_real.py", line 306, in do_translate
    _default = translation(settings.LANGUAGE_CODE)
  File "/media/Files/projects/testapp/env/src/django/django/utils/translation/trans_real.py", line 209, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/media/Files/projects/testapp/env/src/django/django/utils/translation/trans_real.py", line 189, in _fetch
    "The translation infrastructure cannot be initialized before the "
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

_prefix not set in backends/database/__init__.py

I am not entirely sure wether it is an actual bug or I misused your app:

After installing and configuring constance to use the database, django told me that the attribute _prefix did not exist. After looking a bit into the code I added

self._prefix=settings.DATABASE_PREFIX

to DatabaseBackend.init . Now it works.

how to turn off a feature from node.js redis?

I'd like to turn off a feature (by unsetting a constance value in redis)

I'm doing it from node.js.

It seems constance uses python pickle's dump to store truth value.
Isn't the dumped value supposed to change as pickle changes with python version?

How should I toggle truth values from outside of python world?

I'm setting I00\n. for False value. Does this look ok?

Grappelli template

I have modified Constance template to work with Grappelli 2.4.0 stylesheet. It could be useful for somebody else. Though I don't know what would be the best approach for sharing it.

Admin doesn't get Config instance

This Error occurs when /admin/constance/config/ is called.
With 0b05471 and django 1.7b4

Exception Type: AttributeError
Exception Value: 'module' object has no attribute '_backend'

Verbose Name and Grouping/Fieldset

Hi all,

for usability reasons, it would be nice to be able to add a verbose name (that could then also be translatable) and a group name for display as part of a fieldset.

Regards,
Juergen

Choice field?

Just stumbled across this library today, this is exactly what I went in search of, thanks for releasing this.

I'm stilling getting ramped up so apologies if this was covered, but I couldn't find it. I see you support different data types, and render accordingly in the Admin (awesome!!). I was hoping to setup on of my configuration options as a choice, allowing someone to pick one value from a list of choices (as opposed to a text box where they might typo it). Is this possible? If not no biggie, I can work around it, but would be awesome if it was there already.

Thanks

SaaS app and changing settings in settings.py

I know there was a rejected support request for this ... but what about a different approach?

I need to change things like EMAIL_SUBJECT_PREFIX, GRAPPELLI_ADMIN_TITLE ... can we not extend django.conf to use the settings.py as a default but load/replace the custom value from Constance at runtime?

install problem (win)

When I try to install django-constance use
pip install django-constance or pip install -e git+git://github.com/comoga/django-constance#egg=django-constance
ог use git clone and python setup.py install,
I see the same install error
log:

c:\Temp\django-constance>python setup.py install
running install
running bdist_egg
running egg_info
writing django_constance.egg-info\PKG-INFO
writing top-level names to django_constance.egg-info\top_level.txt
writing dependency_links to django_constance.egg-info\dependency_links.txt
reading manifest file 'django_constance.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
Traceback (most recent call last):
File "setup.py", line 36, in
test_suite='tests.runtests.main',
File "c:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "c:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "c:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\Python27\lib\site-packages\setuptools\command\install.py", line 76, i
n run
self.do_egg_install()
File "c:\Python27\lib\site-packages\setuptools\command\install.py", line 96, i
n do_egg_install
self.run_command('bdist_egg')
File "c:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "c:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\Python27\lib\site-packages\setuptools\command\bdist_egg.py", line 167
, in run
self.run_command("egg_info")
File "c:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "c:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\Python27\lib\site-packages\setuptools\command\egg_info.py", line 177,
in run
self.find_sources()
File "c:\Python27\lib\site-packages\setuptools\command\egg_info.py", line 252,
in find_sources
mm.run()
File "c:\Python27\lib\site-packages\setuptools\command\egg_info.py", line 308,
in run
self.read_template()
File "c:\Python27\lib\site-packages\setuptools\command\sdist.py", line 162, in
read_template
sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close()
File "c:\Python27\lib\distutils\text_file.py", line 128, in close
self.file.close ()
AttributeError: 'NoneType' object has no attribute 'close'

Request for feedback: Image support

I often have settings like company_logo that are images. They match the constance work flow perfectly except there is no admin user way to add a custom image. It would need to

  • Use django admin image widget
  • Not break non database backends (not sure if that would really be an issue or not)
  • Would need to have a way to use defaults. How would the default be included in the project. Commit /media maybe? Alternatively we could say no out of box default image support and suggest developers assume '' means use the default.

Alternatives:

  • normal settings.py (not end user customization nor multi tenant)
  • Custom django model for images (then why use constance in the first place)
  • Paste in a url to the image in constance (Not possible to upload the image with just django admin)

bug in admin when constance is saved

I have found in django admin, when you save constance of project, I have all time form.is_valid() is False. Although I check function clean_version it's not call, I think problem when start init fields in __init__ method, with different types, and there is error, when we call form.is_valid(). I think need review all form fields and check it. My problem happens when I have only int type in CONSTANCE_CONFIG dictionary.

Error on start

Hi there

I tried using django-constance on a fresh Django (1.2.5) project with redis (2.2.2) and redispy (2.2.2) and i get following error:

http://dpaste.com/489125/

Am I missing something ?

#68 haven't finished 1.7 compatibility

Because
Now code from constance import config sometimes imports constance/config.py insteda of config object because of django registry code init apps in alphabetical order:

# django/apps/registry.py:105
...
# Load models.
for app_config in self.app_configs.values():
    all_models = self.all_models[app_config.label]
    app_config.import_models(all_models)
...

So constance is being inited config after import in apps thats inited before.

Temporary solution is to use constance like:

import constance
...

print constance.config.some_var

1.7 issue NameError: name 'config' is not defined

Investigating now. If I break where it errors I'm able to run this to make it work

from django.utils.functional import SimpleLazyObject
from constance import Config
config = SimpleLazyObject(Config)

Here is the stacktrace

Traceback (most recent call last):
File "manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
  utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
  django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
  apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
  app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, in import_models
  self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
  __import__(name)
File "/code/ecwsp/grades/models.py", line 6, in <module>
  from ecwsp.sis.models import Student, GradeScaleRule
File "/code/ecwsp/sis/models.py", line 10, in <module>
  from constance import config
ImportError: cannot import name config

Accepting pull requests

Are you accepting pull requests anymore? It looks like you have 2 requests that every other fork is having to implement.

  • Django 1.4 compat
  • Allow empty textfields

Could you accept these or mention why they arent acceptable so we can alleviate the need for all these forks?

Have a good one, thanks man!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.