Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Rest Framework - how to change query params recognition?
I use [https://www.npmjs.com/package/vue-bootstrap4-table#8-filtering][1] with django-rest-framework. The problem is that this component uses totally different query params for sorting, filtering, etc. vue-bootstrap4-table http://127.0.0.1:8000/api/products/?queryParams=%7B%22sort%22:[],%22filters%22:[%7B%22type%22:%22simple%22,%22name%22:%22code%22,%22text%22:%22xxx%22%7D],%22global_search%22:%22%22,%22per_page%22:10,%22page%22:1%7D&page=1 "filters":[{"type":"simple","name":"code","text":"xxx"}], whereas Django-rest-framework needs this format: ../?code__icontains=... I want to figure out how to make DRF accept this format instead of the built-in? I use just ViewSet. class ProductViewSet(viewsets.ModelViewSet): serializer_class = ProductSerializer filter_class = ProductFilter filter_backends = [filters.OrderingFilter] ordering_fields = '__all__' Is it possible? -
Django admin log in page gets stuck after I click the Log in button
This problem can be reproduced on my computer even with the simplest polls application. Execute python .\manage.py runserver to run the server. Open http://127.0.0.1:8000/admin in Chrome. If already logged in, then log out. Click "Log in again" and redirect to http://127.0.0.1:8000/admin/login/?next=/admin/. Type the correct username and password. Then, nothing happens except that the tab of Chrome keeps loading. The log of the python command is as follows. [19/Oct/2019 22:02:09] "GET /admin/logout/ HTTP/1.1" 200 1195 [19/Oct/2019 22:02:10] "GET /admin/ HTTP/1.1" 302 0 [19/Oct/2019 22:02:10] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1807 [19/Oct/2019 22:02:25] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0 I tried another browser, Edge, for several times. This problem never happens in Edge. However, it will happen in Chrome almost every time I follow the steps listed above. I wonder if this is due to Chrome or am I missing something? -
How to force users to complete their profile in Django
I have designed a learning management system that customers can attend courses, buy books and ... . In this system when users want to enrollment in course forced to fill their profile info. But some of them don't want to enrollment in course and then I can't have their info. I want to force users to complete their profile and enter the required information into their profile. For example I want: System show them warning and force them to complete their profile three days after registration. How can I do that? Notice: In other hand I want to block access for users who have not yet completed their profile to use the panel, until they complete theirs profile. -
Too many redirect to same page in django
I am trying to redirect to a the same page if certain conditions are not met in my view in django but i keep getting ERR_TOO_MANY_REDIRECTS error. I am using HttpResponseRedirect. from django.http import HttpResponseRedirect return HttpResponseRedirect(self.request.path_info) -
Raise Form error below the input field in case any invalid data is entered in Django
I am using pre_save to raise error if while entering the data any condition is not met. But when I am using raise ValidationError(). Its showing me error in the next page like this. But what I actually want is the error just below my field that the data is invalid. For example the one that you get for a unique field eg username in the django admin. The error should show in this page itself showing invalid data. How can I do this. This is what I have tried. @receiver(pre_save, sender=Works_in) def check_dept_has_manager(sender, instance, **kwargs): print(instance.emp_name, instance.dept_name) if str(instance.emp_name) == "BB": raise ValidationError("Manager already assigned to this department") -
getting error while creating database python manage.py initdb , how to solve this issue?
error while creating database in python , python manage.py initdb is not working C:\Users\Mantu Kumbhakar\Downloads\pyfile>python manage.py initdb Traceback (most recent call last): File "manage.py", line 4, in from app import app, db, models File "C:\Users\Mantu Kumbhakar\Downloads\pyfile\app__init__.py", line 6, in app.config.from_object('app.config') File "C:\Users\Mantu Kumbhakar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\config.py", line 162, in from_object obj = import_string(obj) File "C:\Users\Mantu Kumbhakar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\werkzeug\utils.py", line 546, in import_string import(import_name) File "C:\Users\Mantu Kumbhakar\Downloads\pyfile\app\config.py", line 1, in config_dev.py NameError: name 'config_dev' is not defined NameError: name 'config_dev' is not defined -
'You're accessing the development server over HTTPS, but it only supports HTTP.' I don't know the cause of the error
I divided and edited the setting.py file in Django. And after starting, it disappeared on the screen. 'ERR_SSL_PROTOCOL_ERROR' is displayed on the screen. Command. python manage.py runserver 0.0.0.0:8000 The error is as follows. 2019-10-19 21:44:10,829 [INFO] /Users/t.a/Desktop/apasn/apasn_rest/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py:154 code 400, message Bad request version ('\x80ì.UÂHÂg\x95JÁ\xad\x81µXBz\'\x00"êê\x13\x01\x13\x02\x13\x03À+À/À,À0̨̩À\x13À\x14\x00\x9c\x00\x9d\x00/\x005\x00') 2019-10-19 21:44:10,830 [ERROR] /Users/t.a/Desktop/apasn/apasn_rest/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py:137 You're accessing the development server over HTTPS, but it only supports HTTP. I tried with 'SECURE_SSL_REDIRECT' set to false, but the result did not change. #base.py import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PROJECT_NAME = os.path.basename(BASE_DIR) SECRET_KEY = '***' DEBUG = True ALLOWED_HOSTS = ['*'] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles' ] MIDDLEWARE = [ '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', ] SECURE_SSL_REDIRECT = False ROOT_URLCONF = 'apasn_rest.config.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'apasn_rest.config.wsgi.application' DATABASES = {} AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] LANGUAGE_CODE = 'ja' TIME_ZONE = 'Asia/Tokyo' USE_I18N = True USE_L10N = True USE_TZ = True STATIC_URL = '/static/' #local.py from .base import * DEBUG = True SECRET_KEY = '***' ALLOWED_HOSTS = ['*'] DATABASES = … -
DetailView redirect not working in django
I keep getting a reverse error when i try to redirect from a DetailView and CreateView. I keep getting object has no attribute pk. I have equally tried using : args=[str(self.id)]) but i still get the error. class check (DetailView) def get(self, request, *args, **kwargs): if...: return reverse('no_edit', kwargs={"pk": self.pk}) -
vue-bootstrap4-table - how to modify filtering query params?
I use https://www.npmjs.com/package/vue-bootstrap4-table#8-filtering with django-rest-framework. The problem is that this component uses totally different query params for sorting, filtering, etc. vue-bootstrap4-table http://127.0.0.1:8000/api/products/?queryParams=%7B%22sort%22:[],%22filters%22:[%7B%22type%22:%22simple%22,%22name%22:%22code%22,%22text%22:%22xxx%22%7D],%22global_search%22:%22%22,%22per_page%22:10,%22page%22:1%7D&page=1 "filters":[{"type":"simple","name":"code","text":"xxx"}], but Django-rest-framework needs this format: ../?code__icontains=... Do you know how to make vue-bootrstrap4-table to generate this format? My app: new Vue({ el: '#app', data: { product_list_url: "{% url "api:product-list" %}", rows: [], total_rows:0, queryParams: { sort: [], filters: "", global_search: "", per_page: 10, page: 1, }, columns: [{ label: "Kód", name: "code", filter: { type: "simple", placeholder: "code" }, sort: true, }, { label: "Názov", name: "name", filter: { type: "simple", placeholder: "Enter name" }, sort: true, }, ], config: { checkbox_rows: true, rows_selectable: true, {#card_title: "Vue Bootsrap 4 advanced table",#} server_mode: true, } }, mounted() { this.fetchData(); }, methods: { onChangeQuery(queryParams) { this.queryParams = queryParams; this.fetchData(); }, fetchData() { let self = this; axios.get(self.product_list_url, { params: { "queryParams": this.queryParams, "page": this.queryParams.page } }) .then(function (response) { self.rows = response.data.results; self.total_rows = response.data.count; }) .catch(function (error) { console.log(error); }); } }, }) -
How to realize sending otp on the phone?
I am trying to implement phone registration using twilio, python and django I can`t comprehend how i have to realize mechanism , that takes input from user for texting him Generating otp and sending to user: from twilio.rest import Client import random otp=random.randint(1000,9999) account_sid = '' auth_token = '' client = Client(account_sid, auth_token) client.messages.create(from_='+', to='+', body='Your OTP is -'+str(otp)) When user inputs his phone number, it sends to the server But how i can place his number at to =" _HERE_ " , when he sends it to the server and how i can call this file then? -
How to limit the number of entries in django database ? Using the default database (sqlite3)
How can i specify number of entries in my django database (sqlite3). For example my model is: from django.db import models class About(models.Model): firstname = models.CharField(max_length=500) lastname = models.CharField(max_length=500, blank=True) address = models.TextField() details = models.TextField() class Meta: verbose_name_plural = 'About' def __str__(self): return self.firstname Now i want to store data of only 2 members in my database. And after adding the data of both users in database from django admin panel, if i try to store data of 3rd member than it should show that database limit is crossed you can't store this data, delete previous data first. Is it possible to limit entries form django models.py . -
How to add an executable to PATH in Azure's Kudu?
I need to add the gecko driver in order to run a headless browser on Azure as part of my website, but I need to add the geckodriver to PATH (apparently I can't manually input the location of the geckodriver file in Python?) I know I have to use the applicationHost.xdt file and add it to /home/site folder, but my Kudu page doesn't allow me to add files (I can create the file using 'touch', but I can't edit it). This is how my Kudu page looks like: https://imgur.com/a/99oHUoC This is my applicationHost.xdt: <?xml version="1.0"?> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.webServer> <runtime xdt:Transform="InsertIfMissing"> <environmentVariables xdt:Transform="InsertIfMissing"> <add name="geckodriver" value="geckodriverL" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" /> <add name="PATH" value="%PATH%;%HOME%\site\wwwroot\cpu" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" /> </environmentVariables> </runtime> </system.webServer> </configuration> This is the error I get from Django: WebDriverException at / Message: 'geckodriverL' executable needs to be in PATH. Request Method: GET Request URL: http://site.azurewebsites.net/ Django Version: 2.2.6 Exception Type: WebDriverException Exception Value: Message: 'geckodriverL' executable needs to be in PATH. Exception Location: /antenv/lib/python3.7/site-packages/selenium/webdriver/common/service.py in start, line 83 Python Executable: /opt/python/3.7.4/bin/python3.7 Python Version: 3.7.4 Python Path: ['/opt/python/3.7.4/bin', '/home/site/wwwroot', '/antenv/lib/python3.7/site-packages', '/opt/python/3.7.4/lib/python37.zip', '/opt/python/3.7.4/lib/python3.7', '/opt/python/3.7.4/lib/python3.7/lib-dynload', '/opt/python/3.7.4/lib/python3.7/site-packages'] Server time: Fri, 18 Oct 2019 14:39:59 +0000 -
jQuery: if statement to select an option value
My aim is: If I type a value bigger than 60, then I would like the option "Long" to be selected. If I type a value less than 60, then I would like the option "Short" to be selected. With help of of jQuery, I would like for "result" to be automatically changed given the field "value" I have a form, contains an input integer field, with id "value", and form has a option field with id "result". Below is my try, but it does not work. Thanks for your input. var value = $('#value'); $(value).change(function() { debugger; if (Number($(this).val()) > 60) { $('#result').prop('value') = "Long"; } if (Number($(this).val()) < 60) { $('#result').prop('value') = "Short"; } }) <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <label for="value" class="col-form-label col-sm-4">Value</label> <div class="col-sm-7"> <input type="number" name="value" class="numberinput form-control" id="value"> </div> </div> <div><i>Result:</i></div> <div id="result" class="form-group row"> <div class="col-sm-12"> <select name="result" class="select2 form-control" style="width: 100%;" id="result"> <option value="Long">Long</option> <option value="Short">Short</option> -
Passing data from function to template in a Django view
I have an ordinary view, which renders a template with some variables. In this example, two values called x, y are retrieved from a form. I would like to render on my template the addition of those two numbers, so i tried this: def myview(): if request.method == 'POST': form = MyForm(request.POST) # check whether it's valid: if form.is_valid(): x = request.POST['x'] y = request.POST['y'] MyFunction(x, y) send = form.save() send.save() messages.success(request, f"Success") //Some other operations here.. return render(request, "main/mytemplate.html", context={"mydata": mydata}) def MyFunction(x, y): mydata = x*y return mydata This problem gives an error, of course, because MyData is a variable defined inside a function, so myview can't see it. Is there a way to pass the variable to the view? I know that i could do the same operation all inside the view, without defining a function, but i would rather use a function since it makes the code easier to read. -
Django only get object if one of it's subobjects meets condition
So I have two models: class Business(models.Model): def __str__(self): return self.name name = models.CharField(max_length=200) class Appointment(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) business = models.ForeignKey(Business, on_delete=models.CASCADE, related_name="appointments") And in my view I have the following context: def home(request): [...] context = { 'business':Business.objects.order_by('name'), } [...] Now I would get all businesses there are with their submodels "Appointment". But what I want is only businesses where on of the existing submodels "Appointment" fullfillsauthor == request.author Also the submodels "Appointment" of a Business should only be the "Appointments" where their author equals request.author -
ConnectionResetError: [Errno 104] Connection reset by peer in Django and Postgresql
I am facing a problem with only a single url which gives connection refused by peers. I have a Django project deployed in server.Earlier it was working fine but now it is giving me this error and on web page it is showing blank screen.I am sending the correct response from views and able to display in text form but it is not rendering with Django template special functions.I tried many things which are available on stack overflow and many other websites but nothing is working.I also tried re-installing Django and also tried to change the url and restarted server many times but nothing worked.I am using a Amazon-ec2 centos server,Django version 2.1 ,python version is 3.7.3.Stack Trace Traceback (most recent call last): File "/usr/lib64/python3.7/wsgiref/handlers.py", line 138, in run self.finish_response() File "/usr/lib64/python3.7/wsgiref/handlers.py", line 180, in finish_response self.write(data) File "/usr/lib64/python3.7/wsgiref/handlers.py", line 279, in write self._write(data) File "/usr/lib64/python3.7/wsgiref/handlers.py", line 453, in _write result = self.stdout.write(data) File "/usr/lib64/python3.7/socketserver.py", line 799, in write self._sock.sendall(b) ConnectionResetError: [Errno 104] Connection reset by peer ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 60208) Traceback (most recent call last): File "/usr/lib64/python3.7/wsgiref/handlers.py", line 138, in run self.finish_response() File "/usr/lib64/python3.7/wsgiref/handlers.py", line 180, in finish_response self.write(data) File "/usr/lib64/python3.7/wsgiref/handlers.py", line 279, … -
Django User model not working after being overrided
Explanation I have extended Django User model and add some fields to that. Then I have saved the model and replaced it with the last User model using StackedInline. For this purpose I am using django_rest_framework. More specifically here is my code: Models.py class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) # TODO: add Upload directory to the avatar avatar = models.ImageField() university = models.CharField(max_length=100, default="") discipline = models.CharField(max_length=100, default="") joined_at = models.DateTimeField(auto_now=True) class UserProfileInline(admin.StackedInline): '''Stacked Inline View for UserProfile''' model = UserProfile class UserAdmin(BaseUserAdmin): inlines = ( UserProfileInline, ) Post Request: Problem I can see the additional fields that I have added in the User model in django-admin, but whenever I want to send a post request to create a new user, the additional fields are ignored! (while I have put the data in the post request, but it shows blank in admin) Question How can I fix or edit my model that it works properly? -
Checking condition before inserting data to a table in Django
I have 5 tables User(i.e Employee), Positions and Emp_position(which is a relationship table between the Employee and Positions). I have a department table which contains the list of all departments in my company and a relationship table Works_in which maps User(Employee) to a department. Now in the Works_in table when I am mapping User(Employee) to a Department I want to check whether the data that I am inserting in Works_in(relationship) table. That is mapping an employee to a department already has a manager mapped to it or not. Example : Employee Himanshu Bassi BB Position Developer Manager Tester Emp_position(relationship table) Employee Position Himanshu Developer Bassi Manager BB Manager Department Web UI Data Analysis Machine Learning Works_in Employee Department Himanshu Web UI Bassi Web UI BB Web UI # this is wrong, which needs to be checked Each Employee will be mapped to a Department, But a department should not have multiple manager. Over here since Bassi and BB are manager we don't want them to be mapped to same department. So for that purpose I want to check before the data BB Web UI was being inserted to our Works_in table whether the department that is going to be mapped … -
How to use PyPDF2 to insert *.png image file into a .pdf file
here is my code: input_file = "example.pdf" output_file = "example-drafted.pdf" watermark_file = "draft.pdf" with open(input_file, "rb") as filehandle_input: pdf = PyPDF2.PdfFileReader(filehandle_input) with open(watermark_file, "rb") as filehandle_watermark: watermark = PyPDF2.PdfFileReader(filehandle_watermark) first_page = pdf.getPage(0) first_page_watermark = watermark.getPage(0) first_page.mergePage(first_page_watermark) pdf_writer = PyPDF2.PdfFileWriter() pdf_writer.addPage(first_page) with open(output_file, "wb") as filehandle_output: pdf_writer.write(filehandle_output) in my above code : watermark_file = "draft.pdf". i want this watermark_file to be used as "draft.png" -
How to use filter value as variable in django orm
I want to use tmp_id as a value of row id in extra method . code: order_obj = table.objects.filter() .annotate( tmp_id=F('test_data') ) .extra( select={"select id from data where row_id = {{here i want to use tmp_id}} limit 1"} ) can anyone tell me how to do it ? -
How can I render this formset as a Crispy form?
I've been having trouble getting my image formsets to upload correctly in Django. I'm using crispy forms, and all other elements on the form and page work fine. Here's what the form looks like: For context, the form should look like this: As you can see, crispy forms isn't rendering. I originally dismissed this as a purely graphical issue, but the HTML source code shows that the FormHelper elements (enctype, layout_class, field_class etc...) aren't loading either, which impedes the image upload functionality. <form class="form-horizontal" method="post" > ... </form> I've walked through the code and the tutorial I used line by line, but I can't find where the problem lies. views.py class CarCreate(generic.CreateView): model = Car slug_field = 'id' slug_url_kwarg = 'car_create' template_name = 'showroom/car_create.html' form_class = CreateCarForm success_url = None def get_context_data(self, **kwargs): data = super(CarCreate, self).get_context_data(**kwargs) self.request.POST: data['images'] = CarImageFormSet(self.request.POST, self.request.FILES) else: data['images'] = CarImageFormSet() return data def form_valid(self, form): context = self.get_context_data() images = context['images'] with transaction.atomic(): form.instance.seller = self.request.user self.object = form.save() if images.is_valid(): images.instance = self.object images.save() return super(CarCreate, self).form_valid(form) def get_success_url(self): # return reverse_lazy('showroom:cars', kwargs={'slug': self.object.id}) # Throws an error return reverse_lazy('showroom:cars') forms.py class CreateCarForm(ModelForm): class Meta: model = Car exclude = ['seller', 'id'] def … -
How to calculate x^2 in sympy gamma
I am very new to coding in Python and using the django. My question: is it possible to calculate x^2 in sympy gamma?In my program x**2 is working but x^2 is not working. ^ is not working. my code is- from django.shortcuts import render, redirect from django.http import HttpResponse from sympy import * from sympy.parsing.sympy_parser import * import sympy as sp # Create your views here. def index(request): if request.method == "POST": x = symbols('x') init_printing() transformations = (standard_transformations + (implicit_multiplication_application,)) eq = parse_expr(request.POST['equ'], transformations=transformations) sympifyy = latex(sympify(eq, evaluate=False)) sympifyy1 = Eq(eq) derivative = latex(sp._eval_derivative(eq,x)) integration = latex(sp.integrate(eq, x)) # integration = integrate(eq, x) # pretty(latex(Integral(eq, x)),use_unicode=False) # print(pretty(Integral(sqrt(1/x), x), use_unicode=False)) rootss = solve(eq) limits = limit(eq, x, 0) seriess = latex(series(eq, x, 0, 10)) data = { 'Sympify' : sympifyy, 'Sympify1' : sympifyy1, 'Derivative' : derivative, 'Integration' : integration, 'Roots' : rootss, 'Limit' : limits, 'Series' : seriess } return render(request, 'index.html', {'data':data}) return render(request, 'index.html') -
What's the difference between handling requests in Django 3 ASGI mode vs WSGI mode?
Django 3 should be released soon and it will be able to work in ASGI mode. ASGI mode seems to make Django more efficient when handling requests than in WSGI mode (more requests can be handled per time unit if I believe correctly). How is it accomplished? Is it like that Django can handle at the same time multiple requests, but most of them will be waiting on events like fetching data from a database or other IO operations? -
Not able to access the URL of the tenants though service is running fine
I am working on django-tenants module to create multi-tenant application for my customers. In my requirement : a user can belong to more than one customer and it can have different roles so I found this as an ideal way to do it. Now the issue is I have created the separate schema for each tenant but I am not able to access any URL though service is running fine.It is showing me error of page not found. I tried the steps mention by tomturner who is one of the contibutor of django-tenants. Below is the link which i followed: https://github.com/tomturner/django-tenants/blob/master/docs/install.rst Everything is perfect in database but why URL is not accessible that I am not able to figure it out. from django.db import models from django_tenants.models import TenantMixin, DomainMixin class Client(TenantMixin): name = models.CharField(max_length=100) class Domain(DomainMixin): pass My domain name of tenant s1 is singh.co, so i should be able to access the tenant url using http:///singh.co:8000. But I am getting 404 error. Not able to identify problem. I am using python 3.7.3 with below packages. Django - 2.2.6 django-tenants- 2.2.3 -
How to fix: 'TypeError: expected string or bytes-like object' when doing unit test on a views.py function
I'm writing a test for a function that returns a JSONResponse. The function works fine on the website but the test always raises a TypeError. It looks like the program fails to get an entry from the database and returns an error instead. views.py: def check_availability(request, id): if request.method == "GET": response_data = {} event_date = request.GET.get('event_date', False) check = None try: try: speaker = Pembicara.objects.get(id = id) filtered = Booking.objects.filter(speaker = speaker) check = filtered.get(event_date = event_date) except ObjectDoesNotExist as e: pass except Exception as e: raise e if not check: response_data['available'] = 'ok' else: response_data['available'] = 'no' except Exception as e: raise e return JsonResponse(response_data) tests.py: def test_date_availability_is_checked(self): p = self.createPembicara() c = Client() date = datetime.date.today() # request = c.get('/profile/1/check_availability/', event_date=date) b = self.createBooking() request = c.get('/profile/1/check_availability/', event_date='1999-12-20') self.assertEqual(request.status_code, 200) self.assertJSONEqual(request.content, {'available': 'ok'}) terminal: Creating test database for alias 'default'... System check identified no issues (0 silenced). ./Users/nethaniasonya/Documents/KULIAH/SEMESTER 3/ppw/bookaspeakers/env/lib/python3.7/site-packages/whitenoise/base.py:116: UserWarning: No directory at: /Users/nethaniasonya/Documents/KULIAH/SEMESTER 3/ppw/bookaspeakers/BookaSpeakers/static/ warnings.warn(u"No directory at: {}".format(root)) E....... ====================================================================== ERROR: test_date_availability_is_checked (speaker_profile.tests.ProfileTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/nethaniasonya/Documents/KULIAH/SEMESTER 3/ppw/bookaspeakers/speaker_profile/tests.py", line 69, in test_date_availability_is_checked request = c.get('/profile/1/check_availability/', event_date='2000-12-20') File "/Users/nethaniasonya/Documents/KULIAH/SEMESTER 3/ppw/bookaspeakers/env/lib/python3.7/site-packages/django/test/client.py", line 535, in get response = super().get(path, data=data, secure=secure, **extra) File "/Users/nethaniasonya/Documents/KULIAH/SEMESTER 3/ppw/bookaspeakers/env/lib/python3.7/site-packages/django/test/client.py", …