Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django reset password get Server Error 500 when deployed to production in Azure
I'm trying to implement a reset password feature in my Django app using django.contrib.auth` like this: from django.urls import path from .import views from django.contrib.auth import views as auth_views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('', views.index, name='index'), path("login", views.login_view, name="login"), path("logout", views.logout_view, name="logout"), path('register', views.register, name='register'), path('admin_main', views.admin_main, name='admin_main'), path('admin_csv', views.admin_csv, name='admin_csv'), path('admin_pdf', views.admin_pdf, name='admin_pdf'), path('reset_password/', auth_views.PasswordResetView.as_view(), name="reset_password"), path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view(), name="password_reset_done"), path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name="password_reset_confirm"), path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(), name="password_reset_complete"), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Everything works just fine during development but in production (Azure App Service) when I introduce the email to reset the password and submit the form, I get "Server Error (500)" and the reset password mail is not send, any idea why could this be? -
Django: tags showing in HTML template even after adding safe tag
I am working on an app. In the HTML template, the text (entered from admin) shows the paragraph tags. I have added the safe tag in my template file. Template file: <div class="container details"> <h5> Category: {{ single.category }} <br> </h5> <h2>{{ single.title }}</h2> <h4> {{ single.content|safe }} </h4> </div> </section> (^^ of course it's got the extends tag and block tag and all that, but this is the part with the error) admin.py from django.contrib import admin from .models import * admin.site.register(Category) admin.site.register(Post) admin.site.register(Tag) Please help 💀 -
Django manage.py runscript causes EOFError when using input()
I am trying to build a script in Django that generates a report based on user input. myscript.py def run(): # analyze some data user_input = input('Enter a value:') # do secondary analysis based on input value When I execute this script with python manage.py runscript myscript, it works until input() is called. "Enter a value:" is printed to the console, but instead of waiting for the user to enter a value, the program terminates with EOFError: EOF when reading a line. What is going on here? Note: Passing arguments to the script with --script-args is not an acceptable workaround because the input value must be determined by the user after the initial data analysis. -
Django two filter
In Django (mongodb), I do two separate filters based on GET requests from my rest api. I'm sure there is data at the intersection of the two filters. However, the result of the two filters has 0 results. Can you check if my filters are wrong? country is manytomanyfield. brand is foreignkey. queryset = Mymodel.objects.all() country = self.request.query_params.get('country', None) brand = self.request.query_params.get('brand', None) if country: queryset = queryset.filter(country__name=country) if brand: queryset = queryset.filter(brand__name__icontains=brand) return queryset -
Transferring user input from one page to another
I am making a website that allows students to find upcoming study sessions for their courses. I am doing this in Django and HTML. A student uploads their courses to the site and they are shown on the courses page as buttons (ex. CS 101 - Intro to CS). When a student clicks on one of their courses (button), it is supposed to bring them to a page that shows available study sessions for that course. I am stuck because I do not know how to properly filter the available study sessions on the next page based on which course is clicked. Is there a way to store the info of the course as a variable so when the button is clicked I can use that variable to filter the results? -
how to send verification email to specific users only in django-allauth
I'm using django-tenants for multi-tenancy,All things are good with allauth package. But the problem is: I've signup form for "subscribers" they must receive an email confirmation and a custom signup form for every "subscribers" to enable them to create users under their subdomains, But the "created users" must receive an email with an initial password not confirmation email. Really I tried many things to perform this mission but with no solution and I searched in many threads here but unfortunately useless, I tried to override def send_mail(self, template_prefix, email, context):, def send_confirmation_mail(self, request, emailconfirmation, signup): and class CustomConfirmEmailView(ConfirmEmailView):. I knew that I've missed something but I don't know what is it. If I send a confirmation email to "subscribers", "created users" affected , And if I change settings to prevent sending confirmation email the "subscribers" affected Also I've a custom login form in adapter.py file to enable users to login with username. class CustomLoginView(LoginView): template_name = 'account/subdomain/login.html' This is my settings ACCOUNT_ADAPTER = 'apps.authentication.adapter.CustomAccountAdapter' AUTH_USER_MODEL = 'authentication.CustomUser' ACCOUNT_FORMS = { 'login': 'apps.authentication.forms.CustomLoginForm', 'signup': 'apps.authentication.forms.CustomUserCreationForm' } LOGIN_REDIRECT_URL = '/' ACCOUNT_LOGOUT_REDIRECT_URL = 'account_login' # created users must redirect to their subdomain login page not public login page ACCOUNT_LOGOUT_ON_GET = True # If … -
Django: How can I create a User view that allows a User to amend or delete their existing bookings
I am developing a restaurant booking service using Django. I have my Model - Views - Templates all working just fine. Now I want to create a view for an authenticated user to view only their existing bookings. In the same view, I would also like them to be able to amend and/or deleted any of their bookings. So far I have managed to get the code right for the authenticated user to only see their bookings but at this point, they cannot do anything with it. models.py; class Booking(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) table = models.ForeignKey(Table, on_delete=models.CASCADE) group_size = models.PositiveIntegerField() date = models.DateField(blank=False) start_time = models.TimeField(auto_now_add=False, blank=False) end_time = models.TimeField(auto_now_add=False, blank=False) comment = models.TextField(blank=True) created_on = models.DateTimeField(auto_now_add=True) approved = models.BooleanField(default=True) def __str__(self): return f'{self.table}. Booked by {self.user} for {self.group_size} people, for the {self.date} at {self.start_time}. Status {self.approved}' views.py; class BookingList(TemplateView): template_name = 'user_booking.html' def get_context_data(self, **kwargs): return super().get_context_data( bookings=self.request.user.booking_set.all(), **kwargs ) html_template; {% for booking in user.booking_set.all %} <h2>{{ booking }}</h2> {% endfor %} output; Table 4, WINDOW. Capacity 4 guests. Booked by admin for 4 people, for the 2022-04-30 at 18:00:00. Status True Table 1, OUTSIDE. Capacity 2 guests. Booked by admin for 2 people, for the 2022-04-30 … -
Django - DRF - Authentication credentials were not provided. - just in Production. What is the cause?
Problem During the deployment of my backend API to Heroku trough Docker container I encounter the following error with status 403(Forbidden) whenever I try to access some data where the user has to be authenticated: { "detail": "Authentication credentials were not provided." } In development everything works as expected. I am aware of the similar question Django Rest Framework - Authentication credentials were not provided. However here the solution is connected with Apache configuration, which strips the AUTHENTICATION header. During the debugging of the issue I found out, the AUTHENTICATION header is available for the application, and in fact the token can be obtained and read without any issue. As a test I have written my own permission class where I have found out, the request.user.is_authenticated line in development gives True but in production gives False with the exact same data and test case. class AuthOrReadOnly(BasePermission): def has_permission(self, request, view): print(request.user.is_authenticated) if request.method in permissions.SAFE_METHODS: return True if request.user.is_authenticated: return True return False SOLUTION to the problem itself I needed to add authentication_classes = (JWTAuthentication,) for my each APIview class where I need to access authenticated content. Example: class RegistrationsForUserView(APIView): permission_classes = [ permissions.IsAuthenticatedOrReadOnly, ] authentication_classes = (JWTAuthentication,) serializer_class = … -
django.contrib.auth.models.User.customer.RelatedObjectDoesNotExist: User has no customer. thats my bug imy ecommerce web app
def cart(request): if request.user.is_authenticated: customer = request.user.customer order, created = Order.objects.get_or_create(customer=customer, complete= False) items = order.orderitem_set.all() else: items = [] context = {'items':items} return render(request,'store/cart.html', context) that is my add to cart code but it still display that there is no related object -
The problem with my code is forcing the user to change the image also when he want to change only content or title of his article
Hello everyone I have project blog platform the user can add,and edit blog. The blog contain (title, slug, contenet, image), I used Django and Django Rest Framework to build website, and for frontend ReactJS. my problem is when I edit blog I couldn't edit blog until change image but for content and title I can change one of them while I can't update blog until I change the image, This is an error when just update title without change image model.py def upload_path(instance, filename): return 'img/{filename}'.format(filename=filename) class Blog(models.Model): title = models.CharField(max_length=250) slug = models.SlugField(max_length=250, unique=True, null=True) content = models.TextField() published = models.DateTimeField(default=timezone.now) author = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='blog_blog') objects = models.Manager() # default manager image = models.ImageField(_("Image"), upload_to=upload_path, null=True) class Meta: def __str__(self): return self.title view.py class EditBlog(generics.UpdateAPIView): permission_classes = [permissions.IsAuthenticated, IsOwnerOrReadOnly] serializer_class = BlogSerializer queryset = Blog.objects.all() in React edit.js import React, { useState, useEffect } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import axiosInstance from '../../../axios'; import WriteCss from '../../../assets/CSSStyle/WriteBlog.module.css'; import { Image } from 'antd'; export function Edit() { const navigate = useNavigate(); const { id } = useParams(); const initialFormData = Object.freeze({ title: '', slug: '', content: '', }); const [formData, updateFormData] = useState(initialFormData); … -
How to convert string to List in python
how to convert string data to list in python, Scenario is when a user enters data it will be in String after that how to convert it into List. user enters => ip1: 1.2 ip2: 3.2 After entering it will becomes "['1.2', '3.2']" Here is how to convert the above string value to List for looping the values further. how to get Output => ['1.2','3.2'] -
Show messages using django messages framework from one particular view
I'm using Django messages framework to show a success message in my contact page template when contact form submission is succeed. since installed app, middlewares and context processor for messages are set in settings.py all the messages that are being generated showing in my contact template, for instance, Login success, logout success, and so on. I just want to show the message.success in the contact templete that I defined in contact view: def contact(request): if request.method == 'POST': Contact.objects.create( first_name=request.POST.get('first_name', ''), last_name=request.POST.get('last_name', ''), email=request.POST.get('email', ''), subject=request.POST.get('subject', ''), message=request.POST.get('message', ''), ) # I want to show only this message on 'POST' success of this view messages.success(request, "Your message has been submitted.") return render(request, 'contact/contact.html') my template: <div class="success-message"> {% if messages %} <ul class="messages"> {% for message in messages %} <li class="{{ message.tags }}"> <h4 class="alert-success text-center" style="padding-top: 5px; padding-bottom: 5px;"> {{ message }} </h4> </li> {% endfor %} </ul> {% endif %} </div> my template is showing all the messages that are being generated throughout the website along with the one that I want. how to prevent other messages except the one that I want? What is the workaround for this problem, Can somebody help me through this? -
Django | Ordering - How to implement "ordering" when you use @property
please help me to make the correct "ordering" for a "custom" property some_property_field. I write such an URL and it doesn't work. I understand the reason is a "custom" property. How to work it out? /api/articles/?ordering=-some_property_field models.py class Article(models.Model): title = models.CharField(max_length=20) description = models.TextField() def __str__(self): return self.title @property def some_property_field(self): return f'{self.title} property func' views.py class ArticleViewSet(viewsets.ModelViewSet): serializer_class = ArticleSerializer queryset = Article.objects.all() filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter,) ordering_fields = ('id', 'title',) ordering = ('id',) # default ordering serializers.py class ArticleSerializer(serializers.ModelSerializer): some_property_field = serializers.CharField(read_only=True) class Meta: model = Article fields = '__all__' -
Django Crispy Forms: Apply a custom title attribute to each error
Situation To inject errors into my registration form, I do some checks in my form class's clean methods (e.g. clean_email(), etc.) and call form.add_error('attribute', 'error message'). I render my forms with django-crispy-forms by using the {% crisy form %} template tag. What I want to do is to set custom title attributes for the error messages which get rendered in span tags. I would prefer to be able to do that within the Django form itself, if possible, but if there is another way, I am open to that as well. Example For example, instead of... <span id="error_1_id_password" class="invalid-feedback"><strong>Password must have an uppercase and a lowercase letter</strong></span> <span title="Password 1 error" id="error_1_id_password" class="invalid-feedback"><strong>Password must have an uppercase and a lowercase letter</strong></span> I have looked at some of the documentation for FormHelper but I don't see any mechanism that will let me apply specific title attributes to each error message. The Current HTML Form The HTML that gets rendered for the form is (notice in particular, the span tags with the errors): <form action="/users/register/" method='post'> <input type="hidden" name="csrfmiddlewaretoken" value="dU7WZ5jCZExYw10TZs6xke4cSj6jFpXZq285IJM3KILHKeGlilkNkAdozSrzAMno"> <div class="form-row"> <div class="col-md"> <div id="div_id_first_name" class="form-group row"> <label for="id_first_name" class="col-form-label col-25 fs-400 ff-sans-normal requiredField">First name<span class="asteriskField">*</span></label> <div class="col-75"> <input type="text" name="first_name" … -
How can I install new product logic in Django?
In Django, when the product is newly added, I want the new product to be named for about 1 week and appear on the new products page. How can I build the logic of this? model.py class Product(models.Model): name = models.CharField(max_length=100) category = models.ForeignKey(Category, on_delete=models.DO_NOTHING) main_image = models.ImageField(upload_to='static/product_images/%Y/%m/%d/') detail = models.TextField() keywords = models.CharField(max_length=50) description = models.CharField(max_length=1000) price = models.FloatField() brand = models.CharField(max_length=50, default='Markon', verbose_name='Brand (Default: Markon)') sale = models.IntegerField(blank=True, null=True, verbose_name="Sale (%)") bestseller = models.BooleanField(default=False) amount = models.IntegerField(blank=True, null=True) available = models.BooleanField(default=True) stock = models.BooleanField(default=True) date_created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name @property def discount(self): dis = float(self.price - (self.price * self.sale) / 100) ln = '' if len(str(dis)) > 3: for i in str(dis): ln += i dis = float(ln) if len(ln) > 3: break return dis -
How to get the value of a radio button in django
I am learning django. I am stuck with this problem. I want to create an upload form which has a field for gender. SO basically, it has radio buttons for male and female. Please note that I have not created forms.py file I just created a template in HTML and the rest of the processing happens in the views.py file. So, I want to know how can I pass the value of the radio button to the views.py file. I have seen some tutorials and articles but they seem to be too complicated and also use forms.py file. Is there anything simpler. I am a newbie and any help will be appreciated. -
Django primary key url issues
I am makeing a simple blog project. In my project, there is one page where there is a list of all the blog posts. If you click on the title of the post you are taken to the post. I used (?P\d+) I the URL path so the user would be directed to the correct post. However, this did not work. Any help would be much appreciated. all_posts.html {% extends "base.html" %} {% block content %} <div class="container"> <h1>Blog Posts</h1> </div> <div class="container"> {% for blog_post in object_list %} <table class="table table-striped"> <ul class="list-group"> <li><a class="btn btn-primary" href="{% url 'blog_app:view' pk=blog_post.pk %}">{{ blog_post.post_title }}</a></li> </ul> </table> {% endfor %} </div> {% endblock %} modles.py from django.db import models # Create your models here. class Blog_Post(models.Model): slug = models.SlugField(max_length=1000, editable=False, null=True) post_title = models.CharField(max_length=100, editable=True, blank=False, null=True) blog_content = models.TextField(max_length=10000, blank=False, editable=True, null=True) files = models.FileField(blank=True, null=True, upload_to=True) date = models.DateTimeField(blank=False, null=True, auto_now=True, editable=False) likes = models.IntegerField(blank=True, null=True, editable=False) urls.py from django.urls import path from . import views app_name = "blog_app" urlpatterns = [ path('create/', views.create_blog_post.as_view(), name='create'), path('view/(?P<pk>\d+)/', views.view_blog_post.as_view(), name='view'), path('all_posts/', views.all_blog_posts.as_view(), name='all'), path('delete/<slug:slug>', views.delet_blog_post.as_view(), name='delete') ] -
Django AllAuth resent password even if the password is not in the database
How do I prevent django-allauth from sending password recovery emails to emails not registered in the database? -
django convert function view to class view
I have a problem converting from a function-based view to a class-based view, function VIEWS.PY @ login_required def favourite_add(request, id): post = get_object_or_404(Perfumes, id=id) if post.favourites.filter(id=request.user.id).exists(): post.favourites.remove(request.user) else: post.favourites.add(request.user) return HttpResponseRedirect(request.META['HTTP_REFERER']) URLS.PY urlpatterns = [ path('fav/<int:id>/', views.favourite_add, name='favourite_add'), ] TEMPLATE.HTML <div> <a href="{% url 'favourite_add' perfume.id %}" class="btn btn-outline-primary">Add</a> </div> In general, the goal is to get the id of a certain perfume on the page, and using the get_object_or_404 function, I'm pulling its object from the Perfumes database - the post variable. Next, I want to retrieve the id of the logged-in user and check if the id of the above user is in the favourites section of the post variable. If not then add, otherwise remove the user id to the favourites section of the post variable. -
Django URL errors
I'm learning Django and I encountered some URL issues that I can't solve. I think it's a URL problem so I'm not sure if the views are needed, but I post them anyway(I'm kind of desperate) The first problem is that when I try to log in with wrong credentials, I get an error. TemplateDoesNotExist at /home/login/ registration/login.html Request Method: GET Request URL: http://127.0.0.1:8000/home/login/ Django Version: 3.2.12 Exception Type: TemplateDoesNotExist Exception Value: registration/login.html Exception Location: C:\Users\dell\ofaw\lib\site-packages\django\template\loader.py, line 47, in select_template Python Executable: C:\Users\dell\ofaw\Scripts\python.exe Python Version: 3.7.0 Python Path: ['C:\\Users\\dell\\Desktop\\OneForAll\\Django website\\ofaw', 'C:\\Users\\dell\\ofaw\\Scripts\\python37.zip', 'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\dell\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\dell\\ofaw', 'C:\\Users\\dell\\ofaw\\lib\\site-packages'] Server time: Sat, 09 Apr 2022 18:43:41 +0000 Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.app_directories.Loader: C:\Users\dell\ofaw\lib\site- packages\django\contrib\admin\templates\registration\login.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\Users\dell\ofaw\lib\site- packages\django\contrib\auth\templates\registration\login.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\Users\dell\ofaw\lib\site- packages\crispy_forms\templates\registration\login.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\Users\dell\Desktop\OneForAll\Django website\ofaw\register\templates\registration\login.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\Users\dell\Desktop\OneForAll\Django website\ofaw\profiles\templates\registration\login.html (Source does not exist) In terminal. django.template.exceptions.TemplateDoesNotExist: registration/login.html [09/Apr/2022 19:43:41] "GET /home/login/ HTTP/1.1" 500 79486 The thing is registration folder was in my first app Templates but I delete it, I don't even know why is still showing it. I use to have an HTML form with action="register" that directed me to … -
Django, request.user prints AnonymousUser, even if i logged in
views.py class StorageView(viewsets.ModelViewSet): serializer_class = StorageSerializer def get_queryset(self): if self.request.user.is_authenticated: user = self.request.user queryset = Storage.objects.filter(username=user.username) return queryset else: print(self.request.user) return [] urls.py from django.urls import path, include from django.urls import re_path as url urlpatterns = [ path('auth/', include('rest_auth.urls')), path('auth/register/', include('rest_auth.registration.urls')) ] settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # CORS 'corsheaders', # REST 'rest_framework', 'rest_framework.authtoken', 'rest_auth', 'rest_auth.registration', 'django.contrib.sites', # App 'backend' ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', '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', ] SITE_ID = 1 ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_SESSION_REMEMBER = True ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_UNIQUE_EMAIL = True REST_FRAMEWORK = { 'DATETIME_FORMAT': "%m/%d/%Y %I:%M%P", 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.TokenAuthentication', ], } I logging in via form or api, but is_authenticated method don't see me Login via api postman screenshot Condition in get_queryset() function in views.py always evaluates to false, even if i logged in it keeps printing "AnonymousUser", why? How to check if user is logged in, in my case? -
Django migration error in heroku postgres
I've just deployed my Django website on Heroku and while running the command to make migrations it shows a lot of migrations to apply but when I try to migrate it, it says no migrations to apply. Here's a photo of it. -
Django 3 claims column does not exist after fixing database manually with pqsl
Something went wrong with the migrations and now, even when I run makemigrations I get: django.core.exceptions.FieldDoesNotExist: mq.pipeline has no field named 'mq_pipepline_id' I used psql to change this particular column name from mq_pipeplineid to mq_pipepline_id. To fix what seemingly went wrong, running: psql \c myapp ALTER TABLE mq_pipeline RENAME COLUMN mq_pipeplineid TO mq_pipepline_id; And I can see the changes. I quit qsql and entered it again to make sure the changes are persistent. Now, the table definitely has that column, but strangely I still get the same error. Is the error not referring to the database itself, but to the migration files? -
Django date field derived from timestamp field
I have a created_date field: class Comment(models.Model): created_date = models.DateTimeField(auto_now_add=True) I want a field derived from created_date that ideally exists in the model. I know in SQL I can do: SELECT created_date::date FROM Comment How would I define that in the Django model? -
What's wrong with GraphQL theme?
I'm learning GraphQL now on my test project with Django, and can't understand where the problem is. Here is my models.py class Teacher(models.Model): full_name = models.CharField(max_length=70, verbose_name="Full name") subject = models.ManyToManyField( "Subject", related_name="teacher_subject", verbose_name="Subject" ) def __str__(self): return self.full_name class Subject(models.Model): name = models.CharField(max_length=100, verbose_name="Subject name") def __str__(self): return self.name class Meta: verbose_name = "Subject" verbose_name_plural = "Subjects" ordering = ["name"] class Student(models.Model): full_name = models.CharField(max_length=70, verbose_name="Full name") subject = models.ManyToManyField( "Subject", related_name="student_subject", verbose_name="Subject" ) avg_grade = models.FloatField(verbose_name="Average grade") def __str__(self): return self.full_name Here is schema.py import graphene from graphene_django import DjangoObjectType from graphene_django.filter import DjangoFilterConnectionField from graphql_app.models import Student, Subject, Teacher class TeacherType(DjangoObjectType): class Meta: model = Teacher # fields = ("id", "full_name", "subject") filter_fields = { 'id': ['exact'], 'full_name': ['exact', 'icontains', 'istartswith'], } interfaces = (graphene.relay.Node,) class SubjectType(DjangoObjectType): class Meta: model = Subject # fields = ("id", "name") filter_fields = {'name': ['exact', 'icontains', 'istartswith']} interfaces = (graphene.relay.Node,) class StudentType(DjangoObjectType): class Meta: model = Student # fields = ("id", "full_name", "subject") filter_fields = { 'id': ['exact'], 'full_name': ['exact', 'icontains', 'istartswith'], } interfaces = (graphene.relay.Node,) class Query(graphene.ObjectType): teacher = graphene.relay.Node.Field(TeacherType) subject = graphene.relay.Node.Field(SubjectType) student = graphene.relay.Node.Field(StudentType) teachers = DjangoFilterConnectionField(TeacherType) subjects = DjangoFilterConnectionField(SubjectType) students = DjangoFilterConnectionField(StudentType) def resolve_teacher(self, info, **kwargs): num …