Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
requests post from django to nodejs
I trying to send data from django to nodejs. I receive but can't read data params. Django: response = { "status": "success", "voto": all_votes, "user_choice": new_vote.value if new_vote else None } import requests requests.post('http://localhost:8081/vote_added', data = response) NodeJS: //router/index router.post('/vote_added', votes.vote_added); //votes controller module.exports.vote_added = function(req, res) { console.log("test", req.params) console.log("test2", req.body) console.log("test3", req.query) } ps: my response is a dict -
Django hidden input and heading set dynamic value (depending on link)? [duplicate]
This question is an exact duplicate of: Django hidden input set dynamic value (depending on link)? 1 answer I am trying to create a Django form with one hidden input value and heading set dynamically. I have say 5 links -> Link 1, Link 2, Link 3, Link 4, Link 5 All of them redirects to the same form. And if the person clicks say 'Link 1' the value of hidden input value will be 'Link 1' and the heading of page should be 'WELCOME TO - Link 1' and then save to database. I want to use single(same) view for all the links. Any help/suggestions would be appreciated. -
Adding a chat app to an existing Django application on Heroku?
I have a fairly large Django project running on Heroku. I'm trying to add a chat app to the project but as far as I can tell, Heroku does not allow multiple ports to be used for an added websocket. I have also tried to use Django channels, but I haven't found any tutorials on adding channels to an existing project, so I have struggled with that as well. I'm trying to avoid making a new Heroku application to solve this. What are my options for adding a websocket to an existing Django application that would run on Heroku? -
Django - Images are overlapping
im currently developing a Django app where i need to display an histogram in the template for the current exam, the problem is that the images are overlapping if i see more than one exam. I will show in the images below. This is the histogram correspondent to the first exam i check And if i check another exam this is the histogram that appears: But if i restart the server it shows OK like the next picutre. Does anybody knows why this is happening? ill post the code of the image display def showImage(request,exam_id): imagePath = '/home/luis/Documentos/projeto/media/examshist/hist'+exam_id+'.png' Image.init() i = Image.open(imagePath) response = HttpResponse(content_type='image/png') i.save(response,'PNG') return response -
Rename RelatedField ordering filter in django rest framework
In a django rest framework APIView we specify ordering fields using the same method as the search filters and therefore we can specify ordering using related names. ordering_fields = ('username', 'email', 'profile__profession') The route would look like this: https://example.com/route?ordering=profile__profession However we would rather avoid to display the relation between the models in the api and then specify profession instead of profile__profession. Such as https://example.com/route?ordering=profession Can this be achieved without modifying the APIView's def get_queryset(self):? -
Adding data to ManyToManyField after creation
I've got a model with a ManyToManyField and want to add all data out of a different table upon creation of that model. This is the code I got so far, which does not save the entries: ''' Klassendefinition für den Spieltag ''' from django.db import models from django.dispatch import receiver from django.utils.translation import ugettext_lazy as _ from django_extensions.db.models import TimeStampedModel from season.models import Season from player.models import Player # Create your models here. class Matchday(TimeStampedModel): ''' Klasse für den Spieltag ''' seasontable = models.ManyToManyField("table.Table", related_name="Ligaspieltisch", blank=True) matchtable = models.ManyToManyField("table.Table", related_name="Pfeilsystemtisch", blank=True) #Spieler die am Spieltag angemeldet sind (Kickereuro) signedin = models.ManyToManyField("player.Player", related_name="Angemeldet", blank=True) needtopay = models.BooleanField(_("Soll der Kickereuro gezahlt werden?"), default=True) finished = models.BooleanField(_("Beendet?"), default=False) season = models.ForeignKey(Season, verbose_name=_("Saison"), blank=True, null=True) class Meta: ''' Metaklasse für Spieltag ''' verbose_name = _("Spieltag") verbose_name_plural = _("Spieltage") ordering = ('-created',) def __str__(self): return "Spieltag" @receiver(models.signals.post_save, sender=Matchday) def execute_after_save(sender, instance, created, *args, **kwargs): ''' Ausführen, wenn matchday gespeichert wird ''' if created: #Wurde matchday neu erstellt? if not instance.needtopay: #Kickereuro muss nicht gezahlt werden -> alle Spieler hinzufügen instance.save() players = Player.objects.all() players = list(players) for player in players: instance.signedin.add(player) instance.save() players = instance.signedin.all() print(players) The print(players) is there for debugging purposes and … -
Why my Django form is not raising any error?
I have a simple form and whenever the user do something wrong on the form i'd like to raise a validation error on Django. The problem is that I set it up but when the form is submited with wrong values, it goes through. I was wondering why it's happening and how I can avoid that ? Here is the html form : <form id="ask-project" method="post" action="{% url 'ask-project' %}"> {% csrf_token %} <input required="required" class="form-control form-text required" id="prenom" name="prenom" type="text"> <button class="btn btn-default submit">Submit</button> </form> views.py : def askProject(request): if request.method == 'POST': form = AskProjectForm(request.POST) if form.is_valid(): save_it = form.save(commit=False) save_it.save() return redirect('/merci/') #success else: return redirect('/') #fail else: return redirect('/') forms.py : class AskProjectForm(forms.ModelForm): class Meta: model = AskProject fields = ['prenom'] def clean_prenom(self): prenom = self.cleaned_data['prenom'] if len(prenom) < 3: raise ValidationError('Votre prénom doit etre plus long que 1 caractère.') return prenom Am I doing something wrong ? -
issue with method filter(), can't filter data and add her with help post_save method [duplicate]
This question already has an answer here: Error with Signals Post_Save and Pre_Save: created and self! how to fix? 2 answers It is necessary to filter the data from the model 'userwathcing' and add the data to the 'UserProfile' but the following error pops up: save() missing 1 required positional argument: 'self' this i s UserProfile model class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) serials_watched_nmb = models.IntegerField(default=0) series_watched_nmb = models.IntegerField(default=0) total_minutes_wathced_nmb = models.IntegerField(default=0) total_count_of_wasted_days_on_series = models.PositiveIntegerField(default=0) TotalCountOfDowlandedSeriesInQuality360p = models.PositiveIntegerField(default=0) TotalCountOfDowlandedSeriesInQuality720p = models.PositiveIntegerField(default=0) TotalCountOfDowlandedSeriesInQuality1080p = models.PositiveIntegerField(default=0) this is userwatching model class userwatching(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, default=True) watched_serial = models.ForeignKey(Serial, on_delete=models.CASCADE, default=True) watched_serie = models.ForeignKey(Series, on_delete=models.CASCADE, default=True, related_name='serie') minutes_of_series = models.PositiveIntegerField(default=42) created = models.DateTimeField(auto_now_add=True, auto_now=False) updated = models.DateTimeField(auto_now_add=False, auto_now=True) this is post_save method def user_watching_post_save(sender, instance, **kwargs): watching_model = userwatching.objects.all() count_of_all_watched_series = watching_model.filter(user=True).count() print(count) time_of_one_series = watching_model.filter(watched_serie__time_of_series=True) print(time) user_profile = UserProfile user_profile.series_watched_nmb = int(count) user_profile.total_minutes_wathced_nmb = time user_profile.save() post_save.connect(user_watching_post_save, sender=userwatching) -
Django. Check in template or use an extra field?
I have some text fields in my Django model that are filled by a script, with values in English (the list of values is known). But the app is actually made for Russian clients only. I'd like to translate those fields into Russian, and here comes a little question. These values are taken from an API response, which means I should check the value to translate it. What's faster: to check and translate fields in template or to make extra fields and translate strings in the Python script? -
ImportError: No module named material
(venv) jeremie@my_account:~/Projects/credit-24-django$ python manage.py migrate Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/jeremie/Projects/credit-24-django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/home/jeremie/Projects/credit-24-django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 337, in execute django.setup() File "/home/jeremie/Projects/credit-24-django/venv/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/home/jeremie/Projects/credit-24-django/venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/home/jeremie/Projects/credit-24-django/venv/local/lib/python2.7/site-packages/django/apps/config.py", line 94, in create module = import_module(entry) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: No module named material I have this little issue, and I can't say why I have it. How could I fix that problem? Thanks in advance! -
how to upload files in viewflow
I'm trying to upload a document attached to the flow in viewflow as another field as would a string or an int, but when I put in the model Answer = FilerFileField () I do not recognize it view flow in the fields Fields = ["Answer"] -
Don't work "show all" filter
I have products sorted by categories and I want to do pagination for products of every category and button "show all" that show all products in chosen category. But when I click "Show all" I get products from first category. product/views.py class CategoryView(DetailView): model = Category template_name = 'shop/product/category.html' context_object_name = 'category' slug_url_kwarg = 'category_slug' def get_context_data(self, **kwargs): context = super(CategoryView, self).get_context_data(**kwargs) context['category'] = get_object_or_404(Category, slug=self.kwargs['category_slug']) context['categories'] = Category.objects.active() context['products'] = Product.objects.active(category=context['category']) context['brands'] = Brand.objects.filter(product__in=context['products']).distinct() context['weight'] = filter(None, sorted(list(set(list(p.weight if p.weight is not None else None for p in context['products']))))) context['package_type'] = filter(None, sorted(list(set(list(p.package_type if p.package_type is not None else None for p in context['products']))))) context['color_type'] = filter(None, sorted(list(set(list(p.color_type if p.color_type is not None else None for p in context['products']))))) product_filter = {} context['product_filter'] = product_filter if 'filter' in self.request.resolver_match.kwargs: filters = self.request.resolver_match.kwargs['filter'].split(";") for f in filters: if "brand_" in f: product_filter['brand'] = [x for x in f.split("brand_")[1].split(',')] context['products'] = context['products'].filter(brand__slug__in=product_filter['brand']) if "weight" in f: product_filter['weight'] = [str(x) for x in f.split("weight_")[1].split(',')] context['products'] = context['products'].filter(weight__in=product_filter['weight']) if "package_type" in f: product_filter['package_type'] = [str(x) for x in f.split("package_type_")[1].split(',')] context['products'] = context['products'].filter(package_type__in=product_filter['package_type']) if "color_type" in f: product_filter['color_type'] = [str(x) for x in f.split("color_type_")[1].split(',')] context['products'] = context['products'].filter(color_type__in=product_filter['color_type']) show_all_products = self.request.GET.get('show') if show_all_products == 'all': … -
Django Celery how to configure queues and see them in rabbitmq admin dashboard
In my config files I have the following lines: CELERY_QUEUES = ( Queue('fetch_tweets_requests'), ) CELERY_ROUTES = { 'applications.twitter.tasks.fetch_tweets': {'queue': 'fetch_tweets_requests' }, } The tasks run as expected when fired, but when I go to the rabbitmq admin dashboard, I don't see any queue named fetch_tweets_requests How can I configure django so that I can see the queues I've setup? -
how to access variable data from string in django template
I have a Django template in which i would like to get a value from a variable (array), and use it. A part of the template: {% for type in hookTypes %} {% for module in type %} <a href="">{{module}}</a> {% endfor %} {% endfor %} type is a variable that contains get and my python file returns an array called get to this template. The problem is that get value in type is string and im not able to access the get array data (this code shows each letter of the type variable. g,e,t in this case) -
django ImageField link doesn't show in html template
I can redirect to uploaded image through admin-panel but I can't load it on page. In HTML source code it looks like this: <img src="" height = "200" with = "200" /> So here's my code: models.py: class Profile(models.Model): user = models.ForeignKey(User) avatar = models.ImageField(upload_to='images/users/', verbose_name='Аватар', default = 'images/users/ava.gif/') urls.py: from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns from mainpage.views import * urlpatterns = [ #other urls ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + staticfiles_urlpatterns() settings.py: MEDIA_ROOT = 'C:/<<path to django app dir>>/media' MEDIA_URL = '/media/' template: {% block content %} <body> <h1>{{ user.username }}</h1> <img src="{{ MEDIA_URL }}{{ profile.avatar.url }}" height = "200" with = "200" /> <p> <ul> <li>email: {{ user.email }}</li> </ul> </p> </body> {% endblock %} Will be very thankful for any help. -
filter like a nobb, can't filter data and add they with post_save, how to fix this?
It is necessary to filter by parameters, but how? For example, to filter out the user = authorized user, then it is necessary to collect all values from these selected data, for example, the entire amount of time, that is, from the 5 selected data, take all the time, and add to another model, in the model "Userprofile" ... Help me pls ... But an error or simply does not save the data to another model this is model of UserProfile class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) serials_watched_nmb = models.IntegerField(default=0) series_watched_nmb = models.IntegerField(default=0) total_minutes_wathced_nmb = models.IntegerField(default=0) total_count_of_wasted_days_on_series = models.PositiveIntegerField(default=0) TotalCountOfDowlandedSeriesInQuality360p = models.PositiveIntegerField(default=0) TotalCountOfDowlandedSeriesInQuality720p = models.PositiveIntegerField(default=0) TotalCountOfDowlandedSeriesInQuality1080p = models.PositiveIntegerField(default=0) this is userwatching model class userwatching(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, default=True) watched_serial = models.ForeignKey(Serial, on_delete=models.CASCADE, default=True) watched_serie = models.ForeignKey(Series, on_delete=models.CASCADE, default=True, related_name='serie') minutes_of_series = models.PositiveIntegerField(default=42) created = models.DateTimeField(auto_now_add=True, auto_now=False) updated = models.DateTimeField(auto_now_add=False, auto_now=True) this is Post_save method def user_watching_post_save(sender, instance, **kwargs): b = userwatching.objects.all() count = b.filter(user=True).count() print(count) time = b.filter(watched_serie__time_of_series=True) print(time) user_profile = UserProfile user_profile.series_watched_nmb = int(count) user_profile.total_minutes_wathced_nmb = time post_save.connect(user_watching_post_save, sender=userwatching) -
What's wrong with the way I pass context to a template in Django?
I have a polls_article table in my database and SELECT * FROM polls_article; yields the following two rows: id | headline ----+--------------------------------------- 1 | Django lets you build Web apps easily 2 | NASA uses Python (2 rows) I would like to print these two rows to my template using: {% if articles %} Articles: {% for article in articles %} ID: {{ article.headline }}<br/> {% endfor %} {% else %} Currently no articles. {% endif %} In my app's views.py I've defined the associated view as follows: def index(request): if request.user.is_authenticated: articles = Article.objects.all(). context = {'articles': articles} return render(request, 'polls/index.html', context) else: return render(request, 'polls/index.html') In my app's urls.py I have the following relevant entry: urlpatterns = [ url(r'^$', views.index, name='index')] The template then renders Currently no articles. where I want the article headlines to be rendered. What am I doing wrong? -
Celery multi workers unexpected task execution order
I run celery: celery multi start --app=myapp fast_worker slow_worker -Q:fast_worker fast-queue -Q:slow_worker slow-queue -c:fast_worker 1 -c:slow_worker 1 --logfile=%n.log --pidfile=%n.pid And celerybeat: celery beat -A myapp Task: @task.periodic_task(run_every=timedelta(seconds=5), ignore_result=True) def test_log_task_queue(): import time time.sleep(10) print "test_log_task_queue" Routing: CELERY_ROUTES = { 'myapp.tasks.test_log_task_queue': { 'queue': 'slow-queue', 'routing_key': 'slow-queue', }, } I use rabbitMQ. When I open rabbitMQ admin panel, I see that my tasks are in slow-queue, but when I open logs I see task output for both workers. Why do both workers execute my tasks, even when task not in worker queue? -
implement a genericKey with taggit and selectize.js
hello would like to use two taggit Tagglemanagers in one model. unfortunately this is not possible. Google suggests to use from taggit.models import CommonGenericTaggedItemBase, TaggedItemBase and then add a genericKey the two fields: class UserProfile(models.Model): I_like = TaggableManager(verbose_name="I like",blank=False) I_dont_like = TaggableManager(verbose_name="See",blank=False) My Problem is that I use selectize.js with from taggit_selectize.managers import TaggableManager so the usual genericKey would not work with that. Or would it? Can anybody tell me how to implement the selectize.js taggit generic Key or what I have to do to get that my form has two taggit selectize fields so I don't get the error You can't have two TaggableManagers with the same through model. Im new to django and never really used genericKeys in my Apps. I hope somebody can help me. -
Unable to upload CSV file using Python/Django
I am trying to upload the csv file using Django and planning to parse the CSV file. But this code fails to upload the file and keeps going to the else condition. What is wrong with this code? from django.shortcuts import render import csv import codecs from django.shortcuts import render_to_response from django.template import RequestContext from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse from items.models import UploadFileForm def handle_files(f): reader = csv.DictReader(open(f)) for row in reader: print row def home(request): if request.method == "POST": form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): handle_files(request.FILES['file']) return HttpResponseRedirect('/workflow/') else: print form.errors print request.FILES return HttpResponseRedirect('/workflow/upload') else: form = UploadFileForm() return render(request, 'template.html', {'formset': form}) -
"The redirect URI included is not valid" error using Django OAuth setup keys for gitlab SSO
Getting the below error when trying to use gitlab OAuth setup on my django webserver. "The redirect URI included is not valid" Below is the configuration i have used, I can't figure out what is wrong: # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' LOGIN_REDIRECT_URL = 'http://localhost:8000/success/' #OAuth setup keys for the gitlab SSO SOCIAL_AUTH_GITLAB_KEY = '91b9ac5d202468586c4201f1127849534249ad7341beb0e0e0385d90d8d7a023' SOCIAL_AUTH_GITLAB_SECRET ='8e7a0592c15c1be3114d12fd98590dd6fb402c9a221f7bdaa6a0de0b2d5a2d25' SOCIAL_AUTH_GITLAB_API_URL = 'https://gitlab.dev.companyname.com/' SOCIAL_AUTH_LOGIN_REDIRECT_URL = 'http://localhost:8000/success/' SOCIAL_AUTH_LOGIN_URL = 'http://localhost:8000/success/' -
putting username in url
so I been working on this for a couple of days now and I still dont seem to understand the problem. I am trying to get the username in the url so that you can just look up any user if you type http://127.0.0.1:8000/accounts/profile/username and that users profile shows up. I have looked at other questions but I keep getting this error when I try. If anyone could help me I would be greatly appreciated. NoReverseMatch at /accounts/profile/admin Reverse for 'viewprofile' with arguments '('',)' not found. 1 pattern(s) tried: ['accounts/profile/(?P[\w.@+-]+)'] views.py def view_profile(request, username): username = User.objects.get(username=username) posts = Post.objects.filter(author = request.user).order_by('-pub_date') args = { 'user': request.user, 'posts': posts, } return render(request, 'accounts/profile.html', args) in my nav bar: this could be wrong but im sure its right <li><a href="{% url 'accounts:viewprofile' username%}">Profile</a></li> urls.py url(r'^profile/(?P<username>[\w.@+-]+)', views.view_profile, name="viewprofile"), -
"Access denied. Option -c requires administrative privileges. ping to 127.0.0.1 failed!". can anyone say me how can i overcome this
i tried executing the below code but i m getting output as access denied. please suggest me, how can i overcome this import subprocess for ping in range(1,10): address = "127.0.0." + str(ping) res = subprocess.call(['ping', '-c', '3', address]) if res == 0: print ("ping to", address, "OK") elif res == 2: print ("no response from", address) else: print ("ping to", address, "failed!") output: - List item Access denied. Option -c requires administrative privileges. ping to 127.0.0.2 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.3 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.4 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.5 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.6 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.7 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.8 failed! Access denied. Option -c requires administrative privileges. ping to 127.0.0.9 failed! -
django and nginx still return 502
After seached the Internet I found these: nginx upload client_max_body_size issue https://www.scalescale.com/tips/nginx/502-bad-gateway-error-using-nginx/# user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; client_body_temp_path /tmp/; client_body_in_file_only on; client_body_buffer_size 128K; client_max_body_size 30M; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } ./conf.d/default.conf upstream app { server localhost:8000; } server { listen 80; server_name jobs.siamsbrand.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name jobs.siamsbrand.com; add_header Strict-Transport-Security "max-age=31536000"; proxy_pass_request_headers on; root /www/data; ssl_certificate /root/fullchain.pem; ssl_certificate_key /root/privkey.pem; include snippets/ssl-params.conf; location / { proxy_pass_request_headers on; proxy_set_header Host $host; proxy_pass http://app; } location /static { try_files $uri $uri/ =404; } location /media { try_files $uri $uri/ =404; } location ~ /.well-known { allow all; } } gunicorn: gunicorn --bind 0.0.0.0:8000 --workers 3 --worker-class gevent wsgi:application --log-level=INFO Problem: I got 502 after 30 seconds. Where am I wrong? -
Django can't make options selected
I'm trying to make the options in my select selected. In my code each user is giving scores to each other. I've tryed a few things but it doesn't work. The option should remain selected if the selected value is equal to the grade given to the user. I've used AbstractUser that's why there is User = get_user_model(), but I decided not to show it since it was useless. models.py class Score(models.Model): VALUE = ( (1, "Score 1"), (2, "Score 2"), (3, "Score 3"), (4, "Score 4"), (5, "Score 5"), (6, "Score 6"), (7, "Score 7"), (8, "Score 8"), (9, "Score 9"), (10, "Score 10"), ) granted_by = models.ForeignKey(settings.AUTH_USER_MODEL, default=0) granted_to = models.ForeignKey(settings.AUTH_USER_MODEL, default=0, related_name='granted_to') grade = models.PositiveSmallIntegerField(default=0, choices=VALUE) def __str__(self): return str(self.granted_to) views.py @login_required(login_url='/login/') def vote(request): User = get_user_model() data = dict() data['users'] = User.objects.exclude(username=request.user) if request.method == "POST": if "rating" in request.POST: for key in request.POST: if 'grade_' in key: awarded_grade = Score.objects.filter(granted_by=request.user, granted_to__id=key.split('_')[1]).first() if awarded_grade: awarded_grade.grade = request.POST.get(key) awarded_grade.save() else: Score.objects.create(granted_by=request.user, granted_to_id=key.split('_')[1], grade=request.POST.get(key)) data['values'] = Score.VALUE data['grade'] = Score.objects.filter(granted_by=request.user) return render(request, 'vote.html', data) vote.html {% for user in users %} <tr> <td>{{ user.date_joined|date:"d.m.Y H:i" }}</td> <td>{{ user.username }} </td> <td>{{ user.id }}</td> <td> <select title="selecting_grade" name="grade_{{ user.id …