EN VI
Posts (0)
Questions (11)
2024-03-11 07:30:05
I'm not sure if I understood you, but you could try this. def get_dynamic_users_mock(user_id, extra_parameter): mock_by_user_id = { 1: { "id": 1, "first_name": "Joh...
2024-03-12 18:00:13
Since, you have only provided one template, I'd assume you're using the same form for all of those views you mentioned. Your form action is pointing to the same url home. at {% csrf_token %} . Change...
Tags: python html django
2024-03-12 19:30:04
For small amounts of dynamic data or scripts, keep the JavaScript code inside your Django template inside Store your dynamic data in a data attribute within an HTML element and read this data from y...
Tags: Javascript python django
2024-03-13 15:30:04
Not sure what is happening here. Django fetches the data from db and sends it to the browser, but it doesn't "sees" the ID while trying to write the data to the db. Django does not generate ids, tha...
Tags: python django postgresql
2024-03-13 17:30:04
You don't use the filtered queryset, but the entire queryset. You can work with: class EventFilter(django_filters.FilterSet): start_date = DateFilter( field_name='event_date', look...
2024-03-14 04:30:04
activate(…) [Django-doc] is not supposed to be persistent. Indeed, as the documentation says: Fetches the translation object for a given language and activates it as the current translation object fo...
Tags: python django localization
2024-03-14 04:30:06
You can not access session variables, or at least not directly, you will need an API to retrieve these. session variables are stored at the server-side, and normally used for sensitive data you don't...
2024-03-14 05:30:06
myMPR is not a MprVw object, but a QuerySet of zero, one, or multiple MprVw items. You thus will need to enumerate to get such object, so: from django.shortcuts import render def MPR(request): m...
Tags: django
2024-03-15 15:30:06
To allow a null value on the foo field in the FooChild serializer while keeping the field as required in the model, you can modify your code as follows: In FooChildSerializer, remove the foo field de...
Tags: python json django
2024-03-15 17:30:05
You can .annotate(…) [Django-doc] with: from django.db.models import Count Player.objects.annotate(score=Count('voteforplayer')) The Player objects that arise from this QuerySet will have an extra at...

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login