django-settings2 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hiep Ho Minh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-settings2
3
+ Version: 1.0.0
4
+ Summary: A simple Django app to store and retrieve application settings in the database
5
+ Author-email: Hiep Ho Minh <hiephm@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Hiep Ho Minh
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/hiephm/django-settings2
29
+ Project-URL: Issues, https://github.com/hiephm/django-settings2/issues
30
+ Keywords: django,settings,configuration,database
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Environment :: Web Environment
33
+ Classifier: Framework :: Django
34
+ Classifier: Framework :: Django :: 3.2
35
+ Classifier: Framework :: Django :: 4.0
36
+ Classifier: Framework :: Django :: 4.1
37
+ Classifier: Framework :: Django :: 4.2
38
+ Classifier: Framework :: Django :: 5.0
39
+ Classifier: Intended Audience :: Developers
40
+ Classifier: License :: OSI Approved :: MIT License
41
+ Classifier: Operating System :: OS Independent
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3.6
44
+ Classifier: Programming Language :: Python :: 3.7
45
+ Classifier: Programming Language :: Python :: 3.8
46
+ Classifier: Programming Language :: Python :: 3.9
47
+ Classifier: Programming Language :: Python :: 3.10
48
+ Classifier: Programming Language :: Python :: 3.11
49
+ Classifier: Programming Language :: Python :: 3.12
50
+ Classifier: Topic :: Internet :: WWW/HTTP
51
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
52
+ Requires-Python: >=3.6
53
+ Description-Content-Type: text/markdown
54
+ License-File: LICENSE
55
+ Requires-Dist: Django>=3.2
56
+ Dynamic: license-file
57
+
58
+ # django-settings2
59
+
60
+ A simple Django app to store and retrieve application settings in the database.
61
+
62
+ ## Requirements
63
+
64
+ - Python >= 3.6
65
+ - Django >= 3.2
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ pip install django-settings2
71
+ ```
72
+
73
+ ## Configuration
74
+
75
+ ### Add to `INSTALLED_APPS`
76
+
77
+ ```python
78
+ INSTALLED_APPS = [
79
+ ...
80
+ "django_settings2",
81
+ ]
82
+ ```
83
+
84
+ ### Run migrations
85
+
86
+ ```bash
87
+ python manage.py migrate
88
+ ```
89
+
90
+ ## Usage
91
+
92
+ ```python
93
+ from django_settings2.models import DjangoSettings
94
+
95
+ # Store a value
96
+ DjangoSettings.set_value("my_key", "hello")
97
+ DjangoSettings.set_value("max_retries", 5, cls=int)
98
+ DjangoSettings.set_value("threshold", 0.75, cls=float)
99
+
100
+ # Retrieve a value
101
+ value = DjangoSettings.get_value("my_key", default="fallback")
102
+
103
+ # Retrieve a JSON value stored as text
104
+ data = DjangoSettings.get_value_json("my_json_key", default={})
105
+
106
+ # Retrieve with row-level lock (useful in transactions)
107
+ data = DjangoSettings.get_value_json("my_json_key", lock=True)
108
+ ```
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,55 @@
1
+ # django-settings2
2
+
3
+ A simple Django app to store and retrieve application settings in the database.
4
+
5
+ ## Requirements
6
+
7
+ - Python >= 3.6
8
+ - Django >= 3.2
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pip install django-settings2
14
+ ```
15
+
16
+ ## Configuration
17
+
18
+ ### Add to `INSTALLED_APPS`
19
+
20
+ ```python
21
+ INSTALLED_APPS = [
22
+ ...
23
+ "django_settings2",
24
+ ]
25
+ ```
26
+
27
+ ### Run migrations
28
+
29
+ ```bash
30
+ python manage.py migrate
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from django_settings2.models import DjangoSettings
37
+
38
+ # Store a value
39
+ DjangoSettings.set_value("my_key", "hello")
40
+ DjangoSettings.set_value("max_retries", 5, cls=int)
41
+ DjangoSettings.set_value("threshold", 0.75, cls=float)
42
+
43
+ # Retrieve a value
44
+ value = DjangoSettings.get_value("my_key", default="fallback")
45
+
46
+ # Retrieve a JSON value stored as text
47
+ data = DjangoSettings.get_value_json("my_json_key", default={})
48
+
49
+ # Retrieve with row-level lock (useful in transactions)
50
+ data = DjangoSettings.get_value_json("my_json_key", lock=True)
51
+ ```
52
+
53
+ ## License
54
+
55
+ MIT
File without changes
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+ from django.contrib import admin
3
+ from .models import DjangoSettings
4
+
5
+
6
+ class DjangoSettingsAdmin(admin.ModelAdmin):
7
+ list_display = ('id', 'key', 'int_val', 'float_val', 'text_val')
8
+ list_display_links = ('key',)
9
+ search_fields = ['key', 'int_val', 'float_val', 'text_val']
10
+
11
+
12
+ admin.site.register(DjangoSettings, DjangoSettingsAdmin)
@@ -0,0 +1,6 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class DjangoSettings2Config(AppConfig):
5
+ default_auto_field = 'django.db.models.BigAutoField'
6
+ name = 'django_settings2'
@@ -0,0 +1,25 @@
1
+ from django.db import migrations, models
2
+
3
+
4
+ class Migration(migrations.Migration):
5
+
6
+ initial = True
7
+
8
+ dependencies = [
9
+ ]
10
+
11
+ operations = [
12
+ migrations.CreateModel(
13
+ name='DjangoSettings',
14
+ fields=[
15
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
16
+ ('key', models.CharField(max_length=100, unique=True)),
17
+ ('int_val', models.IntegerField(blank=True, null=True)),
18
+ ('float_val', models.FloatField(blank=True, null=True)),
19
+ ('text_val', models.TextField(blank=True, null=True)),
20
+ ],
21
+ options={
22
+ 'db_table': 'django_settings2',
23
+ },
24
+ ),
25
+ ]
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ import json
3
+ from django.db import models
4
+
5
+
6
+ class DjangoSettings(models.Model):
7
+ key = models.CharField(max_length=100, unique=True)
8
+ int_val = models.IntegerField(blank=True, null=True)
9
+ float_val = models.FloatField(blank=True, null=True)
10
+ text_val = models.TextField(blank=True, null=True)
11
+
12
+ class Meta:
13
+ db_table = "django_settings2"
14
+
15
+ def __str__(self):
16
+ return '{}'.format(self.key)
17
+
18
+ @staticmethod
19
+ def get_value(key, default=None):
20
+ try:
21
+ setting = DjangoSettings.objects.get(key=key)
22
+ if setting.int_val:
23
+ return setting.int_val
24
+ elif setting.float_val:
25
+ return setting.float_val
26
+ else:
27
+ return setting.text_val
28
+ except Exception:
29
+ return default
30
+
31
+ @staticmethod
32
+ def get_value_json(key, default=None, lock=False):
33
+ try:
34
+ if lock:
35
+ setting = DjangoSettings.objects.select_for_update().get(key=key)
36
+ else:
37
+ setting = DjangoSettings.objects.get(key=key)
38
+ return json.loads(str(setting.text_val))
39
+ except Exception:
40
+ return default
41
+
42
+ @staticmethod
43
+ def set_value(key, value, cls=None):
44
+ setting, created = DjangoSettings.objects.get_or_create(key=key)
45
+ if cls == int:
46
+ setting.int_val = int(value)
47
+ elif cls == float:
48
+ setting.float_val = float(value)
49
+ else:
50
+ setting.text_val = str(value)
51
+ setting.save()
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-settings2
3
+ Version: 1.0.0
4
+ Summary: A simple Django app to store and retrieve application settings in the database
5
+ Author-email: Hiep Ho Minh <hiephm@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Hiep Ho Minh
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/hiephm/django-settings2
29
+ Project-URL: Issues, https://github.com/hiephm/django-settings2/issues
30
+ Keywords: django,settings,configuration,database
31
+ Classifier: Development Status :: 5 - Production/Stable
32
+ Classifier: Environment :: Web Environment
33
+ Classifier: Framework :: Django
34
+ Classifier: Framework :: Django :: 3.2
35
+ Classifier: Framework :: Django :: 4.0
36
+ Classifier: Framework :: Django :: 4.1
37
+ Classifier: Framework :: Django :: 4.2
38
+ Classifier: Framework :: Django :: 5.0
39
+ Classifier: Intended Audience :: Developers
40
+ Classifier: License :: OSI Approved :: MIT License
41
+ Classifier: Operating System :: OS Independent
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3.6
44
+ Classifier: Programming Language :: Python :: 3.7
45
+ Classifier: Programming Language :: Python :: 3.8
46
+ Classifier: Programming Language :: Python :: 3.9
47
+ Classifier: Programming Language :: Python :: 3.10
48
+ Classifier: Programming Language :: Python :: 3.11
49
+ Classifier: Programming Language :: Python :: 3.12
50
+ Classifier: Topic :: Internet :: WWW/HTTP
51
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
52
+ Requires-Python: >=3.6
53
+ Description-Content-Type: text/markdown
54
+ License-File: LICENSE
55
+ Requires-Dist: Django>=3.2
56
+ Dynamic: license-file
57
+
58
+ # django-settings2
59
+
60
+ A simple Django app to store and retrieve application settings in the database.
61
+
62
+ ## Requirements
63
+
64
+ - Python >= 3.6
65
+ - Django >= 3.2
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ pip install django-settings2
71
+ ```
72
+
73
+ ## Configuration
74
+
75
+ ### Add to `INSTALLED_APPS`
76
+
77
+ ```python
78
+ INSTALLED_APPS = [
79
+ ...
80
+ "django_settings2",
81
+ ]
82
+ ```
83
+
84
+ ### Run migrations
85
+
86
+ ```bash
87
+ python manage.py migrate
88
+ ```
89
+
90
+ ## Usage
91
+
92
+ ```python
93
+ from django_settings2.models import DjangoSettings
94
+
95
+ # Store a value
96
+ DjangoSettings.set_value("my_key", "hello")
97
+ DjangoSettings.set_value("max_retries", 5, cls=int)
98
+ DjangoSettings.set_value("threshold", 0.75, cls=float)
99
+
100
+ # Retrieve a value
101
+ value = DjangoSettings.get_value("my_key", default="fallback")
102
+
103
+ # Retrieve a JSON value stored as text
104
+ data = DjangoSettings.get_value_json("my_json_key", default={})
105
+
106
+ # Retrieve with row-level lock (useful in transactions)
107
+ data = DjangoSettings.get_value_json("my_json_key", lock=True)
108
+ ```
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ django_settings2/__init__.py
5
+ django_settings2/admin.py
6
+ django_settings2/apps.py
7
+ django_settings2/models.py
8
+ django_settings2.egg-info/PKG-INFO
9
+ django_settings2.egg-info/SOURCES.txt
10
+ django_settings2.egg-info/dependency_links.txt
11
+ django_settings2.egg-info/requires.txt
12
+ django_settings2.egg-info/top_level.txt
13
+ django_settings2/migrations/0001_initial.py
14
+ django_settings2/migrations/__init__.py
@@ -0,0 +1 @@
1
+ django_settings2
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "django-settings2"
7
+ version = "1.0.0"
8
+ description = "A simple Django app to store and retrieve application settings in the database"
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ authors = [
12
+ { name = "Hiep Ho Minh", email = "hiephm@gmail.com" }
13
+ ]
14
+ requires-python = ">=3.6"
15
+ keywords = ["django", "settings", "configuration", "database"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Environment :: Web Environment",
19
+ "Framework :: Django",
20
+ "Framework :: Django :: 3.2",
21
+ "Framework :: Django :: 4.0",
22
+ "Framework :: Django :: 4.1",
23
+ "Framework :: Django :: 4.2",
24
+ "Framework :: Django :: 5.0",
25
+ "Intended Audience :: Developers",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Operating System :: OS Independent",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.6",
30
+ "Programming Language :: Python :: 3.7",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Topic :: Internet :: WWW/HTTP",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ ]
39
+ dependencies = [
40
+ "Django>=3.2",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/hiephm/django-settings2"
45
+ Issues = "https://github.com/hiephm/django-settings2/issues"
46
+
47
+ [tool.setuptools.packages.find]
48
+ include = ["django_settings2*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+