Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Get the list of a certain column wihout duplicate from model object
I have a model object such as class MyMenu(models.Model): key= m.CharField(max_length=255,unique=True) name = m.CharField(max_length=255) Now there is data like this, key,name a hiro b hiro c fusa d yoshi e yoshio f fusa Now I would like to get the name column without duplication. As a result I would like to get ["hiro","fusa","yoshi","yoshio"] It is possible to do this with for loop, however this way is awkward and slow. Is there any good method to use model object? -
Error while deploying (Not Found The requested resource was not found on this server)
I have deployed a Django-react APP using render.com now the server is live but going into the website https://calendar-app-2lin.onrender.com/only gets this message : in the deployer´s logs I have: here is the repo: https://github.com/SamLCris/calendar_app/blob/master/requirements.txt -
Saving HTML data into JSONField in Django
I have a checksheet with multiple item rows and checkboxes along it. {% for obj in checksheet_items %} <tr class="table-row"> <td class="cell-width"> <p class="cell-content"><span>{{ forloop.counter }}</span></p> </td> <td class="cell-width" colspan="14"> <p class="cell-content text-start"><span>{{ obj.item_name }} {% if obj.checksheet_number == 'E01A ELECTRICAL' and forloop.counter == 14 %} <input class="form-control form-control-sm bg-info" style="width: 50px; display: inline-block;" type="text" name="addition-14" value="{{ check_sheet_data.14.addition }}"><span style="display: inline-block;">M</span>{% endif %}</p> </td> <td class="cell-width text-center"> <input class="exclusive-checkbox-{{ forloop.counter }}" type="checkbox" name="checksheet_{{ checksheet.id }}_ok_{{ forloop.counter }}" id=""> </td> <td class="cell-width text-center"> <input class="exclusive-checkbox-{{ forloop.counter }}" type="checkbox" name="checksheet_{{ checksheet.id }}_na_{{ forloop.counter }}" id=""> </td> <td class="cell-width text-center"> <input class="exclusive-checkbox-{{ forloop.counter }}" type="checkbox" name="checksheet_{{ checksheet.id }}_pl_{{ forloop.counter }}" id=""> </td> </tr> {{ checksheet_data }} {% endfor %} {% block javascript %} <script> document.addEventListener("DOMContentLoaded", function() { {% for obj in checksheet_items %} var checkboxes{{ forloop.counter }} = document.querySelectorAll(".exclusive-checkbox-{{ forloop.counter }}"); checkboxes{{ forloop.counter }}.forEach(function(checkbox) { checkbox.addEventListener("change", function() { checkboxes{{ forloop.counter }}.forEach(function(otherCheckbox) { if (otherCheckbox !== checkbox) { otherCheckbox.checked = false; } }); }); }); {% endfor %} }); </script> {% endblock %} I am storing data in JSONField in my models.py. Everything works fine I am able to save the data by following views.py: if form.is_valid(): check_sheet_data = {} # Initialize a dictionary … -
Djang-admin is not recognized
I am creating a python project , and I am seeing an error saying : The term 'django-admin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again I have installed python is my system and as well as in VS code , I have also added path to enviroment variables , I am unable to find error -
Fields defined in ANNOTATE are not read by UPDATE
Can't Django use fields defined in annotations in updates? Here's the code. code = self.request.user.code product = Products.objects.filter(code=code) with transaction.atomic(): product_aggregated = product.annotate( pamt=Sum("related_name__product_amt"), psum=Sum("related_name__product_sum"), pmax_date=Max("related_name__product_date"), ).exclude(product_amt=F("amt")) This works fine when we try to print it out with print(). for record in product_aggregated: print(record.pamt) print(record.psum) print(record.pmax_date) 10 10000 2023-11-01 07:50:00.632888 However, if you try to update using it, it won't work. product_aggregated.update( product_amt=Subquery( Products.objects.filter(id=OuterRef("id")).values("pamt")[:1] ), product_sum=Subquery( Products.objects.filter(id=OuterRef("id")).values("psum")[:1] ), product_date=Subquery( Products.objects.filter(id=OuterRef("id")).values("pmax_date")[:1] ), ) I get an error like this Cannot resolve keyword 'pamt' into field. Choices are: product_amt, product_sum, product_date ... Can't Django use fields defined in annotations in updates? -
UWSGI Error with Nginx/Django deployment: ModuleNotFoundError: No module named 'web'
I have been trying to solve this for 3 days now. I can not get uwsgi to load my app correctly. I have tried using virtual environments, rebuilding a new EC2 Ubuntu instance, config changes, different versions of uwsgi, but nothing works. I have another working setup that is the exact same, sans versions, EC2, uwsgi, nginx, django. UWSGI should start with my wsgi.py file, but for some reason it seems like it is looking for a python module named "web" which is the name of my django project. Here are the uwsgi logs: Thu Nov 9 14:11:33 2023 - spawned uWSGI worker 1 (pid: 24452, cores: 1) Thu Nov 9 14:17:33 2023 - SIGINT/SIGTERM received...killing workers... Thu Nov 9 14:17:34 2023 - worker 1 buried after 1 seconds Thu Nov 9 14:17:34 2023 - goodbye to uWSGI. Thu Nov 9 14:17:34 2023 - *** Starting uWSGI 2.0.20-debian (64bit) on [Thu Nov 9 14:17:34 2023] *** Thu Nov 9 14:17:34 2023 - compiled with version: 11.2.0 on 21 March 2022 11:00:44 Thu Nov 9 14:17:34 2023 - os: Linux-6.2.0-1015-aws #15~22.04.1-Ubuntu SMP Fri Oct 6 21:37:24 UTC 2023 Thu Nov 9 14:17:34 2023 - nodename: ip-172-31-30-103 Thu Nov 9 14:17:34 2023 … -
Django filter by two fields rangement
I have a model with two fields: min_age, max_age. And I need to filter it with Django Filters by range of two fields. How can I do that? # models.py class AdvertisementModelMixin(models.Model): min_age = models.PositiveSmallIntegerField( blank=True, null=True, validators=[ MaxValueValidator(80) ] ) max_age = models.PositiveSmallIntegerField( blank=True, null=True, validators=[ MaxValueValidator(80) ] ) -
django commands gets stuck when I run makemigrations or createsuperuser etc
I have a Django application, and when I run python manage.py makemigrations The terminal gets stuck and it doesn't show any output and even ctrl + C doesn't work This isn't happening with all commands commands like createsuperuser, flush, makemigrations aren't working but commands like generateschema work I created another django project and tried running these commands and they work. This issue is happening with only this project and it happened suddenly. -
Error while deploying app (ModuleNotFoundError: No module named 'dj_database_url')
I am using render.com for the deployment of my app but I get the following error : (ModuleNotFoundError: No module named 'dj_database_url') why is that? -
Draw form buttons( using helper) after inline formset via crispy
I want my form to have a pair of "edit" and "return" buttons. These buttons should be at the end of the form, right after the formsets, and on the other hand, for some reason, I need the buttons to be created with crispy helper. If the form is drawn as follows, the formsets are placed under the buttons: {% crispy form %} {% for formset in inlines %} {{ formset.management_form }} {% for formss in formset %} {{ formss.management_form }} {% for fields in formss.visible_fields %} {{ fields|as_crispy_field }} {% endfor %} {% endfor %} {% endfor %} If it is drawn as follows, the buttons will not be drawn: {% for fields in form.visible_fields %} {{ fields|as_crispy_field }} {% endfor %} Is it possible to somehow access the helper inside the template and make it draw the pair of buttons? class UpdateStaffForm(forms.ModelForm): class Meta: fields = ['first_name', 'last_name', 'is_staff'] model = User helper = FormHelper() helper.add_input(Submit('submit', 'Edit Staff', css_class='btn-primary')) helper.add_input(Button('back', 'Back', css_class='btn-secondary', onClick="javascript:history.go(-1);")) helper.form_method = 'POST' class UpdateStaffView(NamedFormsetsMixin, UpdateWithInlinesView): template_name = "pages/staff/update.html" model = User form_class = UpdateStaffForm success_url = "/staff/" inlines = [StaffInline, ] -
Celery inspect remove 10 items limit
I need to get the worker queue size using python and Celery. The code works fine, but result is limited to 10 items. Is there any way to get entire list of queued tasks? I get 100+ items, but only 10 are being returned res = i.reserved() # Names of tasks reserved by the worker reserved_count = len(res[queue_name]) Entire code: app = Celery('myapp', broker='redis://redis:6379/0') # Tist of queue names to inspect queue_names = ['celery@worker.photos', 'celery@worker.videos'] queue_info = {} # Iterate through the queue names for queue_name in queue_names: i = app.control.inspect([queue_name]) a = i.active() # Names of tasks currently being executed by the worker active_count = len(a[queue_name]) res = i.reserved() # Names of tasks reserved by the worker reserved_count = len(res[queue_name]) pretty_queue_name = queue_name.replace('celery@worker.', '') queue_info[pretty_queue_name] = { 'active': active_count, 'reserved': reserved_count, 'total': active_count + reserved_count } return queue_info -
Django Routes intercepting api request and serving index page
I have a urls.py file with the following routes from django.contrib import admin from django.urls import path, include, re_path from rest_framework import routers from .core import views from django.shortcuts import render from .core.views import index as index_view def render_react(request): return render(request, "index.html") router = routers.DefaultRouter() router.register(r'site',views.SiteViewSet,'site') router.register(r'sitestatus',views.SiteStatusView,'sitestatus') router.register(r'lender',views.LenderView,'lender') router.register(r'job',views.JobView,'job') router.register(r'admin_view',views.AdminUploadView,'admin_view') router.register(r'site_geography',views.SiteGeographyView,'site_geography') urlpatterns = [ path('login/', views.ObtainAuthToken.as_view()), path('admin/', admin.site.urls), path('api/', include(router.urls)), re_path(r'^.*$', render_react), re_path(r"^(?:.*)/?$", render_react), # path('',render_react), ] Since serving the static react files via Django with the addition of re_path...xxx it is loading some pages (if supporting data is made with POST requests) but other pages that require api data from the /api route are being intercepted and served the render_react index.html file not the appropriate Api data I've tried changing the order but I expect that when a request is made to the /api route it correctly calls the api urls and is not served the html. -
Updating an auto_now DateTimeField in a parent model in Django Framework
I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message to now. Here's my code: def save(self): super(Attachment, self).save() self.message.updated = self.updated Will this work, and if you can explain it to me, why? If not, how would I accomplish this? -
ValueError: time data '2023-12-10' does not match format '%Y-%m-%d %H:%M:%S.%f'
While working with django, I am getting this error with expiry_date field declared as DateFeild in model. What should I do to resolve the error? I tried a lot but didn't get the solution. I imported datetime.datetime, etc. but still the error is not resolved. -
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Why does it trying to connect to localhost when I directly specified "db" as HOST? docker-compose.yml services: web-app: build: . ports: - "8000:8000" volumes: - ./myapp:/myapp command: > sh -c "python manage.py runserver 0:8000" db: image: postgres:13-alpine volumes: - ./myapp_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - POSTGRES_DB=Test_overflow_db settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'Test_overflow_db', 'USER': 'postgres', 'PASSWORD': 'postgres', 'HOST': 'db', 'PORT': 5432, } } Also once I had slightly different error django.db.utils.OperationalError: connection to server at db ("172.20.0.2"), port 5432 failed: Connection refused, but I tried some stuff after and this has never shown again -
Unnecessary filter code execution in custom filter class
Issue-1 Even if we don't pass any tag in the request query the function datasetfiletagsquery gets executed Issue-2 If I set dataset_id as required then it is enforced in retrieve and other action api functions as well. Context I need to make dataset_id as the required query only when tag query is passed in the request Code class DatasetFileViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, GenericViewSet): class DatasetFileFilter(filters.FilterSet): def datasetfiletagsquery(request): try: dataset_id = request.query_params['dataset_id'] qs = Tag.objects.filter(object_id=dataset_id, content_type=ContentType.objects.get_for_model(Dataset), category=Tag.CategoryChoices.DATASET_FILE) except KeyError: raise serializers.ValidationError({'dataset_id': 'This query is required'}) return qs def datasetfiletagsfilter(queryset, name, value): tag_ids = [tag.pk for tag in value] qs = queryset.filter_by_tags(tag_ids) return qs dataset_id = filters.NumberFilter() tag = filters.ModelMultipleChoiceFilter(queryset=datasetfiletagsquery, to_field_name='name', method=datasetfiletagsfilter) class Meta: model = DatasetFile fields = ['dataset_id', 'tag'] queryset = DatasetFile.objects.prefetch_related('tags', 'related_child_dataset_files__child').select_related('datasetbatchfile').extend_order_by() serializer_class = DatasetFileSerializer filterset_class = DatasetFileFilter def get_queryset(self): if self.action == 'download': qs = DatasetFile.objects.all() else: qs = super().get_queryset() qs = qs.filter(dataset__organization_id=self.request.user.organization_id) return qs @action(methods=['POST'], detail=True, url_path='download', serializer_class=DatasetFileDownloadSerializer) def download(self, request, pk): """ api for downloading dataset file """ instance = self.get_object() instance = instance.dataset.get_datasetfiles_for_download(datasetfile_ids=[instance.pk])[0] serializer = self.get_serializer(instance) return Response(serializer.data, status=status.HTTP_200_OK) Expected execution for issue 1 The datasetfiletagsquery function should not be executed if no tag query is present in the request Expected execution for issue 2 The required … -
Add extra action flag to LogEntry in Django
I am registering a custom Log Entry model to django admin Panel. This is the code: class CustomLogEntryAdmin(admin.ModelAdmin): list_display = [ "action_time", "user", "content_type", "shortIds", "object_repr", "action_flag", "shortMessage", ] def shortIds(self, obj): return Truncator(obj.object_id).chars(30) shortIds.short_description = "Object ID" def shortMessage(self, obj): return Truncator(obj.change_message).chars(60) shortMessage.short_description = "Change Message" # list filter list_filter = ["action_time", "user", "content_type"] # search search_fields = ["user__username", "object_repr"] admin.site.register(LogEntry, CustomLogEntryAdmin) there are 3 default action flags of LogEntry ADDITION: int CHANGE: int DELETION: int I want to add a 4th action flag called 'VIEW'. How do I do it? Any help would be appreciated. -
DB architecture of instagram stories like service
Need to create instagram stories like service. I use django rest framework and postgresql as primary db. I stuck with db architecture for stories. I have an idea like: from django.db import models from django.contrib.auth import get_user_model User = get_user_model() class Story(models.Model): created_at = models.DateTimeField(auto_now_add=True) expire_at = models.DateTimeField() preview = models.OneToOneField('StoryContent') class StoryContent(models.Model): media = models.FileField() duration = models.IntegerField() story = models.ForeignKey(Story) class StoryWatched(models.Model): storyfile = models.ForeignKey(StoryContent) user = models.ForeignKey(User) is_watched = models.BooleanField() watched_at = models.DateTimeField(auto_now_add=True) This is just basic implementation and in models will be extra fields. How to optimize user watched stories table. Let's suppose i have a 100.000 users and they watch 1 story with 4 files in it, it makes 400.000 rows in table story_watched. If there better db architectural solutions you can imagine pls help) -
How do I use TokenObtainPairView to don't return tokens for a class I created myself (inherited from AbstractUser)?
I've created a class that inherits from django's built-in user, which is successful when I want to create a new user by request. But when I access a token using the TokenObtainPairView view, it prompts "{ "detail": "Can't find a valid user for the specified credentials" }". I have configured JWT in the setting: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': 10, 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ), } SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(days=7), 'REFRESH_TOKEN_LIFETIME': timedelta(days=7) } In the meantime, my model is as follows: class User(AbstractUser): user_avatar = models.ImageField(null=False, blank=True, default='NONE', upload_to=user_avatar_path, validators=[FileExtensionValidator(allowed_extensions=['jpg', 'jpeg', 'png'])]) user_gender = models.CharField(null=True, blank=True, default='NONE', max_length=10, choices=GENDER_CHOICE) user_created_at = models.DateTimeField(auto_now_add=True) user_updated_at = models.DateTimeField(auto_now=True) class Meta: db_table = 'users' verbose_name = "user_table" ordering = ['user_created_at'] def __str__(self): return f"User({self.id}->{self.username})" def __repr__(self): return self.__str__() My url configuration is as follows: urlpatterns = [ path('login/', LoginView.as_view()), path('register/', RegisterView.as_view()), path('password/', PasswordView.as_view()), path('infomation/', UserView.as_view()), path('infomation/<int:pk>', UserDetailView.as_view()), path('token/', TokenObtainPairView.as_view()), path('token/refresh/', TokenRefreshView.as_view()), ] My Serializer is as follows: class LoginTokenObtainPairSerializer(TokenObtainPairSerializer): def validate(self, attrs): data = super().validate(attrs) data['username'] = self.user.username return data class UserSerializer(serializers.Serializer): username = serializers.CharField(min_length=3, max_length=150) password = serializers.CharField(min_length=6, max_length=20, write_only=True) email = serializers.EmailField(required=False) user_avatar = serializers.ImageField(required=False) user_gender = serializers.ChoiceField(required=False, choices=GENDER_CHOICE) first_name = serializers.CharField(required=False, label='姓') last_name = serializers.CharField(required=False, label='名') is_staff = … -
graphene-django updated now receiving error (reading 'SubscriptionClient')
I have a app who use graphql so far i was with those requirements : aniso8601==7.0.0 asgiref==3.4.1 attrs==22.1.0 boto3==1.26.13 botocore==1.29.91 certifi==2021.10.8 cffi==1.15.0 charset-normalizer==2.0.7 coreschema==0.0.4 cryptography==3.4.7 defusedxml==0.7.1 Django==3.2.8 django-classy-tags==3.0.1 django-cors-headers==3.10.0 django-graphiql==0.4.4 django-graphql-jwt==0.3.4 django-health-check==3.17.0 django-model-utils==4.2.0 django-sekizai==3.0.1 django-storages==1.13.1 docutils==0.18 exceptiongroup==1.0.1 graphene==2.1.9 graphene-django==2.15.0 graphql-core==2.3.2 graphql-relay==2.0.1 httpie==2.6.0 idna==3.3 iniconfig==1.1.1 itypes==1.2.0 Jinja2==3.0.2 jmespath==0.10.0 JSON-log-formatter==0.5.2 MarkupSafe==2.0.1 packaging==21.3 pluggy==1.0.0 promise==2.3 psycopg2-binary==2.9.3 pycparser==2.21 Pygments==2.10.0 PyJWT==2.7.0 pyparsing==3.0.9 PySocks==1.7.1 pytest==7.2.0 pytest-django==4.5.2 python-dateutil==2.8.2 python-environ==0.4.54 pytz==2021.3 requests==2.27.1 requests-toolbelt==0.9.1 Rx==1.6.1 s3transfer==0.6.0 singledispatch==3.7.0 six==1.16.0 sqlparse==0.4.2 text-unidecode==1.3 tomli==2.0.1 uritemplate==4.1.1 urllib3==1.26.7 uWSGI==2.0.21 The goal is to update Django to 4.2 at least When i do so using the following requirements (not everything is updated so far because of the current problem) aniso8601==9.0.1 asgiref==3.7.2 attrs==22.1.0 boto3==1.26.13 botocore==1.29.91 certifi==2021.10.8 cffi==1.15.0 charset-normalizer==2.0.7 coreschema==0.0.4 cryptography==3.4.7 defusedxml==0.7.1 Django==4.2.7 django-classy-tags==3.0.1 django-cors-headers==3.10.0 django-graphql-jwt==0.3.4 django-health-check==3.17.0 django-model-utils==4.2.0 django-sekizai==3.0.1 django-storages==1.13.1 docutils==0.18 exceptiongroup==1.0.1 graphene==3.3 graphene-django==3.1.5 graphql-core==3.2.3 graphql-relay==3.2.0 httpie==2.6.0 idna==3.3 iniconfig==1.1.1 itypes==1.2.0 Jinja2==3.0.2 jmespath==0.10.0 JSON-log-formatter==0.5.2 MarkupSafe==2.0.1 packaging==21.3 pip-review==1.3.0 pluggy==1.0.0 promise==2.3 psycopg2-binary==2.9.3 pycparser==2.21 Pygments==2.10.0 PyJWT==2.7.0 pyparsing==3.0.9 PySocks==1.7.1 pytest==7.2.0 pytest-django==4.5.2 python-dateutil==2.8.2 python-environ==0.4.54 pytz==2021.3 requests==2.27.1 requests-toolbelt==0.9.1 Rx==1.6.1 s3transfer==0.6.0 singledispatch==3.7.0 six==1.16.0 sqlparse==0.4.2 text-unidecode==1.3 tomli==2.0.1 typing_extensions==4.8.0 uritemplate==4.1.1 urllib3==1.26.7 uWSGI==2.0.21 I can't use the sand box over localhost/graphql and i receive this error Uncaught TypeError: Cannot read properties of undefined (reading 'SubscriptionClient') at graphiql.js:99:57 at graphiql.js:192:3 I didn't use subscription nowhere in my code. I … -
Django ORM aggregation with SUM and conditional COUNT with group by failing
I'm trying to get the follwing query to execute in Django ORM but no luck so far. I would like to have all PotatoesMeasurement grouped by wn and do a conditional count on alternaria when it greater than, smaller than and in range of certain values. I have the raw mongosh query to get the correct result but I'm unable to get the equivelent in django ORM. My model looks like: class BasicEntity(models.Model): class Meta: abstract = True id = models.UUIDField(default=uuid4, editable=False, db_index=True, primary_key=True) created_on = models.DateTimeField(default=now, editable=False, blank=True) updated_on = models.DateTimeField(default=now, editable=False, blank=True) class PotatoesMeasurement(BasicEntity): class Meta: db_table = "measurements_potatoes" colorado_potato_beetle_larvae = models.FloatField( default=0.0, validators=[MinValueValidator(0), MaxValueValidator(100)]) aphids_per_leaflet = models.IntegerField(blank=False, null=False) late_blight = models.FloatField( default=0.0, validators=[MinValueValidator(0), MaxValueValidator(100)]) alternaria = models.FloatField( default=0.0, validators=[MinValueValidator(0), MaxValueValidator(100)]) wn = models.IntegerField(default=datetime.now().isocalendar().week, validators=[MinValueValidator(1), MaxValueValidator(53)]) Mongosh query working perfectly: db.measurements_potatoes.aggregate([ { $group: { _id: "$wn", countSmaller: { $sum: { $cond: [{ $lte: ["$alternaria", 1] }, 1, 0] } }, countRange: { $sum: { $cond: [{ $range: [ 20, "$alternaria", 30 ] }, 1, 0] } }, countBigger: { $sum: { $cond: [{ $gt: ["$alternaria", 90] }, 1, 0] } } } }, {$sort: {_id: 1}}, ]); On django ORM side so far I have the following: res … -
HI i tried to solve this error while i am trying to host my django project to vercel so i got that error
error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [27 lines of output] your text note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error -
Django: set language
I'm totally new in Django I want to make a language field in Admin panel, the admin can set the language of the user, it can be 1 or many languages. For example, person 1 can speak english, French and japanese and another only in french. How can we do that? My User model looks like that Model: from django.contrib.auth.models import User # Create your models here. class Profile(models.Model): def __str__(self): return f'{self.user.get_full_name()}' -
Django: set birthday just by giving the month and day
I'm totally new in Django I want to make a field in Admin panel, that we could set the birthday of a user just by giving the month and day. Right now, we can only give the date, but that's not what I want. I want for example 2 dropdowns one for the day and one for the month My User model looks like that Model: from django.contrib.auth.models import User # Create your models here. class Profile(models.Model): birthday = models.DateField(blank=True, null=True) def __str__(self): return f'{self.user.get_full_name()}' -
How to containerize Streamlit + Django web app?
I’m creating a web app that allows users to use some tensorflow models I’ve created. Nothing new here, streamlit would deal with this perfectly. The problem here is that I want the users to be able to train new models with their own data and even parameters. So a number of user-specific models will be created, wich should be stored and secured with authentication. I have some experience with Django and it sounds like the framework that could perfectly deal with both authentication and database management, as well as Tensorflow tasks like inference and training. My proposed architecture would be a Streamlit frontend, connected to a Django backend with 3 applications: one for general backend tasks and communication with the frontend and DB (maybe via REST), one for Tensorflow related tasks, and one for authentication. I thought of this because this way I could hypothetically deploy another Streamlit frontend for another data science project, while using the same Django backend for both. My question is how should I containerize (with Docker) this system. I was thinking of one container for the Streamlit app (frontend) (if in the future I have several frontends, one container for each), one for Django and …