Changes between Initial Version and Version 1 of Ticket #33297, comment 4
- Timestamp:
- Apr 5, 2022, 8:56:19 AM (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #33297, comment 4
initial v1 6 6 1. Create models. 7 7 2. Import models by setting up Django in any python module 8 9 {{{ 8 10 os.environ['DJANGO_SETTINGS_MODULE'] = 'ServiceName.settings' 9 11 django.setup() 10 12 from ServiceName.models import ModelName 11 13 14 }}} 15 12 16 3. Use models via django ORM to fetch some data from DB on service startup(lets call it step 1) and later on by some triggers(lets call it step 2). In my case data is fetched once on startup, and all the subsequent times on certain Kafka event. 13 17 e.g. 18 19 {{{ 14 20 query_results = ModelName.objects.filter(your_filter=some_value) 21 }}} 22 15 23 16 24 4. Shutdown PostgreSQL instance after step one, but before step 2