Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django - How to pass multiple parameters to URL
I have created a Listings Page where all listings can be searched. From there, a user can click on any particular listing to see further detail. When I go to individual listing page, I am displaying Breadcrumb to provide an option to go back to Search results (which was previous Listings page). The issue is I am not able to pass 2 parameters (one containing the previous URL so that I can use that for Breadcrumb back to search results) while calling individual listing page from listings page. Please see main code: views.py def listing(request, listing_id, query): listing = get_object_or_404(Listing, pk=listing_id) context = { 'listing': listing, 'query':query } return render(request, 'listings/listing.html', context) HTML template {% url 'listing' listing_id=listing.id path=12 %} I tried using {{ request.get_full_path }} to find path and then add to parameter but its not working. Any suggestions on how to capture URL will be appreciated. -
How to auto increment a model field in django admin form by having add another on the side?
I have this model: class BlogPost(models.Model): author = models.CharField(max_length=64, default='Admin') image = models.ImageField(blank=True, null=True) title = models.CharField(max_length=255) caption = models.CharField(max_length=500) content = RichTextUploadingField() # todo support for tags tags = models.CharField(max_length=255, default='travel') #todo date_created = models.DateField() Now in tags field, I want to give multiple strings like #tips, #travel, etc on the same field. What I want is there should be like an add or increment tag, which when I click will show another tag field appears on the admin form and the user can adder another tag. My backend is not on the regular HTML page. I have customized the default Django admin page for the backend using the material package. That is I cant use button tag and all. How can I achieve this?? I have an image attached which explains better. Image here -
Permissions in DRF + Vue
I working on a project that has these models Instructor, Student, Review, Class. only a Student that has a Class with Instructor can send a Review. In the backend, I have a custom permission IsStrudentOfInstructor to determine a user can send a Review to an Instructor or not! and it works fine! Question: How the frontend developer can determine to show the review form to the requested user or not? Do I need to do any more work for that as a backend developer? The frontend framework is Vue and the backend framework is Django Rest -
NameError: name 'Order' is not defined
I Just Can't Access 'Order' in views.py's Function. i tried also "order=Order()" for creating object but it's Dosen't Work. Can anyone help me Please. models.py class Order(models.Model): r_name = models.ForeignKey(Restaurant, on_delete=models.CASCADE) f_name = models.ForeignKey(Food, on_delete=models.CASCADE) price = models.IntegerField(default=0) qauntity = models.IntegerField(default=0) total = models.IntegerField(default=0) def __str__(self): return str(self.r_name) views.py def order(request, id): f_detail = Food.objects.get(id=id) if request.method == 'POST': r_name = request.POST['r_name'] f_name = request.POST['f_name'] price = request.POST['price'] qauntity = request.POST['qauntity'] total = int(price) * int(qauntity) addOrder = Order(r_name=r_name, f_name=f_name, price=price, qauntity=qauntity, total=total,) addOrder.save() messages.success(request, 'Your Order is recorded!') return redirect('order') else: context = { 'f_detail' : f_detail, } return render(request, 'pages/order.html',context) return render(request,'pages/order.html') -
when i want post a tweet on my tweet page, it returns undefined instead of the actuall tweet content
i'm following a Create a (Twitter-like App with Python Django JavaScript and React)toturial. yesterday when i save the code and close the VS code the home page was like this enter image description here and today when i run the code i realize that all of my tweets were changed and now it shows me this enter image description here and the code thath handle tweets in templetes: enter c{% extends 'tweets\base.html' %} {% block head_title %} what a nice concept! {% endblock head_title %} {% block content %} <div class='row text-center'> <div class='col'> <h1>Welcom to Tweet</h1> </div> </div> <div class='row mb-3'> <div class='col-md-4 mx-auto col-10'> <form class='form' id='tweet-create-form' method='POST' action='/create-tweet'> {% csrf_token %} <input type='hidden' value='/' name='next' /> <textarea class='form-cntrol' name='content' placeholder="Your tweet..." ></textarea> <button type='submit' class='btn btn-primary'>Tweet</button>> </form> </div> </div> <div class='row' id='tweets'> Loading... </div> <script> function handleTweetCreateFormDidSubmit(event){ event.preventDefault() const myForm = event.target const myFormData = new FormData(myForm) const url = myForm.getAttribute("action") const method = myForm.getAttribute("method") const xhr = new XMLHttpRequest() const responseType = "json" xhr.responseType = responseType xhr.open(method, url) xhr.setRequestHeader("HTTP_X_REQUESTED_WITH", "XMLHttpRequest") xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest") xhr.onload = function() { if (xhr.status === 201) { const newTweetJson = xhr.response console.log(newTweetJson.likes) const newTweetElement = formatTweetElement(newTweetJson) console.log(newTweetElement) tweetsContainerElement.prepend(newTweetElement) } } xhr.send(myFormData) } … -
How to get my image gallery into my product.html in Django with Class based view DetailView
I am using model Product and Images. my goal is to display in my singe item page a gallery of item related pictures coming from model "Images" How can i change the following code to filter by item slug and only show gallery specific to the slug. class ProductDetailView(DetailView): model = Item template_name = 'product.html' context_object_name = 'item' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['image_gallery'] = Images.objects.all() return context -
File in django admin ( forms.py ) is not editing after edit
I accidentally edit the django's Lib/site-packages/django/contrib/auth/forms.py. The problem Then it showed me error then i noticed error and i fixed it after edit, It is still showing that error in the same line , same error syntax ( I have edited it ). When i delete every single word from that file ( forms.py ) , it still shows that error at the same line. What have i tried 1). I have tried --python manage.py makemigrations-- , --python manage.py migrate--. 2). I have also restarted the server. Help me in this. I will really appreciate your Help. Thank you in advance !! -
Element function fails to execute using external js
I just started learning JS and I keep failing to make a function successfully run via external javascript. I have no idea what is wrong. The thing is that it works when using inline javascript, but not external one. Here's the following code: {% load static %} <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="{% static 'css/main.css' %}"> <title id='title'> Home </title> </head> <body> <input type="button" id="btn" value="testas" onclick="myFunction()" /> <address> Written by <a href="mailto:webmaster@example.com">Jon Doe</a> </address> <script src="{% static 'javascript/js.js' %}"></script> </body> </html> JS: function ChangeTitle() { document.getElementById("title").innerHTML = 'Homepage'; } I want to change the title of "Home" to "Homepage" but it doesn't work on external JS. -
How to send manytomany field to Django rest framework using HTTP request in flutter
I have a back end system that needs to device a list of ids to fit a manytomany field made by django. Here are my files : model class field(models.Model): # Fields name = models.CharField(max_length=30) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) class Lawyer(models.Model): # Relationships fields = models.ManyToManyField("mohamena_app.field") # << -- this is the targeted field city = models.ForeignKey("mohamena_app.City", on_delete=models.PROTECT) # Fields last_updated = models.DateTimeField(auto_now=True, editable=False) bio = models.CharField(max_length=4000) mobile = models.CharField(max_length=14, unique=True) lawyer_id = models.ImageField(upload_to="upload/images/") full_name = models.CharField(max_length=30) is_active = models.BooleanField(default=False) image = models.ImageField(upload_to="upload/images/") created = models.DateTimeField(auto_now_add=True, editable=False) is_phone_active = models.BooleanField(default=False) activation_code = models.PositiveIntegerField(default='0000') Serializer class LawyerSerializer(serializers.ModelSerializer): class Meta: model = models.Lawyer fields = [ "last_updated", "bio", "lawyer_id", "full_name", "fields", "city", "is_active", "image", "mobile", "created", ] And here is how i tried to send the request in my flutter app : Future lawyerRegister(LawyerRegisterModel lawyerRegisterModel) async { Client client = Client(); String theUrl = '${baseURL}Lawyer/'; var uri = Uri.parse(theUrl); List fieldsList = []; for (FieldModel item in lawyerRegisterModel.fields){ fieldsList.add(item.id); // Creates a list of IDS } Map<String, String> headers = { 'Authorization': 'Token $theToken', }; var theRequest = MultipartRequest('POST', uri); theRequest.headers.addAll(headers); theRequest.fields['fields'] = '$fieldsList'; // Here is the error causing line theRequest.fields['city'] = '${lawyerRegisterModel.cityID}'; theRequest.fields['bio'] = '${lawyerRegisterModel.bio}'; theRequest.fields['full_name'] … -
Need suggestions to upload a huge amount of dataset
I'm looking for a solution to upload a huge excel data in Postgresql with a django rest api, the size of file is around 700mb while the number of rows are in millions. The options i'm looking for are: My question is how should i manage such a huge upload and how possibly show the status of uploaded data? Should i upload file in backend the parse and upload in tables? Should i parse data in frontend and upload on backend? Answer any suggestions you, what's the best practice that is used in real world apps? -
Django How to customize constraint Message in Meta Class?
I want to customize Meta class constraints default message. Here is my model that I have been working out. class BusRoute(BaseModel): route = models.ForeignKey(Route, on_delete=models.PROTECT) shift = models.ForeignKey( Shift, null=True, on_delete=models.PROTECT ) journey_length = models.TimeField(null=True) class Meta: default_permissions = () verbose_name = 'Bus Route' verbose_name_plural = 'Bus Routes' constraints = [ models.UniqueConstraint( fields=['route', 'shift'], name='unique_bus_company_route' ) ] The default constraint error message is as following Bus Route with this Shift already exists. Is there any way out I can customize this constraint message? -
from allauth.account.adapter import DefaultAccountAdapter causing error The SECRET_KEY setting must not be empty
I'm trying to create a custom rederect with djangl-allauth but when I import this #settings.py from allauth.account.adapter import DefaultAccountAdapter I got the following error. raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.") django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. #settings.py SECRET_KEY = 'I have a code here and it is not emrpy' -
TemplateDoesNotExist at /welcome_page/
I'm new in coding field. I decided to start a project with Django & Python, but I got stuck due to some errors. For the past 3 weeks, I tried to figure out what was the issue but couldn't find it. I will appreciate it if anyone help. when I run my code, I get as an error, "TemplateDoesNotExist at /welcome_page/" Everything as been specified but I'm still getting the same error Here is the error page: TemplateDoesNotExist at /welcome_page/ content of the welcome page: Content of my the welcome page my URLS : URLS where I defined welcome page My base content: My base content the place where the welcome page is calling from: The place where the welcome page is calling from My root to the welcome page from my C: drive: My root to the welcome page from my C: drive -
Serializer not working in custom method in model viewset,
This is my custom method in model viewset. class UserViewSet(viewsets.ModelViewSet): @action(detail=False, methods=['POST'],serializer_class=UserSerializer, name='Attach meta items ids') def create_user(self, request): queryset = User.objects.all() serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) return Response(serializer.data) this is my serialzer class UserSerializer(serializers.ModelSerializer): password = serializers.CharField(write_only=True) print("lklml") def create(self, validated_data): print("hjniknjbj") if UserModel.objects.filter(email=validated_data['email']).exists(): raise serializers.ValidationError("A user is already registered with this e-mail address.") if UserModel.objects.filter( username=validated_data['username']).exists(): raise serializers.ValidationError("This username already exists.") user = UserModel.objects.create( username=validated_data['username'], email=validated_data['email'] ) # add custom password password validation later user.set_password(validated_data['password']) user.save() return user class Meta: model = UserModel fields = ("id", "username", "password", "email",) extra_kwargs = {"password": {'write_only': True}} Now when ever i hit the api it's directly returning data what i sent and not going through serializer process i.e: returning same thing which i am posting.The issue is only when i am using custom viewset method. {"username":"pragghgjhhhkhhhhjbjhjhkjbjvin","email":"pravwnkwin@dat.com","password":"kms@1234"} -
I am not understanding what role is item.quantity and item.get_total playing in the code
class Order(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, blank=True, null=True) date_ordered = models.DateTimeField(auto_now_add=True) complete = models.BooleanField(default=False, null=True, blank=False) transaction_id = models.CharField(max_length=200, null=True) def __str__(self): return str(self.id) @property def get_cart_total(self): #get total value of all products with their respective quantity orderitems = self.orderitem_set.all() total = sum([item.get_total for item in orderitems]) return total @property def get_cart_items(self): #get items total orderitems = self.orderitem_set.all() total = sum([item.quantity for item in orderitems]) return total class OrderItem(models.Model): #make more orderitem product = models.ForeignKey(Paidproduct, on_delete=models.SET_NULL, blank=True, null=True) #it's gonna give you what you actually define in def__str___.....return self.name order = models.ForeignKey(Order, on_delete=models.SET_NULL, blank=True, null=True) quantity = models.IntegerField(default=0, null=True, blank=True) data_added = models.DateTimeField(auto_now_add=True) @property def get_total(self): #to get total items of a certain product in cart.html total = self.product.price * self.quantity return total -
django forloop counter as a variable
So I am trying to make an e-commerce pizza site where when a user adds an item to the basket it is stored as a cookie in the form cart=[{"id":"2","quantity":"1"},{"id":"3","quantity":"5"},{"id":"5","quantity":"3"},{"id":"5","quantity":"3"}] And my views.py is... def cart(request): cart = request.COOKIES.get('cart') cart = json.loads(cart) items =[] basket=[] for i in cart: pizza = Product.objects.filter(pk=i['id']).first() basket.append(int(i['quantity'])) items.append(pizza) cart = len(cart) context = { "cart":cart, "pizzas":items, "basket":basket } return render (request, "store/cart.html", context) And my models.py is ... class Product(models.Model): name = models.CharField(max_length=70) price = models.IntegerField() description = models.CharField(max_length=300) image = models.ImageField(upload_to="pizza_images") def save(self, *args, **kwargs): super().save() img = Image.open(self.image.path) img.save(self.image.path) def __str__(self): return f"{self.name}" In which my template code... <table> <thead> <tr> <th scope="col" class="small_col">Item</th> <th id="product_col" scope="col">Product</th> <th scope="col" class="small_col">Quantity</th> <th scope="col" class="small_col">Price</th> </tr> </thead> <tbody> {% for pizza in pizzas %} <tr> <td class="center">{{forloop.counter}}</td> <td>{{pizza.name}}</td> <td class="quantity_row justify-content-center"> <input class="quantity_input" type="text" value="{{basket.forloop.counter0}}" id="pizza{{forloop.counter}}"> <div class="form_buttons"> <img onclick="add(this.getAttribute('data-attribute'))" data-attribute="pizza{{forloop.counter}}" src="https://s.svgbox.net/hero-outline.svg?ic=plus-sm&fill=000" > <img onclick="minus(this.getAttribute('data-attribute'))" data-attribute="pizza{{forloop.counter}}" src="https://s.svgbox.net/hero-outline.svg?ic=minus-sm&fill=000"> </div> </td> <td class="center"> <h6>$25</h6> </td> <td class="small_col"> <a><img class="mb-1" src="https://s.svgbox.net/hero-outline.svg?ic=trash&fill=d90429" width="20" height="20"></a> </td> </tr> {% endfor %} </tbody> </table> And in the input field I want the quantity of the product to be displayed. The line which says... <input class="quantity_input" type="text" value="{{basket.forloop.counter0}}" id="pizza{{forloop.counter}}">and for somereason the … -
Django is not able to read the data posted from the POSTMAN?
I have the following code snippet:- from django.shortcuts import render from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt # Create your views here. @csrf_exempt def ajax_post_view(request): if request.method == "POST": foo = request.POST.get('Foo') print(foo) return JsonResponse(foo, safe=False) else: return JsonResponse("Not a POST method", safe=False) And I am making a POST request from POSTMAN which showls null value in response:- What am I missing? -
Django context processor 'AnonymousUser' object is not iterable
Im new to Django and have the below context processor which passes some data which is displayed in the header. everything works ok until the user logs out which should direct them back to the login screen however i get the below error. enter image description here here is the code from . models import Job from datetime import date def add_variable_to_context(request): today = date.today() engineers_jobs = Job.objects.filter(date_due__lte = today).filter(assigned_to=request.user) engineer_overdue = 0 for job in engineers_jobs: engineer_overdue += 1 return { 'engineers_jobs': engineers_jobs, 'engineer_overdue':engineer_overdue, } i then tried the below from . models import Job from datetime import date def add_variable_to_context(request): if request.user.is_authenticated: today = date.today() engineers_jobs = Job.objects.filter(date_due__lte = today).filter(assigned_to=request.user) engineer_overdue = 0 for job in engineers_jobs: engineer_overdue += 1 return { 'engineers_jobs': engineers_jobs, 'engineer_overdue':engineer_overdue, } but that displayed the following error enter image description here can someone help me where i am going wrong? Thanks -
Django: Add context to TemplateView
I have very simple template which I would like to mount via TemplateView: urlpatterns = [ ... path('feedback', TemplateView.as_view(template_name='foo/feedback.html', context=dict(mail=settings.DEFAULT_FROM_EMAIL)), name='feedback'), ] But this does not work: TypeError: TemplateView() received an invalid keyword 'context'. as_view only accepts arguments that are already attributes of the class. How can I add render a template without writing a method? -
How to create complex multi model join query set with Django ORM
I want to create a query set with multiple tables. I cannot find any resource that helps Beside some small 2 table join examples, I cannot find any resource that is helpful for this, not in stackoverflow, the Django docs or even in the ORM Cookbook. Below is firstly the SQL I want to recreate followed by the models classes, simplified for the purpose of this question. They have in fact a LOT more fields. SELECT doc_uid, docd_filename, doct_name, docd_media_url FROM vugd_detail, vugdoc_vug_docs, doc_documents, docd_detail, doct_type WHERE vugd_vug_uid = vug_uid AND vugdoc_vug_uid = vug_uid AND vugdoc_doc_uid = doc_uid AND docd_doc_uid = doc_uid AND doct_uid = doc_doct_uid AND vugd_status = 1 AND docd_status = 1 AND NOW() BETWEEN vugd_start_date AND vugd_end_date AND NOW() BETWEEN docd_start_date AND docd_end_date AND vug_uid = {{Some ID}}; class VugVirtualUserGroup(models.Model): objects = None vug_uid = models.AutoField(primary_key=True) vug_name = models.CharField(unique=True, max_length=30) vug_short_code = models.CharField(max_length=6) vug_created_on = models.DateTimeField() vug_created_by = models.CharField(max_length=30) class Meta: managed = False db_table = 'vug_virtual_user_group' app_label = 'main' class VugdDetail(models.Model): objects = None vugd_uid = models.AutoField(primary_key=True) vugd_vug_uid = models.ForeignKey(VugVirtualUserGroup, models.DO_NOTHING, db_column='vugd_vug_uid') vugd_long_name = models.CharField(max_length=50) vugd_status = models.IntegerField() vugd_start_date = models.DateTimeField() vugd_end_date = models.DateTimeField() class Meta: managed = False db_table = 'vugd_detail' app_label = 'main' class … -
how to use use Django filtered class data to 2 seperate view
I am using Django filter and using it in normal view it is working as expected now I want to download the filtered data so for this I am writing one download view where I am trying to use the same FilterClass but no luck. It is giving me an ERROR. Can anyone please help/suggest how to use filtered queryset in filter class more than one view OR pass the data of filtered query to the download views. Please find my code. filters.py class CTAFilter(django_filters.FilterSet): id = django_filters.NumberFilter(label="DSID") class Meta: model = CTS fields = ['id', 'EmailID','id','Shift_timing'] Here I want when the user will select Shift_timing for example Morning he will get 10 records so the same data I want to pass to the below download view. (For this I am using CTSFilter class but no luck.) Please find the below download code(View). def exportcts_data(request): response = HttpResponse(content_type='application/ms-excel') response['Content-Disposition'] = 'attachment; filename="CTA_ShiftTiming.xls"' wb = xlwt.Workbook(encoding='utf-8') ws = wb.add_sheet('CTS_ShiftChange Data') # this will make a sheet named Users Data # Sheet header, first row row_num = 0 font_style = xlwt.XFStyle() font_style.font.bold = True columns = ['id','idk','Shift_timing','EmailID','Vendor_Company','Project_name','SerialNumber','Reason','last_updated_time'] for col_num in range(len(columns)): ws.write(row_num, col_num, columns[col_num], font_style) # at 0 row 0 column # … -
Pass a custom param with a ModelViewSet URL
What's the best way of passing a param using a ModelViewSet? Forexample achieving something like this : http://127.0.0.1:8000/api/v1/financing-settings/template/?param=block Below is the approach I was using but found out I have set the param in the body section, but it's not what I want : class TemplateView(ModelViewSet): """ViewSet for Saving Block/ Step template.""" def list(self, request, *args, **kwargs): """Get list of Block/Steps with is_process_template is equal to True.""" param = request.data['param'] if param == "block": _block = Block.objects.filter(is_process_template=True).values() return JsonResponse({"data": list(_block)}, safe=False, status=200) elif param == "step": _step = Step.objects.filter(is_process_template=True).values() return JsonResponse({"data": list(_step)}, safe=False, status=200) return Response(status=status.HTTP_204_NO_CONTENT) -
Sequentially validating individual attributes with Django Rest Framework
I am very new to Django Rest Framework and am confused about coding the following task: when a user on the front-end enters an email address, without any other user information, the API should determine whether or not the email already exists. Likewise, when the user enters a username, without any other user information, the API should determine whether or not the username already exists. I am aware of the existence of validators, but I don't understand how to use them on partial data. Here is my serializers.py class class CustomUserSerializer(serializers.ModelSerializer): email = serializers.EmailField(required=True) username = serializers.CharField(min_length=2) password = serializers.CharField(min_length=8, write_only=True) first_name = serializers.CharField(min_length=2) last_name = serializers.CharField(min_length=2) class Meta: model = CustomUser fields = ('pk', 'email', 'username', 'password', 'created_at', 'first_name', 'last_name') extra_kwargs = {'password': {'write_only': True}} def validate_email(self, value): if CustomUser.objects.filter(email=value).exists(): raise serializers.ValidationError("An account already exists with that email address.") return value def validate_username(self, value): if CustomUser.objects.filter(username=value).exists(): raise serializers.ValidationError("An account aready exists with that username.") return value def create(self, validated_data): password = validated_data.pop('password', None) instance = self.Meta.model(**validated_data) if password is not None: instance.set_password(password) instance.save() return instance And here is my views.py class class CustomUserCreate(APIView): permission_classes = (permissions.AllowAny,) authentication_classes = () def post(self, request, format='json'): """ Receives an HTTP request. Serializes … -
How to only use a single instance of multiple same name classes
When clicking on a link, it changes from like to unlike or vice versa but, the number of likes and unlike are supposed to change uniquely and not every single one of the posts in the same page. A for loop in Django is used to call the posts, so they have the same class names. The jquery below is supposed to change the like count of a specific post, but it changes every single one due to the class name. How can this be done please. jquery extract var previous_likes = parseInt($('span.count .total').text()); $('span.count .total').text(previous_action == 'like' ? previous_likes + 1 : previous_likes - 1); full jquery code $('a.like').on('click', function(event){ event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); $.post('{% url "posts:post_like" %}', { id: $(this).data('id'), action: $(this).data('action') }, function(data){ if (data['status'] == 'ok') { var previous_action = $(event.target).data('action'); // toggle data-action $(event.target).data('action', previous_action == 'like' ? 'unlike' : 'like'); // toggle link text $(event.target).text(previous_action == 'like' ? 'Unlike' : 'Like'); // update total likes var previous_likes = parseInt($('span.count .total').text()); $('span.count .total').text(previous_action == 'like' ? previous_likes + 1 : previous_likes - 1); } } ); }); -
Troubles with test Django
i am noob in django and trying to find an adequate solution for my problem. Perhaps i have searched a lot but didn't find satisfy solution. How i can figure out with this problem? Test Errors: Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\Users\DjangoDev\Desktop\Django\mi> py .\manage.py test osu Creating test database for alias 'default'... System check identified no issues (0 silenced). EEEEEEEEEE ERROR: test_with_future_question (osu.tests.DetailModelTests) Traceback (most recent call last): File "C:\Users\DjangoDev\Desktop\Django\mi\osu\tests.py", line 60, in test_with_future_question future_quest = create_question('f', 30) File "C:\Users\DjangoDev\Desktop\Django\mi\osu\tests.py", line 26, in create_question return Question.objects.create(text, time) File "C:\Users\DjangoDev\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) TypeError: create() takes 1 positional argument but 3 were given ====================================================================== ERROR: test_with_past_question (osu.tests.DetailModelTests) Traceback (most recent call last): File "C:\Users\DjangoDev\Desktop\Django\mi\osu\tests.py", line 65, in test_with_past_question past_quest = create_question('p', -30) File "C:\Users\DjangoDev\Desktop\Django\mi\osu\tests.py", line 26, in create_question return Question.objects.create(text, time) File "C:\Users\DjangoDev\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) TypeError: create() takes 1 positional argument but 3 were given ====================================================================== ERROR: test_does_not_have_any_question (osu.tests.QuestionIndexModelTests) Traceback (most recent call last): File "C:\Users\DjangoDev\Desktop\Django\mi\osu\tests.py", line 33, in test_does_not_have_any_question self.assertContains(response.content, 'No osu are aviable') File "C:\Users\DjangoDev\AppData\Local\Programs\Python\Python39\lib\site-packages\django\test\testcases.py", line 461, in assertContains text_repr, real_count, msg_prefix = self._assert_contains( File "C:\Users\DjangoDev\AppData\Local\Programs\Python\Python39\lib\site-packages\django\test\testcases.py", line …