Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to enable CORS for django project in EC2 aws instance?
How to enable CORS in Amazon AWS EC2 instance for Django project. I have developed the project using Docker which I can run in two modes. Developed modes: Development mode: It runs Django's built in server for project and media/staticfiles delivery Production mode: It runs NGINX for project and media/staticfiles delivery I have used CORS_ORIGIN_ALLOW_ALL = True for first option, but I still have following issue Access to XMLHttpRequest at 'http://ec2-18-191-33-108.us-east 2.compute.amazonaws.com:8000/api/achievements/list/' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. And I have used following nginx.conf for production mode. # # Wide-open CORS config for nginx # upstream hello_django { server web:8000; } server { listen 80; location / { proxy_pass http://hello_django; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If- Modified-Since,Cache-Control,Content-Type,Range'; # # Tell client that this pre-flight info is valid for 20 days # add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, … -
Check login without refreshing
how I can modify my code that be check login&password without refreshing? Ajax call function in django to check login and password then send .json with result. Next one I want display error in js if result is failed or play animation if it's true. js code: function CheckBeforeSend() { var LoginInput = document.getElementById('flogin'); if(LoginInput.value.match(/^[a-zA-Z]+['.']+[a-zA-Z]+[0-9]+$/) == null) { if(document.getElementById('Windows').childElementCount > 2) { document.getElementById('Windows').children[0].remove(); } AddPicture("paperJsConn"); } else { document.getElementById("button").type = "submit"; $.ajax({ url: 'http://127.0.0.1:8000/', data: $('#login_form').serialize(), type: "POST", async:false, success: function(response) { var CheckingCorrect = response['result']; //if checkingcorrect play func animation. }, error: function(error){ alert('No Connection!'); } }); } } $('#login_form').submit(function(e){ e.preventDefault(); $.post('view-url', $(this).serialize()); }); // this event dont work. views.py: def Logget(request): if request.method == 'POST': login = request.POST.get('flogin') response_data = {} response_data['result'] = 'Failed' lengthBase = UsersLog.objects.count() for i in range(lengthBase): if login == str(UsersLog.objects.get(id=i+1)): password = request.POST.get('lpass', False) if str(password) == str(UsersLog.objects.get(id=i+1).password): response_data['result'] = 'Succes' break return JsonResponse(response_data) return render(request, 'index.html') -
I want to save textarea in Django with space characters
I want to save textarea in Django with space characters. for example I want to be saved like this 1. A BC D E 2. 1000 2000 The result is saved and viewed 1. A BC D E 2. 1000 2000 The source code above is my form. class createPlanForm(forms.ModelForm): class Meta: model = plan_models.Plan fields = [ "title_for_plan", "contents_for_plan", ] widgets = { "title_for_plan": forms.TextInput(attrs={"placeholder": "title"}), "contents_for_plan": forms.Textarea(attrs={"placeholder": "contents"}), } If you have any additional things you need to do in Django, please let me know. I wish you could let me know if there is a way:) -
if statement not working properly in django templates
i want to redirect button in questions page except for last page ,so i used this code views.py def question_detail(request,question_id,quiz_id): q = Quiz.objects.get(pk=quiz_id) que = q.question_set.get(pk=question_id) ans = que.answer_set.all() count = q.question_set.count() come = que.rank came = come + 1 later_question = q.question_set.get(rank=came) return render(request, 'app/question_detail.html', {'que': que, 'later_question': later_question, 'ans': ans, 'count':count}) question_detail.html {% if later_question > count %} <button><a href="{% url 'app:detail' quiz_id=que.quiz.id question_id=later_question.id%}">Question {{later_question.rank}}</a></button> {% else %} <button><a href="">result</a></button> {% endif %} this code showing result button on every page -
Why is my multiple select form field only submitting one value Django?
Having trouble getting this form to submit/save multiple inputs from my multiple select form field... def StaffHome(request): dates = request.user.availability_set.all() bookings = request.user.booking_set.all() if request.method == 'POST': if 'remove' in request.POST: form = RemoveDate(request.user, request.POST) if form.is_valid(): for d in form.cleaned_data['date']: for i in dates: if d == str(i.dates): i.delete() return redirect('main-home') elif 'add' in request.POST: form = AddDate(request.user, request.POST) if form.is_valid(): for d in form.cleaned_data['date']: Availability.objects.create(user=request.user, dates=d) return redirect('main-home') context = { 'today': datetime.datetime.now().date(), 'bookings': bookings, 'form': AddDate(request.user), 'form2': RemoveDate(request.user), 'dates': dates } return render(request, 'users/staffhome.html', context) I tried using request.POST.getlist('date') but that was throwing a method object not subscriptable error. -
install issue with pip
when i install a package with pip, pip show the successful message but i can't import it and i can't add it to INSTALLED_APPS, the program does not recognize it pip install django-ckeditor WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly. WARNING: The directory '/home/def/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Requirement already satisfied: django-ckeditor in /home/def/.local/lib/python3.6/site-packages (5.9.0) Requirement already satisfied: django-js-asset>=1.2.2 in /home/def/.local/lib/python3.6/site-packages (from django-ckeditor) (1.2.2) -
How do I chart Unix dates on a Bokeh chart correctly?
I'm trying to get datetime data on the x-axis of the chart pictured below. Currently the time data is in Unix format from a list: [1586088239188, 1586091716319, 1586095462692, ...] Here's the code in a Django view that I'm outputting to a Django template. I'd like to convert each of the list date elements into a human readable date format. I was able to get as close as: "2020-04-12 03:01:47.708000" but that wouldn't chart on the x-axis. here's the Django def view code with the chart output below: def chart(request): chart_endpoint = "https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=7" request_chart_data = requests.get(chart_endpoint) results_chart_data = request_chart_data.json() chart_data = results_chart_data['prices'] #print(chart_data) price = [item[1] for item in chart_data] price_date = [item[0] for item in chart_data] p = figure(title='Line Plot Price and Date', x_axis_label='x', y_axis_label='y') p.line(price_date, price) script, div = components(p) return render(request, 'crypto/chart.html', {'script': script, 'div': div}) Here's my attempt at the date converion and the chart output of that result below. As you can see, all the dates are 1.587e+12 etc... def chart(request): chart_endpoint = "https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=7" request_chart_data = requests.get(chart_endpoint) results_chart_data = request_chart_data.json() chart_data = results_chart_data['prices'] #print(chart_data) price = [item[1] for item in chart_data] price_date = [item[0] for item in chart_data] for num in price_date: price_date_formatted = datetime.datetime.fromtimestamp(num / … -
django: automatic tenant schema recognition in SQLalchemy
In my django app, I am processing data that the user input on the website and I am using SQLalchemist to populate the postgresql database as follow: engine = create_engine('postgresql://myname:mypassword@local:5432/mydb') DB = df555.to_sql('dashboard_items', engine, if_exists='replace') the issue that I encounter is this populates the public schema. From the document, I can use a 'schema' argument, however this action needs be performed for any tenant, so I am stucked there because I cannot specify one particular schema in the arguments. I was wondering if anyones knows a way to work around that and get sqlalchemy to automatically detect which tenant schema to populate -
Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index' in authentication
I am trying to make a user authentication in Flutter but i am having the error saying "Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index' " static Future<User> loginUser(String email,String password) async { WidgetsFlutterBinding.ensureInitialized(); SharedPreferences prefs = await SharedPreferences.getInstance(); final http.Response response = await http.get("myurl/accounts/users/", headers: {'Content-Type': 'application/json', HttpHeaders.authorizationHeader: "mytoken"}, ); if (response.statusCode == 200) { final jsonResponse = json.decode(response.body); List<User> users = jsonResponse[jsonResponse['User']] as List<dynamic>; } else { throw Exception('Failed to login '); } } -
DJANGO - Get field value of a GET form
I have a get form to display a filtered table (django-filter). When I click on search my URL look like http://127.0.0.1:8000/data/?Category=2&Item=3 My question is : how can I get the value of category and item (final goal is to export this table in excel) Related question DJANGO -Extract filtered data -
Django: show different list based on 'a' tag click
In my Django website I'd like the user to be able to choose to show two different lists, one at a time but on the same page, based on the click of the user on a 'a' tag? Hope someone could help! If it isn't possible to do so, is there a different way I can achieve it? I really don't know what should I change. Thanks a lot! views.py class searchesView(TemplateView): template_name = "search/searches.html" def post(self, request, *args, **kwargs): print('FORM POSTED WITH {}'.format(request.POST['srh'])) srch = request.POST.get('srh') if srch: sr = Info.objects.filter(Q(band__icontains=srch)) sd = Info.objects.filter(Q(disco__icontains=srch)) sp = Info.objects.filter(Q(band__icontains=srch) & Q(disco__icontains=srch)) #if sr.exists() and sd.exists(): #return render(self.request, 'search/searches.html') #else: paginator = Paginator(sr, 10) page_number = request.GET.get('page') page_obj = paginator.get_page(page_number) return render(self.request, 'search/searches.html', {'sr':sr, 'sd': sd, 'sp':sp, 'page_obj': page_obj }) else: return render(self.request, 'search/searches.html') template: {% if sp %} <a href="{%url 'searches' sd%}" >Band: {{ request.POST.srh }}</a><br/> <a href="{%url 'searches'%}" >Album: {{ request.POST.srh }}</a> {% else %} {% if sd %} {% for y in sd %} <div class="container"> <div class="album"> {%if y.cover%} <img src= "{{y.cover.url}}" width="100%"> {%endif%} </div> <div class="info"> <table class="talbum" style="height:400px"> <tr><th colspan="2"><h2>{{y.disco}}</h2></th></tr> <tr><td> Band: </td><td> {{y.band}} </td></tr> <tr><td> Anno: </td><td> {{y.anno}} </td></tr> <tr><td> Disco: </td><td> {{y.disco}} </td></tr> <tr><td> … -
Django ManyToManyField renders as object() instead of description
I am using Django's ManyToManyField so that my user may make select multiples from check boxes. This all seems to be working and saving correctly except that the display is showing "Choice Object(1)" instead of the description. models.py: class Choice(models.Model): description = models.CharField(max_length=20) def __unicode__(self): return unicode(self.description) class Person(models.Model): name = models.CharField(max_lenght=20) choice = models.ManyToManyField(Choices) #disciplines offered by an academy def __unicode__(self): return self.name forms.py class PersonForm(models.ModelForm): class Meta: model=Person fields=('name','choice') person_update_form.html {% block content %} <form method="post" enctype="multipart/form-data" novalidate> {% csrf_token %} {{ form.name }} {{ form.choice }} <button type="submit" class="btn btn-success">Save Person</button> </form> {% endblock %} My Choice Database has 3 entries: 'Red', 'Green', 'Blue'. (ie description = 'Red') When I render my form, instead of seeing a box with: 'Red' 'Green' 'Blue' I see a box with: Choice Object(1) Choice Object(2) Choice Object(3) Anyone know how to get the display to show the descriptions instead of the object? Thanks in advance. -
Django - limit choices to foreign key
I have the following model in Django class Transfer(models.Model): user = models.ForeignKey(User, on_delete=models.PROTECT, limit_choices_to={'is_accepted':True}) amount = models.IntegerField(default=0) transfer_date = models.DateTimeField(default=timezone.now) company = models.ForeignKey(Company, on_delete=models.PROTECT) I would like to filter the users based on is_accepted field. The problem is, that this field is declared in a model called Employee, which is in onetoone relationship with user. Is there any possibility to reach Employee fields and filter them in this manner? -
Django Database Routers not routing to the correct database
I'm writing a dashboard to maintain different apps. Therefor I want to be able to access seperate databases on the server. The final step to get this all working is to setup database routing. However, I end up with having every table in the default database, and none in the app database for my tour-app for example. settings.py DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.contrib.gis.db.backends.mysql', 'OPTIONS': { 'read_default_file': os.path.join(CONFIG_DIR, 'apps.cnf'), }, }, 'morapps': { #'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.contrib.gis.db.backends.mysql', 'OPTIONS': { 'read_default_file': os.path.join(CONFIG_DIR,'apps.cnf'), }, }, 'tourdb': { #'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.contrib.gis.db.backends.mysql', 'OPTIONS': { 'read_default_file': os.path.join(CONFIG_DIR,'tourdb.cnf'), }, } } DATABASE_ROUTERS = ['dbrouter.DbRouter'] DATABASE_APPS_MAPPING = {'contenttypes': 'default', 'auth': 'default', 'admin': 'default', 'sessions': 'default', 'messages': 'default', 'staticfiles': 'default', 'tour_admin': 'tourdb', } dbRouter.py class DbRouter(object): def db_for_read(self, model, **hints): "Point all operations on tour_admin models to 'tourdb'" print("1 label: "+model._meta.app_label) if model._meta.app_label == 'tour_admin': print("test1") return 'tourdb' return 'default' def db_for_write(self, model, **hints): "Point all operations on tour_admin models to 'tourdb'" print("2 label: " +model._meta.app_label) if model._meta.app_label == 'tour_admin': print("test2") return 'tourdb' return 'default' def allow_relation(self, obj1, obj2, **hints): "Allow any relation if a both models in tour_admin app" print("3 label: " +obj1._meta.app_label+"|"+obj2._meta.app_label) if obj1._meta.app_label == 'tour_admin' and obj2._meta.app_label == 'tour_admin': print("test3") … -
Getting "Authentication credentials were not provided." message when trying to access my ModelViewSet URL
I am creating an application using Django Rest Framework and using Token based authentication. I have a PlaceViewSet class inheriting from ModelViewSet. I want both list and retrieve to work even if there is no token sent by the user whereas create, destroy and update should be allowed only if the user has sent the Token. But I am getting "Authentication credentials were not provided." for requests of all types. I also want to stick to the REST standard so that the list, retrieve, update, create, destroy comes under the same model view set. In case if DRF does not allow any requests without Token if I have set my default authentication as TokenAuthentication then why I am able to access the signin and signup views? -
UWSGI Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'
I am trying to deploy my django app using uWSGI and have been following this However I get an error when I try to start my app using the uwsgi --ini book_uwsgi.ini command. The error that I am getting is Python version: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] Set PythonHome to /home/book/book/ Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings' and my book_uwsgi.ini # Django-related settings # the base directory (full path) chdir = /home/book/bookAPI # Django's wsgi file module = ohako.wsgi # the virtualenv (full path) home = /home/book/book # process-related settings # master master = true # maximum number of worker processes processes = 10 # the socket (use the full path to be safe socket = /tmp/bookAPI.sock # ... with appropriate permissions - may be needed # chmod-socket = 664 # clear environment on exit vacuum = true Inside /home/book/book there are four folders bin include lib local share. I am completely lost and have been tackling this problem for days. Any help is appreciated. -
Django - NoReverseMatch error with two slugs into a template URL
I am creating a Django site where the URL's feature multiple slugs: www.example.com/app-name/country_slug/area_slug E.g. www.example.com/destinations/united-states/new-york I have the URL pattern working fine using this code in urls.py: urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('<slug:country_slug>/', views.CountryView.as_view(), name='country'), path('<slug:country_slug>/<slug:area_slug>/', views.AreaView.as_view(), name='area'), ] If I enter the url into the browser address bar, I can access the page without problems. The issue comes with the template for the view 'country'. I am struggling to create a link to the 'area' page, as this need to reference both the 'country_slug' and 'area_slug' in the {% url %} tag. Here is the error I am getting: NoReverseMatch at /destinations/united-states/ Reverse for 'area' with arguments '('', '')' not found. 1 pattern(s) tried: ['destinations/(?P<country_slug>[-a-zA-Z0-9_]+)/(?P<area_slug>[-a-zA-Z0-9_]+)/$'] Here is the code I am using in the template: {% if latest_area_list %} <ul> {% for area in latest_area_list %} <li><a href="{% url 'destinations:area' country.country_slug area.area_slug %}">{{ area.area_name }}</a></li> {% endfor %} {% endif %} And the View: class CountryView(generic.ListView): template_name = 'destinations/country.html' context_object_name = 'latest_area_list' slug_field = 'country_slug' slug_url_kwarg = 'country_slug' def get_queryset(self): self.country = get_object_or_404(Country, country_slug=self.kwargs['country_slug']) return Area.objects.filter(country=self.country) class AreaView(generic.ListView): template_name = 'destinations/area.html' context_object_name = 'latest_place_list' slug_field = 'area_slug' slug_url_kwarg = 'area_slug' def get_queryset(self): self.area = get_object_or_404(Area, area_slug=self.kwargs['area_slug']) return Place.objects.filter(area=self.area) … -
How to deal with 2 kinds of user in system
I'm building a website that allows for people to rent rooms. In my website, I serve 2 kind of users. The first one is people who want to rent a room and the second is the host of room. Is it necessary to create 2 models like user(guess) and member(host) for those users in Django because each model will related with difference models in my database. I also want to create separate profile for those model. And how to do that in django? -
DJANGO -Extract filtered data
I have a django-filter (OrderFilter) to display a filtered table, now I want to extract to excel the same filtered table. My code works but the data is not filtered. Can you help please ? Views.py def Order(request): filter= OrderFilter(request.GET, queryset=Order.objects.all()) orders= filter.qs.order_by('-Date') """ Don't work Category_query = request.GET.get(filter.Category) qs = Order.objects.filter(Category= Category_query) """ if request.GET.get('Export') == 'Export': response = HttpResponse(content_type='application/ms-excel') response['Content-Disposition'] = 'attachment; filename="data.xlsx"' wb = xlwt.Workbook(encoding='utf-8') ws = wb.add_sheet('Data') row_num = 0 font_style = xlwt.XFStyle() font_style.font.bold = True columns = ['Date', 'Category', 'Item'] for col_num in range(len(columns)): ws.write(row_num, col_num, columns[col_num], font_style) font_style = xlwt.XFStyle() rows=qs.values_list('Date', 'Category', 'Item') for row, rowdata in enumerate(rows): row_num += 1 for col, val in enumerate(rowdata): if isinstance(val,datetime.date): val = val.strftime('%d/%m/%Y') ws.write(row_num, col, val, font_style) wb.save(response) return response return render(request, 'template.html',{'orders':orders,'filter': filter}) template.html <form method="get"> {{filter.form}} <button class="btn btn-primary" type="submit">Search</button> </form> <form method="GET" > <button class="btn btn-warning" type="submit" value="Export" name="Export"> Export</button> </form> -
Apache 403 loading video through HTML5 Video player
I have an Django application that streams videos. The application uses drf_firebase_auth. I have tested streaming videos using Postman, the Python requests library, and through the HTML5 video player (using cookie authentication after a sign-in process). When the application is run locally, video streaming works when called by Postman, Python requests library, and the HTML5 player. When the application is run on AWS, video streaming works through Postman and the Python requests library, but it fails with a 403 when trying to stream through the HTML5 video player. During debugging I put print statements in the drf_firebase_auth code. The print statements appear in the apache error log when the video is streamed (i.e. through postman or Python requests), but not when called from the HTML5 player. That seems to indicate that the 403 is happening before getting to Django. Any debugging guidance is appreciated. Thanks. -
How to get a parent from a child FK?
models.py class Product(models.Model) name = models.CharField() class User(models.Model) name = models.CharField() class List(models.Model) user = models.ForeignKey(User) class Item(models.Model) name = models.CharField() list = models.ForeignKey(List) user = models.ForeignKey(User) product = models.ForeignKey(Product) views.py class ListView(View) def get(self, request, pk) list = List.objects.get(id=pk) return render(request, "list.html", {"list" : list}) list.html {% for item in list.item_set.all %} {{ item.name }} {{ item.user.name }} - ?? {{ item.product.name }} - ?? {% endfor %} How get user.name и product.name? I tried it: {% item.user_set.first.name %} - does not work {% for user in item.user_set.all %}{{ user.name }}{% endfor %} - does not work Model method: def get_user(self): self.user_ser.get() #does not work How do I solve this problem? -
Django. Show error message on current page
Help me please! I'm trying to show error message: In forms: def clean_form(self): url = self.cleaned_data['text'] if url == 'qwe': raise ValidationError("Error") return self.cleaned_data In view: def main_site(request): if request.method == 'POST': form = Form(request.POST or None) if form.is_valid(): form.clean_form() link = form.cleaned_data['text'] ... But when I send 'qwe' in form: And press 'send'. Take: But I want to see Error on same page. What's I should be do? Thank you! -
Fields with NULL and blank values
I'm writing my first Python web application. My code is difficult because it often needs to treat fields separately if they contain a blank value (object.propery = '') and a Null value (object.property = None). Is there a simple way of dealing with these two values as one? I've noticed some languages have a isNullorEmpty() function. I've also noticed that if a DB field is set to contain numbers then assigning a blank value to the field just makes it Null (convinient :-) -
Subdomain www.example.com and root doman example.com with django-allauth with a single SITE_ID
We are using django-allauth to enable login with Twitter. As far I as am aware the following must match: SITE_ID = 1 so the site used in the social login must have id = 1 Twitter login callback must of the form http://www.example.com/accounts/twitter/login/callback/ The user must be visiting the application via example.com not example.herokuapp.com I am wondering how to handle root domain example.com and www.example.com, what should the domain of the site be? Links SITE_ID (https://docs.djangoproject.com/en/3.0/ref/settings/#site-id) -
Django api filter search on other models without a direct foreign field
I have two models named user, skill, and profile. I am trying to implement a search filter on the user's skills. which means when someone searches for something that is contained in the skills of a user, that user would appear in the search result. Note: when the user signs up, a signal is used to auto-create a profile for that user. The user simply updates their profile to add skills and other things. user model class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(max_length=254, unique=True) name = models.CharField(max_length=250) picture = models.TextField(null=True, blank=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=True) last_login = models.DateTimeField(null=True, blank=True) date_joined = models.DateTimeField(auto_now_add=True) slug = models.SlugField(max_length=255, unique=True, blank=True) profile model class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='profiles') date_of_birth = models.DateField(blank=True, verbose_name="DOB", null=True) bio = models.TextField(max_length=500, blank=True, null=True) skills = models.ManyToManyField(Skill, related_name='skills') sex = models.CharField(max_length=6, choices=SEX, blank=True, null=True) type_of_body = models.CharField(max_length=8, choices=BODYTYPE, blank=True, null=True) feet = models.PositiveIntegerField(blank=True, null=True) inches = models.PositiveIntegerField(blank=True, null=True) lives_in = models.CharField(max_length=50, blank=True, null=True) updated_on = models.DateTimeField(auto_now=True) skill model class Skill(models.Model): name = models.CharField(max_length=60) subcategory = models.CharField(max_length=60, blank=True, null=True) description = models.TextField(null=True, blank=True) created_on = models.DateTimeField(auto_now=True) updated_on = models.DateTimeField(auto_now_add=True) updated_by = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.DO_NOTHING) the user view, where the search is done from class ListUsersView(generics.ListAPIView): …