├── MANIFEST.in ├── README.md ├── django_db_only ├── __init__.py └── conf │ ├── __init__.py │ └── project_template │ ├── core │ ├── __init__.py │ ├── models.py │ └── settings.py │ ├── manage.py │ ├── query_resolver.py │ └── wsgi.py ├── examples ├── #1 - dbhelper │ ├── core │ │ ├── __init__.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ └── __init__.py │ │ ├── models.py │ │ └── settings.py │ ├── db.sqlite3 │ ├── manage.py │ ├── query_resolver.py │ ├── readme.md │ ├── requirements.txt │ └── wsgi.py ├── #2 - dbhelper │ ├── config.py │ ├── core │ │ ├── __init__.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── 0002_user_delete_film.py │ │ │ └── __init__.py │ │ ├── models.py │ │ └── settings.py │ ├── db.sqlite3 │ ├── main.py │ ├── manage.py │ ├── readme.md │ ├── requirements.txt │ └── wsgi.py └── readme.md └── setup.py /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include django_db_only * 2 | recursive-exclude * __pycache__ 3 | recursive-exclude * *.py[co] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /django_db_only/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os, sys 3 | 4 | from django.core.management import execute_from_command_line as django_execute 5 | import django_db_only 6 | 7 | 8 | def show_usage(): 9 | print("Usage: " + os.path.basename(sys.argv[0]) + " startproject [projectname]") 10 | return 11 | 12 | def execute_from_command_line(): 13 | 14 | if len(sys.argv) < 3: 15 | show_usage() 16 | sys.exit(1) 17 | 18 | cmd = sys.argv[1] 19 | if cmd.lower()!="startproject": 20 | show_usage() 21 | sys.exit(1) 22 | 23 | projectname = sys.argv[2] 24 | 25 | sys.argv.append("--template") 26 | templ_path = os.path.join(os.path.dirname(django_db_only.__file__), "conf/project_template") 27 | sys.argv.append(templ_path) 28 | 29 | django_execute(sys.argv) 30 | 31 | return 32 | 33 | -------------------------------------------------------------------------------- /django_db_only/conf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/django_db_only/conf/__init__.py -------------------------------------------------------------------------------- /django_db_only/conf/project_template/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/django_db_only/conf/project_template/core/__init__.py -------------------------------------------------------------------------------- /django_db_only/conf/project_template/core/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models -------------------------------------------------------------------------------- /django_db_only/conf/project_template/core/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = 'django-insecure-ynff)9l#l3xzy$%q)pb24_p#wt#r-dsu$pt%v5jy_gfh4pfzb@' 6 | 7 | DEBUG = True 8 | 9 | INSTALLED_APPS = ( 10 | "core", 11 | ) 12 | 13 | MIDDLEWARE_CLASSES = [] 14 | 15 | DATABASES = { 16 | 'default': { 17 | 'ENGINE': 'django.db.backends.sqlite3', 18 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 19 | } 20 | } 21 | 22 | LANGUAGE_CODE = 'en-us' 23 | TIME_ZONE = 'UTC' 24 | USE_I18N = True 25 | USE_L10N = True 26 | USE_TZ = True 27 | 28 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -------------------------------------------------------------------------------- /django_db_only/conf/project_template/manage.py: -------------------------------------------------------------------------------- 1 | from django.core.management import execute_from_command_line 2 | import os, sys 3 | 4 | if __name__ == "__main__": 5 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 6 | execute_from_command_line(sys.argv) -------------------------------------------------------------------------------- /django_db_only/conf/project_template/query_resolver.py: -------------------------------------------------------------------------------- 1 | import wsgi 2 | from core import models -------------------------------------------------------------------------------- /django_db_only/conf/project_template/wsgi.py: -------------------------------------------------------------------------------- 1 | import os, django 2 | 3 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 4 | django.setup() 5 | -------------------------------------------------------------------------------- /examples/#1 - dbhelper/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/examples/#1 - dbhelper/core/__init__.py -------------------------------------------------------------------------------- /examples/#1 - dbhelper/core/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.0.1 on 2022-07-24 17:21 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Film', 16 | fields=[ 17 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=64)), 19 | ('count', models.IntegerField()), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /examples/#1 - dbhelper/core/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/examples/#1 - dbhelper/core/migrations/__init__.py -------------------------------------------------------------------------------- /examples/#1 - dbhelper/core/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Film(models.Model): 4 | name = models.CharField(max_length=64) 5 | count = models.IntegerField() 6 | 7 | def __str__(self): 8 | return self.name -------------------------------------------------------------------------------- /examples/#1 - dbhelper/core/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = 'django-insecure-ynff)9l#l3xzy$%q)pb24_p#wt#r-dsu$pt%v5jy_gfh4pfzb@' 6 | 7 | DEBUG = True 8 | 9 | INSTALLED_APPS = ( 10 | "core", #hohlagancha app 11 | ) 12 | 13 | MIDDLEWARE_CLASSES = [] 14 | 15 | DATABASES = { 16 | 'default': { 17 | 'ENGINE': 'django.db.backends.sqlite3', 18 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 19 | #hohlagan bazaga sozlang :) 20 | } 21 | } 22 | 23 | LANGUAGE_CODE = 'en-us' 24 | TIME_ZONE = 'UTC' 25 | USE_I18N = True 26 | USE_L10N = True 27 | USE_TZ = True 28 | 29 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -------------------------------------------------------------------------------- /examples/#1 - dbhelper/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/examples/#1 - dbhelper/db.sqlite3 -------------------------------------------------------------------------------- /examples/#1 - dbhelper/manage.py: -------------------------------------------------------------------------------- 1 | from django.core.management import execute_from_command_line 2 | import os, sys 3 | 4 | if __name__ == "__main__": 5 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 6 | execute_from_command_line(sys.argv) -------------------------------------------------------------------------------- /examples/#1 - dbhelper/query_resolver.py: -------------------------------------------------------------------------------- 1 | import wsgi 2 | from core.models import Film 3 | 4 | film = Film(name = "Avatar", count=3) 5 | film.save() 6 | 7 | print(Film.objects.all()) -------------------------------------------------------------------------------- /examples/#1 - dbhelper/readme.md: -------------------------------------------------------------------------------- 1 | > its only one model here called Film 2 | 3 | u can change it and migrate 4 | then freely use 5 | 6 | query_resolver is main thing here 7 | -------------------------------------------------------------------------------- /examples/#1 - dbhelper/requirements.txt: -------------------------------------------------------------------------------- 1 | django-db-only 2 | django -------------------------------------------------------------------------------- /examples/#1 - dbhelper/wsgi.py: -------------------------------------------------------------------------------- 1 | import os, django 2 | 3 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 4 | django.setup() 5 | -------------------------------------------------------------------------------- /examples/#2 - dbhelper/config.py: -------------------------------------------------------------------------------- 1 | import wsgi; from core.models import User 2 | 3 | BOT_TOKEN = "" 4 | 5 | class USER: 6 | def get(self, **kwargs): 7 | user = User.objects.filter( **kwargs ) 8 | if user.exists(): 9 | return user.first() 10 | return False 11 | 12 | def create(self, **kwargs): 13 | user = User( **kwargs ) 14 | try: 15 | user.save(); return True 16 | except Exception as e: 17 | return False 18 | 19 | def delete(self, **kwargs): 20 | user = User.objects.filter( **kwargs ) 21 | if user.exists(): 22 | try: user.delete(); return True 23 | except Exception as e: pass 24 | return False -------------------------------------------------------------------------------- /examples/#2 - dbhelper/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/examples/#2 - dbhelper/core/__init__.py -------------------------------------------------------------------------------- /examples/#2 - dbhelper/core/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.0.1 on 2022-07-24 17:21 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Film', 16 | fields=[ 17 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=64)), 19 | ('count', models.IntegerField()), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /examples/#2 - dbhelper/core/migrations/0002_user_delete_film.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.0.1 on 2022-07-25 04:02 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('core', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='User', 15 | fields=[ 16 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('userId', models.IntegerField()), 18 | ('name', models.CharField(max_length=64)), 19 | ('username', models.CharField(max_length=64)), 20 | ], 21 | ), 22 | migrations.DeleteModel( 23 | name='Film', 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /examples/#2 - dbhelper/core/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/examples/#2 - dbhelper/core/migrations/__init__.py -------------------------------------------------------------------------------- /examples/#2 - dbhelper/core/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class User(models.Model): 4 | userId = models.IntegerField() 5 | name = models.CharField(max_length=64) 6 | username = models.CharField(max_length=64) 7 | 8 | def __str__(self): 9 | return self.name -------------------------------------------------------------------------------- /examples/#2 - dbhelper/core/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = 'django-insecure-ynff)9l#l3xzy$%q)pb24_p#wt#r-dsu$pt%v5jy_gfh4pfzb@' 6 | 7 | DEBUG = True 8 | 9 | INSTALLED_APPS = ( 10 | "core", #hohlagancha app 11 | ) 12 | 13 | MIDDLEWARE_CLASSES = [] 14 | 15 | DATABASES = { 16 | 'default': { 17 | 'ENGINE': 'django.db.backends.sqlite3', 18 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 19 | #hohlagan bazaga sozlang :) 20 | } 21 | } 22 | 23 | LANGUAGE_CODE = 'en-us' 24 | TIME_ZONE = 'UTC' 25 | USE_I18N = True 26 | USE_L10N = True 27 | USE_TZ = True 28 | 29 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -------------------------------------------------------------------------------- /examples/#2 - dbhelper/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abrorbekuz/django-db-only/453acb0664db9aebe3d5f0862695e99e56299324/examples/#2 - dbhelper/db.sqlite3 -------------------------------------------------------------------------------- /examples/#2 - dbhelper/main.py: -------------------------------------------------------------------------------- 1 | import telebot, config 2 | 3 | bot = telebot.TeleBot(config.BOT_TOKEN) 4 | users = config.USER() 5 | 6 | 7 | @bot.message_handler(commands=['help', 'start']) 8 | def send_welcome(message): 9 | if users.get(userId = message.from_user.id): 10 | bot.reply_to(message, "Salom do'stim") 11 | else: 12 | user = users.create( 13 | userId = message.from_user.id, 14 | name = message.from_user.first_name, 15 | username = message.from_user.username 16 | ) 17 | if user: 18 | bot.reply_to(message, "Salom yangi do'stim") 19 | else: print("err") 20 | 21 | bot.infinity_polling() -------------------------------------------------------------------------------- /examples/#2 - dbhelper/manage.py: -------------------------------------------------------------------------------- 1 | from django.core.management import execute_from_command_line 2 | import os, sys 3 | 4 | if __name__ == "__main__": 5 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 6 | execute_from_command_line(sys.argv) -------------------------------------------------------------------------------- /examples/#2 - dbhelper/readme.md: -------------------------------------------------------------------------------- 1 | > heres some code actually thats welcomer bot 2 | 3 | it checks user exists in db and welcomes 4 | otherwise it creates another object -------------------------------------------------------------------------------- /examples/#2 - dbhelper/requirements.txt: -------------------------------------------------------------------------------- 1 | django-db-only 2 | django 3 | pytelegrambotapi -------------------------------------------------------------------------------- /examples/#2 - dbhelper/wsgi.py: -------------------------------------------------------------------------------- 1 | import os, django 2 | 3 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") 4 | django.setup() 5 | -------------------------------------------------------------------------------- /examples/readme.md: -------------------------------------------------------------------------------- 1 | > these are example codes with pytelegrambotapi 2 | 3 | use it wisely -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | EXCLUDE_FROM_PACKAGES = [ 4 | 'django_db_only.conf.project_template', 5 | ] 6 | 7 | setup( 8 | name='django_db_only', 9 | version='0.0.1', 10 | description='Django models as standalone app.', 11 | long_description='Django models as standalone app.', 12 | author='Abror Qodirov', 13 | author_email='splayerme@gmail.com', 14 | license='BSD', 15 | packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES), 16 | entry_points={'console_scripts': [ 17 | 'django_db_only = django_db_only:execute_from_command_line', 18 | ]}, 19 | url='http://github.com/abrorbekuz/django_db_only', 20 | include_package_data=True, 21 | install_requires=[ 22 | 'django', 23 | ], 24 | classifiers=[ 25 | "Programming Language :: Python", 26 | "License :: OSI Approved :: BSD License", 27 | "Development Status :: Beta", 28 | "Operating System :: OS Independent", 29 | "Framework :: Django", 30 | "Intended Audience :: Developers", 31 | "Topic :: Internet :: WWW/HTTP :: Dynamic Content", 32 | ], 33 | zip_safe=False, 34 | 35 | 36 | ) 37 | --------------------------------------------------------------------------------