Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
try to update a my Cart with django, but i don't know whats im implementing wrong here
Django version = 4.0.4 Python == 3.9.12 os = osx here is my cart template, where I use a template tag to get access to my Order instance data for render it <div class="block-cart action"> <a class="icon-link" href="{% url 'core:cart' %}"> <i class="flaticon-shopping-bag"></i> <span class="count">{{ request.user|cart_item_count }}</span> <span class="text"> <span class="sub">Carrito:</span> Gs.{{ request.user|cart_total_count }} </span> </a> <div class="cart"> <div class="cart__mini"> <ul> <li> <div class="cart__title"> <h4>Carrito</h4> <span>( {{ request.user|cart_item_count }} Item en el carrito)</span> </div> </li> {% if request.user|cart_total_items != 0 %} {% for order_item in request.user|cart_total_items %} <li> <div class="cart__item d-flex justify-content-between align-items-center"> <div class="cart__inner d-flex"> <div class="cart__thumb"> <a href="product-details.html"> <img src="{{ order_item.item.image.url }}" alt=""> </a> </div> <div class="cart__details"> <h6><a href="product-details.html">{{ order_item.item.title }}</a></h6> <div class="cart__price"> <span>Gs. {% if order_item.item.discount_price|stringformat:".0f" %} {{ order_item.item.discount_price|stringformat:".0f" }} {% else %} {{ order_item.item.price|stringformat:".0f" }} {% endif %} x {{order_item.quantity}}</span> </div> </div> </div> <div class="cart__del"> <a href="{% url 'core:remove-from-cart-from-home' order_item.item.id%}"><i class="fal fa-times"></i></a> </div> </div> </li> {% endfor %} {%else%} {% endif %} <li> <div class="cart__sub d-flex justify-content-between align-items-center"> <h6>Subtotal</h6> <span class="cart__sub-total">Gs.{{ request.user|cart_total_count }}</span> </div> </li> <li> <a href={% url 'core:cart' %} class="wc-cart mb-10">Ver Carrito</a> <a href={% url 'core:checkout' %} class="wc-checkout">Finalizar Compra</a> </li> </ul </div> </div> here is the custom template tag @register.filter def cart_item_count(user): if user.is_authenticated: … -
How to have an object's pk as an integer?
I have this model: class Class(models.Model): class_id = models.IntegerField(blank=False) def save(self, *args, **kwargs): self.class_id = self.pk+1000 super(Class, self).save(*args, **kwargs) As you can see, I want pk to be added to 1000 and use that as class_id value. But I get this error: TypeError at /new-class unsupported operand type(s) for +: 'NoneType' and 'int' How can I have the pk as an integer? -
Django Admin: How to check TabularInline model field value
I want to check the value filled by user in Django Admin for TabularInline model. Maybe above sentence does not makes sense, if yes, please ignore above sentence, and below is more explanation to my requirement. My model has 2 classes (Filter and FilterCondA) as below: Filter has name of filter and id. class Filter(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) filter_name = models.CharField(max_length=32, unique=True, verbose_name=_("Name")) And FilterCondA has class FilterCondA(models.Model): DEVICE_FIELD = ((A, 'A'), (B, 'B'), (C, 'C'), (D, 'D')) opt_contains, opt_exact, opt_startswith, opt_endswith = 'contains', 'exact', 'startswith', 'endswith' OPERATORS = ((opt_contains, 'Contains'), (opt_exact, 'Exact'), (opt_startswith, 'Startswith'), (opt_endswith, 'Endswith')) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) fconda_filter = models.ForeignKey(Filter, null=True, blank=True, verbose_name=_('Filter')) fconda_field = models.CharField(max_length=512, choices=DEVICE_FIELD, blank=False, verbose_name=_("Device Field")) fconda_logic_op = models.CharField(max_length=16, choices=OPERATORS, blank=False, verbose_name=_("Operator")) fconda_value = models.CharField(max_length=64, null=True, blank=False, verbose_name=_("Value")) fconda_neg = models.BooleanField(null=False, blank=False, default=False, verbose_name=_("Negate")) UI looks like as below: ========================================= admin.py looks like as below: class FilterCondAAdmin(admin.TabularInline): model = FilterCondA class FilterAdmin(admin.ModelAdmin): inlines = [FilterCondAAdmin] I want to check that user has added any conditions or not in filter or blank filter has been created. I want to stop user 2from creating blank filter. Thanks in advance -
Database not exist in docker compose on windows debian subsystem
I want to try to dockerize my Django project, but I face a problem that the database doesn't exist. I run docker on WSL2. I use PostgreSQL. -
iframe refused to connect in django 4.0.2 template
I tried to add iframe to my template in django but it shows me this error: I tried to add X_FRAME_OPTIONS = 'SAMEORIGIN' to my settings.py like explained here: https://docs.djangoproject.com/en/4.0/ref/clickjacking/ but it didn't work, any idea ? Screen Shot my settings.py from pathlib import Path MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] X_FRAME_OPTIONS = 'SAMEORIGIN' -
How to import apps in django from parent directory of manage.py
I have project structure as below: |-Project/ | |-apps/ | | |-notes/ | | |-todo/ | |server/ | | |-api/ | | |-manage.py I want to import apps from ./apps/ folder; tried relative imports with ".." but it doesn't work... eg. INSTALLED_APPS = [ "" '..apps.notes', "" ] how to make parent directory of manage.py as root directory for app imports? -
How can we automate migrations for multiple database in django?
I am working with mult-tenant setup in django.I have multiple databases for which I am looking for a way to run a migration across all the databases linked in my settings.py file in one go. Currently, I have to do "python manage.py makemigrations --database=db_name " for all the databases one by one. -
Is there a way to change the autogenerated shema name of a serializer in drf-spectacular
I got many serializers named 'InputSerializer' and 'OutputSerializer' which translates to 'Input' and 'Output' schema name in drf-spectacular. This ends up referring the api endpoints to the same schema. Is there a way to override the autogenerated schema names of these serializers without changing the name of the class? -
Connect webRTC javascript to Django
My question is: How can I send my webRTC audio and video data to Django server and then apply some ML operations. I can successfully create a P2P connection in webRTC using Django channels for communicating between two clients. Any suggestions or solutions are highly respected -
How to use multi-level {%url%} with Django in HTML template - Class Based Views
Im utilizing class based views: I have an app that has 2 sublevels urls files and 1 view file portfolio_menu.urls: app_name = 'portfolio' urlpatterns = [ path('test', include('store.urls', namespace='store')), path('', views.menu), ] store.urls: app_name = 'store urlpatterns = [ path('', include('product.urls', namespace='product')), ] product.urls: app_name = 'product' urlpatterns = [ path('', views.ProductListView.as_view(), name='list'), ] the funcion I want to get, but don't know the sintax: <a href="{%url portfolio:store:product:list%}"></a> #I wish something like that -
Edit and Add in django
How to allow all fields to be added to the database and only some to be edited in django class PageAdmin(admin.ModelAdmin): list_display = ('rooms', 'first_name', 'last_name', 'visit_date','leave_date','admin') list_filter = ('rooms',) readonly_fields = ('visit_date',) admin.site.site_header = 'Uzbegim' def get_form(self, request, *args, **kwargs): form = super(PageAdmin, self).get_form(request, *args, **kwargs) form.base_fields['admin'].initial = request.user return form (so that after creation it was impossible to edit a certain field) class Rooms(models.Model): objects = None room_num = models.IntegerField(verbose_name='Комната') room_bool = models.BooleanField(default=True,verbose_name='Релевантность') category = models.CharField(max_length=150,verbose_name='Категория') def __str__(self): return f'{self.room_num}' class Meta: verbose_name = 'Комнату' verbose_name_plural = 'Комнаты' class Registration(models.Model): objects = None rooms = models.ForeignKey(Rooms, on_delete=models.CASCADE,verbose_name='Номер',help_text='Номер в который хотите заселить гостя!') first_name = models.CharField(max_length=150,verbose_name='Имя') last_name = models.CharField(max_length=150,verbose_name='Фамилия') admin = models.ForeignKey(User, on_delete=models.CASCADE,verbose_name='Администратор') pasport_serial_num = models.CharField(max_length=100,verbose_name='Серия паспорта',help_text='*AB-0123456') birth_date = models.DateField(verbose_name='Дата рождения') img = models.FileField(verbose_name='Фото документа',help_text='Загружайте файл в формате .pdf') visit_date = models.DateTimeField( default=datetime.datetime(year=year, month=month, day=day, hour=datetime.datetime.now().hour, minute=datetime.datetime.now().minute, second=00,),verbose_name='Дата прибытия') leave_date = models.DateTimeField( default=datetime.datetime(year=year, month=month, day=day + 1, hour=12, minute=00, second=00),verbose_name='Дата отбытия') guest_count = models.IntegerField(default=1,verbose_name='Кол-во людей') room_bool = models.BooleanField(default=False,verbose_name='Релевантность',help_text='При бронирование отключите галочку') -
Can I use any method to choose a specific foreign key like I used while using get in Django?
Can I use any method to choose a specific foreign key like I used while using get? session = StudentReporter.objects.get(pk=pk).session_report.session.pk session_report = StudentReporter.objects.get(pk=pk).session_report.pk studentsession = StudentSessions.objects.filter(session=session).select_related('student', 'session', 'session__teacher', 'session__name', 'session__day') # I tried this for loop but it returns a string not a model instance student = tuple([(student.student,student.student) for student in studentsession]) self.fields['student'] = forms.ChoiceField(choices= student) I want the code to be like that session = StudentReporter.objects.get(pk=pk).session_report.session.pk session_report = StudentReporter.objects.get(pk=pk).session_report.pk # watch the change in the following lines studentsession = StudentSessions.objects.filter(session=session).select_related('student', 'session', 'session__teacher', 'session__name', 'session__day').students self.fields['student'] = forms.ChoiceField(choices= studentsession) as I can use the students in models StudentSessions model in models.py class StudentSessions(models.Model): student = models.ForeignKey(Student, related_name='student_session', on_delete=models.CASCADE) session = models.ForeignKey(Session, related_name='student_session', on_delete=models.CASCADE) class Meta: unique_together = ['student', 'session'] def __str__(self): return f'{self.student.name}, {self.session.teacher}, {self.session.time}, {self.session.name} ' # type: ignore -
data base or text file and excel file in Django
if you have some fixed data in Django, for example, ten rows and 5 columns. Is it better to create a database for it and read it from the database, or is it not good and it is better to create a dictionary and read the data from the dictionary? In terms of speed and logic and ... If the database is not a good choice, should I write the data as a dictionary in View Django or inside a text file or inside an Excel file? Whichever method is better, please explain why. -
django.db.migrations.exceptions.NodeNotFoundError pytest
I have troubles with migrations when i run pytest. Tracebak django.db.migrations.exceptions.NodeNotFoundError: Migration account.0001_initial dependencies reference nonexistent parent node ('auth', '0012_alter_user_first_name_max_length') Migration file: class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0012_alter_user_first_name_max_length'), ('contenttypes', '0002_remove_content_type_name'), ] I try to python manage.py flush and delete all migrations folders. But it doesn't work for my case. Can you give me some advices for this trouble ? -
Javascript remove class="d-none" function not defined HTMLSpanElement.onclick (Uncaught ReferenceError)
I'm trying to link a Javascript remove function (i.e. the ability to hide/unhide a dropdown menu) from a button on my website's navigation bar. When I run my server clicking the button doesn't do anything, and my console is giving me an Uncaught ReferenceError: Uncaught ReferenceError: showNotifications is not defined at HTMLSpanElement.onclick ((index):61:135) social.js: function showNotifications() { const container = document.getElementById('notification-container'); if (container.classList.contains('d-none')) { container.classList.remove('d-none'); } else { container.classList.add('d-none'); } } The HTML document the function is linked to: show_notifications.html: <div class="dropdown"> <span class="badge notification-badge" style="background-color: #d7a5eb;" onclick="showNotifications()">{{ notifications.count }}</span> <div class="dropdown-content d-none" id="notification-container"> {% for notification in notifications %} {% if notification.post %} {% if notification.notification_type == 1 %} <div class="dropdown-item-parent"> <a href="#">@{{ notification.from_user }} liked your post</a> <span class="dropdown-item-close">&times;</span> </div> {% elif notification.notification_type == 2 %} <div class="dropdown-item-parent"> <a href="#">@{{ notification.from_user }} commented on your post</a> <span class="dropdown-item-close">&times;</span> </div> {% endif %} {% elif notification.comment %} {% if notification.notification_type == 1 %} <div class="dropdown-item-parent"> <a href="#">@{{ notification.from_user }} liked on your comment</a> <span class="dropdown-item-close">&times;</span> </div> {% elif notification.notification_type == 2 %} <div class="dropdown-item-parent"> <a href="#">@{{ notification.from_user }} replied to your comment</a> <span class="dropdown-item-close">&times;</span> </div> {% endif %} {% else %} <div class="dropdown-item-parent"> <a href="#">@{{ notification.from_user }} has started … -
ProgrammingError at / relation "website_request" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "website_request"
this is my first deployment to heroku and i am getting the above error, i did everything right, I mean I think so at least and still getting the error. am deploying via heroku CLI -
Cannot locate local path of uploaded file to Heroku from django using ephemeral file system( Web based Application)
I have recently deployed my first django project to Heroku. My project is a Web Based Application that allows users to upload a file to the server and the server will export a product after processing it. The views.py processing the upload process is as follows if form.is_valid(): task= form.save(commit=False) task.task_created_by = request.user task.save() The model is as follows class db(models.Model): created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) description = models.CharField(max_length=255, blank=True) excel = models.FileField(upload_to='task/excel/') userinput = models.FileField(upload_to='task/userinput/') output= models.FileField(blank=True,null=True) uploaded_at = models.DateTimeField(auto_now_add=True) settings.py #Media path setting MEDIA_URL = '/uploaded/' MEDIA_ROOT = os.path.join(BASE_DIR, 'uploaded') Therefore, a part of the server involves accessing the user uploaded file and thus processing it. I did not set up any external file storage service(e.g. aws s3) and is only using the default ephemeral file system. when I first run the application the server response this error No such file or directory: '/app/uploaded/task\\excel\\abc.xlsx' However, as I am using the django model file field, when I go to the django admin panel, it shows the file is uploaded and can be downloaded from the admin panel... Therefore, the question is where did Heroku saved the uploaded file locally... I have tried the heroku run bash method to search for … -
Django arguments '(1, '')' not found. 1 pattern(s) tried:
Error Reverse for 'comment_fix' with arguments '(1, '')' not found. 1 pattern(s) tried: ['comment_fix/(?P[0-9]+)/(?P<comment_id>[0-9]+)\Z'] My problem Why can't I find the information (?P<comment_id>[0-9]+)\Z'? Where can I edit to get information? MY html <div> <form method="POST" action="{% url 'create_comment' post.id %}"> {% csrf_token %} {{ comment_form }} <input type="submit"> {% for i in post.question_set.all %} <p>comment: {{ i.subject }}</p> <p>time: {{ i.created_at }}</p> <a href="{% url 'comment_fix' post.id question.id %}">comment fix</a> <hr> {% endfor %} </form> </div> MY urls urlpatterns = [ path('home/', views.home, name='home'), path('home/top', PostList.as_view(), name='top'), path('home/top/<int:pk>/', views.top_detail, name='top_detail'), path('search/', views.search, name='search'), path('signup/', views.signup, name='signup'), path('login/', auth_views.LoginView.as_view(template_name='main/login.html'), name='login'), path('logout/', auth_views.LogoutView.as_view(), name='logout'), path('create_comment/<int:post_id>', views.create_comment, name='create_comment'), path('comment_fix/<int:pk>/<int:comment_id>', views.comment_fix, name="comment_fix") ] My models class Top(models.Model): product_name = models.CharField(blank=True, null=True, max_length=30) product_price = models.CharField(blank=True, null=True, max_length=30) product_image = models.ImageField(blank=True, null=True, upload_to="images") product_explain = models.TextField(blank=True, null=True, ) class Question(models.Model): post = models.ForeignKey(Top, null=True, on_delete=models.CASCADE) subject = models.CharField(null=True, max_length=150) created_at = models.DateTimeField(auto_now=True) def __str__(self): return self.subject My views def top_detail(request,pk): post = get_object_or_404(Top, pk=pk) post_list = Top.objects.get(pk=pk) comment_form = CommentForm() return render(request, 'main/top_detail.html', {'post':post, 'post_list':post_list,'comment_form':comment_form}) def create_comment(request, post_id): filled_form = CommentForm(request.POST) if filled_form.is_valid(): form = filled_form.save(commit=False) form.post = Top.objects.get(id=post_id) form.save() return redirect('top_detail',post_id) #comment fix @login_required def comment_fix(request, comment_id, pk): question = Question.objects.get(id=comment_id) comment_form = CommentForm(instance=question) … -
Django serializer updation only one column shld have same values and remaining columns shld get new value option to entry for a user
Here i do have some columns called task_name tht should every day update same perivous task_name but task_value shld not update it shld give option to user to enter new task_value and new threshold value my models class SubTask(models.Model): tasks = models.ForeignKey(Task, on_delete=models.CASCADE, related_name='task_regular', null=True, blank=True) task_id = models.AutoField(primary_key=True) regular_task_id = models.PositiveIntegerField(blank=True, null=True) task_name = models.CharField(max_length=200, blank=True, null=True) task_value = models.CharField(max_length=200, blank=True, null=True) created_at = models.DateTimeField(auto_now=True) updated_at = models.DateTimeField(blank=True, null=True) threshold = models.FloatField(blank=True, null=True) views class SubTaskViewSet(viewsets.ModelViewSet): pagination_class = None queryset = SubTask.objects.all() serializer_class = SubTaskSerializer Serializer class SubTaskSerializer(serializers.ModelSerializer): class Meta: model = SubTask fields = '__all__' Let me know which method i need to follow -
passing json from js to views in django
I am trying to pass some data from JavaScript to python views here is my js code sourcejson=JSON.stringify(sourceGoal) jsonmap=JSON.stringify(mapgraph.showNodes()) json=JSON.stringify(straightLineToDestination) $.ajax({ type: "get", url: "", dataType: 'json', data: jsonmap, success: function(response){ graphview.appendChild('<p>'+response.result+'</p>') } }); $.ajax({ type: "get", url: "", dataType: 'json', data: sourceGoal, }); $.ajax({ type: "get", url: "", dataType: 'json', data: straightLineToDestination, }); here is my views.py import imp import json from telnetlib import STATUS from urllib import request from django.shortcuts import render from django.http import HttpResponse import os from django.views.generic import View from queue import PriorityQueue from django.http import JsonResponse class ajaxhandlerview(View): def get(self,request): return render(request,'index.html') def post(self,request): global GRAPH global straight_line global SourceandGoal GRAPH=json.loads(request.Get.get('jsonmap')) straight_line=json.loads(request.Get.get('straightLineToDestination')) SourceandGoal=json.loads(request.Get.get('sourceGoal')) print(GRAPH) print(straight_line) print(SourceandGoal) if request.is_ajax(): heuristic, cost, optimal_path = a_star(SourceandGoal.start, SourceandGoal.end) result=' -> '.join(city for city in optimal_path) return JsonResponse({"heuristic":heuristic,"cost":cost,"optimal_path":optimal_path,"result":result},STATUS=200) return render(request,'index.html') def a_star(source, destination): """Optimal path from source to destination using straight line distance heuristic :param source: Source city name :param destination: Destination city name :returns: Heuristic value, cost and path for optimal traversal """ priority_queue, visited = PriorityQueue(), {} priority_queue.put((straight_line[source], 0, source, [source])) visited[source] = straight_line[source] while not priority_queue.empty(): (heuristic, cost, vertex, path) = priority_queue.get() if vertex == destination: return heuristic, cost, path for next_node in GRAPH[vertex].keys(): current_cost = … -
__init__() got an unexpected keyword argument 'content_type'
I have @action in DRF ModelViewSet which should export data into csv @action (detail = False, methods = ['get']) def export(self,request): csv_response = HttpResponse(content_type='text/csv') csv_response =['Content-Disposition']='attachement; filename="data.csv"' writer = csv.writer(csv_response) row = ','.join(['a','b','c']) writer.writerow(row) return csv_response but this method returns next error : __init__() got an unexpected keyword argument 'content_type' What is the reason and how can I fix it? Thanks in advance -
form.save() not working in django using FileField() in models. Uploaded File is not getting saved in the directory
I am pretty new to Django and am trying to save the uploaded image by the user to a folder. After researching a bit, I learned that form.save() saves the form and the image to my folder. But it isn't working. You might see GridFS codes, it's because I'm also trying to save the uploaded file to the MongoDB database via GridFS. I've mentioned the codes and errors below. I have these lines of code in my views.py file def upload_file(request): if request.method == 'POST': form = UploadFile(request.POST, request.FILES) file = request.FILES['file'] extension = str(file).split('.')[1] img_extension = ['jpeg', 'jpg', 'png', 'tiff', 'raw', 'gif'] video_extension = ['mp4', 'mov', 'wmv', 'avi', 'mkv', 'webm'] if extension in img_extension: if form.is_valid(): form.save() return HttpResponse('Success') return HttpResponse('It is a Image Extension - ' + str(extension)) elif extension in video_extension: if form.is_valid(): form.save() return HttpResponse('Success') return HttpResponse('It is a Video Extension - ' + str(extension)) else: return HttpResponse('Please Upload a proper Image or a Video format') else: form = UploadFile() context = { 'form': form, } return render(request, 'upload.html', context) I have a simple FileField() in the models.py file from django.db import models from django.conf import settings from djongo.storage import GridFSStorage from django.core.files.storage import FileSystemStorage from … -
Mess with models primary key. Django
There are two models: class Parent(models.Model): name = models.CharField(max_length=25) date = models.DateField(default=now) class Child(models.Model): name = models.CharField(max_length=25) quantity = models.DecimalField(max_digits=10, decimal_places=2) parent = models.ForeignKey(Parent, on_delete=models.CASCADE) In my app I have a set (or list) of parents within a set of child elements inside. When I try to delete child element - request redirects me to the wrong parent. Here below my view: def deleteChild(request, pk): child= get_object_or_404(Child, pk=pk) parent= get_object_or_404(Parent, pk=child.parent.pk) if request.method == 'POST': child.delete() return redirect('detail', pk=parent.pk) context = {'parent': parent.pk} return render(request, 'parent-detail.html', context) my url: path('child-delete/<int:pk>', views.deleteChild, name='child-delete'), I assume one of the reasons are - incorrect ID pass... Point me please what is wrong with this and much appreciate to You All if You give me an advice how to correctly prescribe Models for such case (maybe best practice if any). Because I expect same issue when I start doing updateChild view X))). Thanks a lot and have a nice day! -
ReactJS with Django Elements Displayed As Text
I try to get elements inside my div but they are displayed as text and not Elements. I use Django as the back-end and ReactJS as a link import in my HTML template on the front-end. my template is like this: {% load static %} <!DOCTYPE html> <html lang="en"> <head> <script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script> <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin</script> </head> <body> <div id ="form-container"> </div> <!-- Bootstrap JS CDN --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> </body> <script src="{% static '/js/login.js' %}"></script> </html> and my react JS file is like this: const hello = ('<h1>test</h1>'); const root = ReactDOM.createRoot(document.getElementById("form-container")); root.render(hello); Have tried removing the ' ' or the parenthesis but can't get it to work it either it shows invalid syntax. -
Austi updating Django postgres database when changes in legacy database are made in a docker container
I'm working on a Django project with docker which use different legacy Microsoft SQL Server database. Since I didn't want to alter those legacy databases I use inspectdb and Django router to create models and then use the data there to read and write a default Postgres database with all the Django specific tables. Everything was working fine, each instance of my model objects have the initial data from the SQL server db populating into the Postgres db. However whenever anything is updated in the SQL server db the data in the is not updating in Postgres db unless the docker container is stop and restarted. I'm wondering is there a way to autoupdate my postgres db when changes are made in the connected SQL Server db's with stopping the container? Would I need to use something like celery or a cron job to schedule updates? I've used cron jobs before but only to pull from an api. Is it possibly to run celery or a cron job just on a database and not an api? Or is there a solution that's simplier? I'm also running with nginx and gunicorn on an Ubuntu server. Using volumes to persist db.