Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add pagination to Django Filter Views?
Filtering and Pagination with Django I want to add pagination in filter view function below contain my code Filters.py : when i add paginated by is unavailable at the wepages class AccountFilter(django_filters.FilterSet): username = django_filters.CharFilter(lookup_expr='icontains') first_name = django_filters.CharFilter(lookup_expr='icontains') last_name = django_filters.CharFilter(lookup_expr='icontains') is_staff = django_filters.BooleanFilter(widget=CustomBooleanWidget) is_superuser = django_filters.BooleanFilter(widget=CustomBooleanWidget) is_active = django_filters.BooleanFilter(widget=CustomBooleanWidget) date_joined = django_filters.DateFromToRangeFilter(label='Date Joined Range', widget=django_filters.widgets.RangeWidget(attrs={'placeholder': 'yyyy/mm/dd','class': 'datepicker', 'type': 'date'})) ` views.py : # AccountFilter View: def AccountViewFilter(request): userf_list = User.objects.all() userf_filter = AccountFilter(request.GET, queryset= userf_list) return render(request, 'accounts/user_list.html', {'filter': userf_filter}) user_list.html: {% if filter.qs%} <table class="table"> <thead class="thead-dark"> <tr> {# <th scope="col">No</th> #} <th scope="col">User Name</th> <th scope="col">User Email</th> <th scope="col">Is Staff</th> <th scope="col">Is Active</th> <th scope="col">Date Joined</th> <th scope="col">Is SuperUser</th> <th scope="col">Edit</th> <th scope="col">Delete</th> </tr> </thead> <tbody> {{endif}} -
Python/Django Improperly Configured Error - Settings are not configured
I have a Django project called Veganet that I am trying to connect to two other applications using flask, but when I run my main script vega_flask_run.py it gives me an improperly configured error. The source of the error is coming from a script named models.py, more specifically line 2 where I am declaring from django.contrib.auth.models import User. I have tried to use a few posts to solve my problem including: Django DB Settings 'Improperly Configured' Error ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details “settings.DATABASES is improperly configured” error performing syncdb with django 1.9 I have tried their solutions which mostly includes changing the INSTALLED_APPS variable in my projects settings.py and changing the DATABASES variable inside settings.py, as well as using windows powershell to execute python manage.py shell, django-admin.py shell --settings=mysite.settings, and then setting the DJANGO_SETTINGS_MODULE variable to point to my projects settings and lastly using from django.core.management import setup_environ from veganet import settings setup_environ(settings) as the answer suggests in the first link. here is the error in it's entirety: Exception has occurred: ImproperlyConfigured Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or … -
Docker container build fails on local if a unit test fails but build successfully on Azure
init.sh file #!/bin/bash cd /code python manage.py migrate python manage.py load_fixtures python manage.py collectstatic --noinput python manage.py test || exit 1 python manage.py runserver 0.0.0.0:8000 When the test fails my docker compose fails and container is not built but when I take the code online to azure pipeline. It works with out giving test error. -
django not checking elif condition views.py
In my views.py if i provide only 1 elif condition its working but when i give 2 elif condition its not working In views.py def dashboard(request): if request.user.is_superuser: a=branch.objects.aggregate(Count('id')) b=emp.objects.aggregate(Count('id')) elif request.user.admin.position == 'admin': a=branch.objects.aggregate(Count('id')) b=emp.objects.filter(branch=request.user.admin.branch_name).aggregate(Count('id')) elif request.user.emp.position == 'employee': a=branch.objects.aggregate(Count('id')) b=emp.objects.filter(branch=request.user.emp.branch).aggregate(Count('id')) -
Django 4.0.1 authentication from not default database
I create project using DRF, I'm using two database alias: Default and Oracle. On oracle database there are all django tables. How can I use authenticate if auth_user is on oracle not default database. -
Problem installing django-auth-ldap on Centos 8
I have problem with finalizing netbox installation on Centos8. Netbox is working fine with Gunicorn and Apache. I wanted to add LDAP auth but there is a problem with django-auth-ldap installation. Can you tell my why? I'm using proxy but all installations where ok sofar. Maybe there is no setuptools version for centos8 higher or equal to 40.8.0? (venv) test # python -m pip --proxy http://x.x.x.x:8080 install django-auth-ldap Collecting django-auth-ldap Using cached django_auth_ldap-4.0.0-py3-none-any.whl (20 kB) Collecting python-ldap>=3.1 Using cached python-ldap-3.4.0.tar.gz (376 kB) Installing build dependencies ... error ERROR: Command errored out with exit status 1: command: /opt/netbox-3.1.6/venv/bin/python /tmp/pip-standalone-pip-7k0onaz9/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-af6_ygqc/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel cwd: None Complete output (7 lines): WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8aaf45b880>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /simple/setuptools/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8aaf45bc10>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /simple/setuptools/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8aaf45b040>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /simple/setuptools/ … -
How to retrieve URL fragment parameters in drf APIView?
I have created a callback view for instagram account connection in django by inheriting the APIView class. After successful connection of instagram account facebook redirects me to the InstagramConnectCallbackView and includes the response data as a URL fragment. url: http://localhost:8000/v1/instagram-connect/callback/?#access_token=EAAN....&data_access_expiration_time=1650543346&expires_in=6254&state=eyd... But I don't know how to read the URL fragments from the request into the get method. callback view: class InstagramConnectCallbackView(APIView): permission_classes = (permissions.AllowAny,) version = settings.FACEBOOK_GRAPH_API_VERSION def get(self, request, format=None): .... I tried the following: request.get_full_path() # returns `/v1/instagram-connect/callback/` request.query_params() # returns `{}` Any help will be appreciated. -
How to setup memcached for Django 3.0 on App Engine?
So I have a Django 3.0 app that I want to deploy to App Engine. I want to use Memcached in order to cache data that has been pulled from BQ to my Django app. So far what I have is that I set up my Django's views.py as follows: from google.appengine.api import memcache def index(request): cached_data = memcache.get('cached_data') if not cached_data: # Syntax to pull data here memcache.add(key='cached_data', value='pulled_data', time=3600) My app.yaml also includes app_engine_apis: true However, after deploying the app using gcloud app deploy and opening the web app, I'm getting a 500 Server Error. I believe this error is because of the Memcached but I'm not sure what I am missing. Additional Note: I have not set any CACHES in my settings.py as none were mentioned on the GCP website. I used this during development locally: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': '127.0.0.1:11211', } } But then I removed it right before deploying to App Engine. I've tried following this SO Answer but it didn't work for me. -
want fetch existing data from db in django. 1054 "Unknown column 'traders.id' in 'field list'" error getting. Id is automatically generate in db
def Fetch_data(request): if 'q' in request.GET: q = request.GET['q'] #enter image description here'q' is name given in form data = Traders.objects.filter(traders_name__icontains=q) else: data = Traders.objects.all() return render(request,"fetch_data.html", {'data':data}) html file(tempplate)- <tbody> {% for data in data %} <tr> <th scope="row">1</th> <td>{{data.traders_name}}</td> <td>{{data.email}}</td> <td>{{data.registration_no}}</td> <td>{{data.address}}</td> </tr> --> {% endfor %} </tbody> -
How to validate fields in Django?
I'm new to Django. I was a .NET developer. I've created a form for new users' registration, but my problem is that I need some validation controls to validate my fields. I could not find any resources or examples. Any help, please? My newuser.html is in the below: {% block content %} <form method="POST"> {% csrf_token %} <table> <tr> <td> <lable>Name </lable> </td> <td> <input type="text" name="name"> </td> </tr> <tr> <td> <lable>Username </lable> </td> <td> <input type="text" name="username"> </td> </tr> <tr> <td> <lable>Password </lable> </td> <td> <input type="password" name="password"> </td> </tr> <tr> <td> <lable>Confirm password </lable> </td> <td> <input type="password" name="confirmPassword"> </td> </tr> <tr> <td> <lable>email </lable> </td> <td> <input type="email" name="email"> </td> </tr> <tr> <td> <input type="submit" name="save" value="Save" colspan=2> </td> </tr> </form> {% endblock content %} -
in Django: How to get and display in template verbose_name of a model that their value is true, while name of field unknown?
I have a model than has a lot of models.BooleanField declarations. class a_lot_of_booleans(model.Models): old_or_new = models.BooleanField(default=False,verbose_name="is it an old or a new item") product_for_teens = models.BooleanField(default=False,verbose_name="is this product for teens") in_original_package = models.BooleanField(default=False,verbose_name="is this product in original package?") Which then is used in some other classes like: class product_for_sale(a_lot_of_booleans): U_Id = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) product_name=models.CharField(max_length=50) class product_for_buying(a_lot_of_booleans): U_Id = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) product_name=models.CharField(max_length=50) The class a_lot_of_booleans might change over time. Some booleans might get added some might get removed. What I need is to display a list of several entries, of the verbose_name, of only the true fields on one of the classes that inherit the a_lot_of_booleans class and the value of product_name, belonging to specific user. What I"m trying in the views.py is the following: def view_rfps(request): list=product_for_sale.objects.all().filter(U_Id=request.user) for item in list: values=item._meta.fields for value in values: res=item.objects.filter(**{value:'True'}) ##<< lines that fail print(res) the above code fails on res=item.objects.filter(**{value:'True'}) on "Manager isn't accessible via search_for_constructor_rfp instances" The idea later to pass on the res variable to view, however I cannot pass this point. I have several items in list and for every list several boolean fields, that I"m not sure what they names gonna be in a future, so … -
How to coordinate randomly chosen objects in a DRF APIView?
I am building an API for a game and need to select a random game round for a randomly chosen resource. Choosing the random resource works. What I am trying to do now, in order to coordinate players is to filter the game rounds by the resource that has been chosen randomly and then return a random game round. The code below shows what I have tried so far, namely to access the resource for which a game round has been played over the method with the @property decorator. models.py class Gameround(models.Model): user = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True) gamesession = models.ForeignKey(Gamesession, on_delete=models.CASCADE) created = models.DateTimeField(editable=False) score = models.PositiveIntegerField(default=0) objects = models.Manager() def save(self, *args, **kwargs): if not self.id: self.created = timezone.now() return super().save(*args, **kwargs) def create(self): pass @property def tags(self): tags = self.taggings.values('tag') return tags.values('tag_id', 'tag__name', 'tag__language', 'resource_id') class Tagging(models.Model): user = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True) gameround = models.ForeignKey(Gameround, on_delete=models.CASCADE, related_name='taggings') resource = models.ForeignKey(Resource, on_delete=models.CASCADE, related_name='taggings') tag = models.ForeignKey(Tag, on_delete=models.CASCADE) created = models.DateTimeField(editable=False) score = models.PositiveIntegerField(default=0) origin = models.URLField(max_length=256, blank=True, default='') objects = models.Manager() def create(self, tag): tagging = self.create(tag=tag) def __str__(self): return str(self.tag) or '' def save(self, *args, **kwargs): if not self.id: self.created = timezone.now() return super().save(*args, **kwargs) I am then … -
I want to filter a model but their are many filters and all aren't required django?
In my project, I want to build a filter system and the filter is not by 1 field it is by about 6 fields but every field isn't required but at backend I have to use many queries like if 3 fields are coming: field1 = form.field1 field2 = form.field2 field3 = form.field3 field3 = form.field4 field4 = form.field5 field5 = form.field6 if field1 is None: filter_by_other_field but by doing this method it will make many queries so can u pls help me In this case I want to use less code Thanks -
Django Email alert after User creation
The user must receive a mail when the user was created if the post button was pressed in Django rest framework and below is my code. I'm Creating API for this project ERROR AttributeError at /api/User/ 'User' object has no attribute 'is_active' Request Method: POST Request URL: http://127.0.0.1:8000/api/User/ Django Version: 2.2.12 Exception Type: AttributeError Exception Value: 'User' object has no attribute 'is_active' class User(models.Model): CHOICES= ( ('manager','Manager'), ('hr', 'HR'), ('hr manager','HR Manager'), ('trainee','Trainee') ) firstname = models.CharField(max_length=210) lastname = models.CharField(max_length=210) dob=models.DateField(max_length=8) email=models.EmailField(max_length=254,default=None) password=models.CharField(max_length=100,default=None) joiningDate=models.DateTimeField(max_length=8) userrole=models.CharField(max_length=20,choices=CHOICES,null=True) def __str__(self): return self.firstname @receiver(post_save, sender=User, dispatch_uid='active') def active(sender, instance, **kwargs): if instance.is_active and User.objects.filter(pk=instance.pk, is_active=True).exists(): subject = 'Active account' mesagge = '%s your account is now active' %(instance.username) from_email = settings.EMAIL_HOST_USER send_mail(subject, mesagge, from_email, [instance.email], fail_silently=True) class Project(models.Model): name = models.CharField(max_length=20) description=models.TextField() type=models.TextField() startDate = models.DateTimeField(max_length=10) endDate=models.DateTimeField(max_length=10) user=models.ManyToManyField(User) def __str__(self): return self.name class Timesheet(models.Model): project=models.ManyToManyField(Project) Submitted_by=models.ForeignKey(default=None,related_name="SubmittedBy",to='User',on_delete=models.CASCADE) status=models.CharField(max_length=200) ApprovedBy=models.ForeignKey(default=None,related_name="ApprovedBy",to='User',on_delete=models.CASCADE) Date=models.DateField() Hours=models.TimeField(null=True) def __str__(self): return self.id class Client(models.Model): clientname=models.CharField(max_length=20) comapny=models.CharField(max_length=200) location=models.CharField(max_length=200) email=models.EmailField(max_length=25,default=None) def __str__(self): return self.clientname -
Dynamic variables in json with Django settings values
I am working with a python library for a certain api service. And in order to connect to their account, they use the json file. This is how the API connection looks like. api = VoximplantAPI('credentials.json') credentials.json { "account_email": "my email", "account_id": "ac_id", "key_id": "key_id", "private_key": "private" } I removed the values. I have a question, how can I add dynamic variables to json so that I can take values from Django settings, for example using Jinja. I have been looking for an answer for several hours, but I have not found an answer. -
How to create 2 roles for the same user in Django
I am creating a job portal system where a user can either be a employee or employer.This is my models.py in account app in django, it is not working. from django.contrib.auth.models import AbstractUser from django.db import models from account.managers import CustomUserManager JOB_TYPE = ( ('M', "Male"), ('F', "Female"), ) ROLE = ( ('employer', "Employer"), ('employee', "Employee"), ) class User(AbstractUser): username = None email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "A user with that email already exists.", }) role = models.CharField(choices=ROLE, max_length=10) gender = models.CharField(choices=JOB_TYPE, max_length=1) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] def __str__(self): return self.email def get_full_name(self): return self.first_name+ ' ' + self.last_name objects = CustomUserManager() -
Local variable reference before assignment - Python Django
I am having an issue in calculating a field in Model. Basically what I need to do is to calculate, based on the user HTML input, a certain date and a certain price. The functions are giving me problem are the functions inside the models.py file. The code is as follows: models.py from django.db import models from datetime import datetime as dt from datetime import timedelta # Create your models here. RAMO_POLIZZA = ( ('ITAS DANNI', 'ITAS DANNI'), ('ITAS ELEMENTARI', 'ITAS ELEMENTARI'), ('SARA DANNI', 'SARA DANNI'), ('SARA ELEMENTARI', 'SARA ELEMENTARI'), ) FRAZIONAMENTO = ( ('Annuale', 'Annuale'), ('Semestrale', 'Semestrale'), ('Quadrimestrale', 'Quadrimestrale'), ('Mensile', 'Mensile'), ) class Cliente(models.Model): nome = models.CharField(max_length=50) cognome = models.CharField(max_length=50) note = models.TextField(blank=True, null=True) creata = models.DateTimeField(auto_now_add=True) aggiornata = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = 'Cliente' ordering = ['cognome', ] def __str__(self): return self.nome + ' ' + self.cognome class RamoPolizza(models.Model): nome = models.CharField(max_length=50, choices=RAMO_POLIZZA) creata = models.DateTimeField(auto_now_add=True) aggiornata = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = 'Ramo Polizza' def __str__(self): return self.nome class Frazionamento(models.Model): nome = models.CharField(max_length=50, choices=FRAZIONAMENTO) creata = models.DateTimeField(auto_now_add=True) aggiornata = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = 'Frazionamento' def __str__(self): return self.nome class Polizza(models.Model): cliente = models.ForeignKey(Cliente, on_delete=models.CASCADE) numero_polizza = models.CharField(max_length=100) data_decorrenza = models.DateField() data_scadenza = models.DateField(blank=True, null=True) ramo_polizza = … -
Django import fail
Good day, 10 minutes ago everything worked fine. I changed nothing except running the server again and now I get the error line 2, in <module> from .forms import LoginForm, RegisterForm ImportError: attempted relative import with no known parent package I am in the views.py and want to import forms.py -
Command line isn't working with any Django commands
I am trying to call any django command, but it is just empty row below What kind of problem could it be? -
having trouble getting desired response from django restframework
I am working on an app based on Flutter (frontend), django (backend), mongodb atlas (database). In my app users can add posts, like, or comment on those posts (just like facebook!) in django my models.py has separate tables for Posts, Reacts on Posts (for like button), comments on posts. here is the code for my models.py class PostsComments(models.Model): commentID = models.AutoField(primary_key=True) content = models.TextField() createTime = models.TextField() updateTime = models.TextField() approved = models.BooleanField(default= True, editable= True) userID = models.ForeignKey('Users', on_delete=models.CASCADE, name="userID") postID = models.ForeignKey('Posts', on_delete=models.CASCADE, name="postID") class PostsReacts(models.Model): reactID = models.AutoField(primary_key=True) createTime = models.TextField() updateTime = models.TextField() react = models.BooleanField(default= False, editable= True) userID = models.ForeignKey('Users', on_delete=models.CASCADE, name="userID") postID = models.ForeignKey('Posts', on_delete=models.CASCADE, name="postID") class Posts(models.Model): postID = models.AutoField(primary_key=True) content = models.TextField() createTime = models.TextField() updateTime = models.TextField() approved = models.BooleanField(default= True, editable= True) hasVideo = models.BooleanField(default= False, editable= True) hasImage = models.BooleanField(default= False, editable= True) #images = ListField(models.TextField) #videos = ListField(models.TextField) images = models.TextField() videos = models.TextField() #comments = [PostsComments()] #reacts = [PostsReacts()] customerID = models.ForeignKey('Customers', on_delete=models.CASCADE, name="customerID") def __str__(self): return f"ID: {self.postID}" view.py from django.http.response import HttpResponseRedirect from rest_framework.decorators import api_view from rest_framework.response import Response from rest_framework.serializers import Serializer #seerializers from .serializers import BookingHistorySerializer, BookingSerializer, CommentsSerializer, CustomerSerializer, ExpertSerializer, PostsSerializer, … -
Ingress routing misses prefix for django redirects
I deployed a Django app in a K8s cluster and have some issues with the routing by Ingress. Ingress config: apiVersion: projectcontour.io/v1 kind: HTTPProxy metadata: name: main namespace: ${namespace} spec: routes: - conditions: - prefix: /my-app services: - name: my-app-backend port: 80 timeoutPolicy: response: 60s pathRewritePolicy: replacePrefix: - replacement: / my-app/urls.py from django.urls import include, path from overview import views app_name = "overview" urlpatterns = [ path("", views.index), path("overview", views.overview) ... ] I have a url like example.com, where the paths are redirected to several K8s services. URL example.com/my-app/ should be resolved to my service "my-app". So far so good, i can see the entry page of my app. But if i start clicking buttons from here, the relative redirects done by Django don't work as expected: A Button click which is expected to navigate me to example.com/my-app/overview, targets to example.com/overview which results in 404 obviously. I would expect a /my-app/ prefix for all redirects in my-app. I'm an Ingress rookie, but i would assume that my-app shouldn't be responsible for this information, as I would have to change two repos when the domain path changes eventually (and i want to avoid routers or hardcoding the url prefixed to /my-app/). … -
ValueError: source code string cannot contain null bytes with django
So, i have been getting this error for a week now, and every time I reopen or resume a django project, then i run a python command like python manage.py runserver i get this unusually error $ python manage.py runserver Traceback (most recent call last): File "C:\kate\manage.py", line 22, in <module> main() File "C:\kate\manage.py", line 11, in main from django.core.management import execute_from_command_line File "C:\Python39\lib\site-packages\django\__init__.py", line 1, in <module> from django.utils.version import get_version ValueError: source code string cannot contain null bytes Meanwhile i saw a solution online that says i should convert it to UTF-8 which i don't know where to change that or convert that since i use pycharm, VS Code and Sublime for my projects -
making a retrieve api for a manytomany field
I am making an API with django rest framework and what it's supposed to do is, it has to return the movies that have a certain genre. And I dont know how to do that. because the film model has a manytomany field called filmGenre and I want to preferably make this api by extending the ModelSerializer class. # Models.py class Genre(models.Model): genreID = models.AutoField(primary_key=True) nameOf = models.CharField(max_length=100, unique=True) details = models.TextField(null=True) class Film(models.Model): filmID = models.AutoField(primary_key=True) title = models.CharField(max_length=150) filmGenre = models.ManyToManyField(Genre) # Serializers.py class GenreRetrieveSerializer(serializers.ModelSerializer): # TO BE DONE can anyone help me with this problem? -
Python ImproperlyConfigured Error - Django
I am trying to use a Flask application to connect to a Django application using this tutorial https://flask.palletsprojects.com/en/2.0.x/patterns/appdispatch/ that uses application dispatching to connect both applications together. But I am receiving an ImproperlyConfigured error when I try to connect three applications together inside vega_flask_run.py. I have tried looking at other posts such as ImproperlyConfigured: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings, django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured, and Set DJANGO_SETTINGS_MODULE as an Environment Variable in Windows permanently and have tried all such solutions accordingly but all my attempts have thus far have failed, for better context, these solutions include setting the DJANGO_SETTINGS_MODULE=veganet.settings using the set command in Windows, changing the PYTHON_PATH to that of my project, and including import utils.file_utils.read_file. Here is the error that I am receiving: Exception has occurred: ImproperlyConfigured Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. File "C:\Users\trevo\OneDrive\Desktop\veganet\profiles\models.py", line 2, in <module> from django.contrib.auth.models import User File "C:\Users\trevo\OneDrive\Desktop\veganet\profiles\forms.py", line 2, in <module> from .models import ExperimentContext, Profile File "C:\Users\trevo\OneDrive\Desktop\veganet\vega_ai\VegaMain.py", line 25, in <module> from profiles.forms import ProfileModelForm, ExperimentModelForm File "C:\Users\trevo\OneDrive\Desktop\veganet\vega_flask_run.py", line 6, … -
TypeError: __call__() got an unexpected keyword argument 'message_id' Dajngo
HTML code <a href="{% url 'front_end:office_message' message_id=message.id %}"><img src="{{message.profile_image.url}}" alt="" /></a> views.py def office_message(request, message_id): message = OfficeStaffMessage.objects.filter(id=message_id) context = {"messages": message} return render(request, "about-us.html", context) urls.py path("messages/<int:message_id>/", office_message, name="office_message"),