Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
getting exact values of current object in ModelAdmin django
i have a ModelAdmin class EventAdmin(admin.ModelAdmin): def formfield_for_foreignkey(self, db_field, request, **kwargs): current_obj = request.GET.get('event_date', '2018-10-01') if db_field.name == "start": kwargs["queryset"] = TimeSlots.objects.filter(~Q(event__event_date=current_obj)) return super().formfield_for_foreignkey(db_field, request, **kwargs) i am not getting my exact value of current in current_obj what can i do to get it? my Event model: class Event(models.Model): event_date = models.DateField() start = models.ForeignKey(TimeSlots, verbose_name='Slot Time', null=True) -
How to loop inside a dictionary wish has values as arrays
I want to loop inside a dictionary that has arrays as values and get each element of the arrays how to do it in python I tried this but it didn't work array={'Secretary' : [0,1,2,3,4] , 'Admin' : [0,2,3,4,1]} for key,value in array.items(): for v in value: print(v[count]) count =count+1 -
Could not parse the remainder: '{{ list[loop.index0] }}'
I followed instructions in simmilar thread like: How do you index on a jinja template? but my html template is not working and whole django project is not responding due to this. Error that I'm getting: Error during template rendering. Could not parse the remainder: '[loop.index0]' from 'songs_titles[loop.index0]' My code looks like this: {% if converted_files_urls %} <p>Titles: {{ songs_titles }}</p> {% for n in converted_files_urls %} <a href="{{ n }}" download>Download: {{ songs_titles[loop.index0] }}</a> <br/> {% endfor %} {% endif %} What am I doing wrong? -
display any value from django views to html form input
I'm working on Django app and i have only one page in my templates directory named "index", everything is working well but i faced a problem when i wanted to display the result which will be passed by Django views to my HTML page. I want the value to be displayed on my input field instead of printing it on the browser. I searched a lot but i couldn't found anything related to this. I have three fields: key field. Plaintext field. Ciphertext field. and one button for encryption & decryption. I need when i click on the button, the result will be displayed on my Ciphertext field not on the browser because i already did that before. Can you help me? Thanks.. -
Can I make a model save() method dependent on a successful payment?
I want to give users the ability to create a model, but I want the saving of the model to be dependent on a successful payment. I know I could just save the model instance and use web hooks to modify a bool field from false to true upon successful payment, to show that it has been paid for, but is there a way to hold the initial data in space, and only commit it to the database if a successful payment signal is received? I've looked into pre_save signals, but not sure if I'm on the right track. -
Return result of instance method with values_list()
I want to do Object.objects.all().values_list('id', 'method_name') where method_name is not a field in the database but a method in the Object model. I get an error with this example, because values_list does not return objects and only fields. Is there a solution to return the output of that method here too? Or do I have to build the whole thing by myself, that means looping the returned objects and putting the data in a dictionary. -
Django Rest Framework DELETE returns no content in the body
I am using Django Rest Framework and I am making a DELETE request. As opposed to POST, PUT, PATCH, which all return the state of the object post creation/modification, delete does not return anything in the body (just the 204 code). Having this information would be helpful when trying to tie responses back to their original requests. In particular https://github.com/agraboso/redux-api-middleware does a bad job at telling me what succeeded and what errored) Is there a way to force DRF to add information about what was deleted in the body of the response? Thank you! -
Django: can't upload mid-sized file to the server
I've tried to upload 11MB file to the django server and got strange error: backend_1 | Traceback (most recent call last): backend_1 | File "/usr/local/lib/python3.6/wsgiref/handlers.py", line 137, in run backend_1 | self.result = application(self.environ, self.start_response) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 65, in __call__ backend_1 | return self.application(environ, start_response) backend_1 | File "/usr/local/lib/python3.6/site-packages/whitenoise/base.py", line 66, in __call__ backend_1 | return self.application(environ, start_response) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 142, in __call__ backend_1 | response = self.get_response(request) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 78, in get_response backend_1 | response = self._middleware_chain(request) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner backend_1 | response = response_for_exception(request, exc) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception backend_1 | response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception backend_1 | return debug.technical_500_response(request, *exc_info) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/views/debug.py", line 94, in technical_500_response backend_1 | html = reporter.get_traceback_html() backend_1 | File "/usr/local/lib/python3.6/site-packages/django/views/debug.py", line 333, in get_traceback_html backend_1 | c = Context(self.get_traceback_data(), use_l10n=False) backend_1 | File "/usr/local/lib/python3.6/site-packages/django/views/debug.py", line 305, in get_traceback_data backend_1 | 'filtered_POST_items': list(self.filter.get_post_parameters(self.request).items()), backend_1 | File "/usr/local/lib/python3.6/site-packages/django/views/debug.py", line 177, in get_post_parameters backend_1 | return request.POST backend_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 111, in _get_post backend_1 | self._load_post_and_files() backend_1 | File "/usr/local/lib/python3.6/site-packages/django/http/request.py", line 310, in _load_post_and_files backend_1 … -
Software stack with Django and PHP/Wordpress feedback
I am pretty inexperienced with different software stacks and would just like to get some feedback about my current plan for a relatively unusual architecture (as far as I know). For a project we want to use Wordpress for it's page creation features and have a separate API based database in the backend. My current plan was to use Django to connect to the database and create an API to access the data from other sources. In the PHP code for the Wordpress pages, the API is then called to access the data. Some other sources also use the API to import data into the database and do some computations. It just seems very odd to me, so I was wondering if there are any major issues with this architecture. The main reason to use Django is just that it's the easiest option for me. -
Ajax request not returning an HttpResponse
I'm coding a django web app with only one page. This page contains a form with some inputs. When I click on the submit button, I make an ajax call to a function in python. I want to get back some data from this function. HTML file: <form id="strategy" method="post" class="edit_user"> {% csrf_token %} <div class="sel-schedule"> <label>Label: </label> <input id="start_time" type="time" name="start_time" value="09:30" required> </div> <button type="submit" class="inactive boton-lanzar">Launch</button> </form> JS file: $('#strategy').on('submit', function(event){ var start_time = document.getElementsByName("start_time")[0].value; var url = '/method_calculation/'; $.ajax(url, { data: { 'start_time': start_time, }, dataType: 'json', success: function (data) { console.log("new") } }) }); Urls file: urlpatterns = [ path('admin/', admin.site.urls), path('', home, name='home'), path('method_calculation/', method_calculation, name="method_calculation"), ] Views file: def home(request): if request.method == "GET": return render(request, 'index.html') else: return HttpResponse("OK") def method_calculation(request): if request.method == 'POST': start_time_hour = int(request.POST.get('start_time')[0:2]) start_time_minute = int(request.POST.get('start_time')[3:5]) data_comparison = caculate_summit(start_time_hour, start_time_minute) args = {data_comparison} return JsonResponse(args) I'm a bit confused. First, I don't want the page to reload but if I take out the return HttpResponse it says that it needs it. Second, with the current files I get the following error: The view myapp.views.method_calculation didn't return an HttpResponse object. It returned None instead. What am I missing? … -
Proper way of using optional arguments [duplicate]
This question already has an answer here: *args and **kwargs? [duplicate] 11 answers How can I use optional arguments? I have the following code: SaveSlots(clinicobj, docobj, RegAvStart, RegAvStop, "availablereg") SaveSlots(clinicobj, docobj, RegBrStart, RegBrEnd, "brkreg") SaveSlots(clinicobj, docobj, WeekAvStart, WeekAvEnd, "availableweek", day=WeekAvDay) SaveSlots(clinicobj, docobj, WeekBrStart, WeekBrEnd, "brkweek", day=WeekBrDay) SaveSlots(clinicobj, docobj, SpecialAvStart, SpecialAvEnd, "availablespl", date=SpecialAvDate) SaveSlots(clinicobj, docobj, SpecialBrStart, SpecialBrEnd, "brkspl", date=SpecialBrDate) return HttpResponse(msg) def SaveSlots(clinicobj, docobj, startl, endl, typeslot, *args): if typeslot=="availablereg": for start, stop in zip(startl, endl): ts=Timeslots(doctor=docobj, clinic =clinicobj, start=start, stop=stop, available=True) print("Saving Regular Hours\nStarts:%s Ends:%s.." % (start, stop)) ts.save() elif typeslot=="brkreg": for start, stop in zip(startl, endl): ts=Timeslots(doctor=docobj, clinic =clinicobj, start=start, stop=stop, available=False) print("Saving Regular Break Hours\nStarts:%s Ends:%s.." % (start, stop)) ts.save() elif typeslot=="availableweek": daylist = args['day'] for start, stop, day in zip(startl, endl, daylist): ts=Weekdays(doctor=docobj, clinic =clinicobj, start=start, stop=stop, available=True, day=day) print("Saving Weekly Available Hours\nDay:%s Starts:%s Ends:%s.." % (day, start, stop)) elif typeslot=="brkweek": daylist = args['day'] for start, stop, day in zip(startl, endl, daylist): ts=Weekdays(doctor=docobj, clinic =clinicobj, start=start, stop=stop, available=False, day=day) print("Saving Weekly Break Hours\nDay:%s Starts:%s Ends:%s.." % (day, start, stop)) elif typeslot=="availablespl": datelist = args['date'] for start, stop, date in zip(startl, endl, datelist): ts=Specialdays(doctor=docobj, clinic =clinicobj, start=start, stop=stop, available=True, date=date) print("Saving Special Available Hours\nDay:%s Starts:%s Ends:%s.." % (day, … -
Where do I use save and where do I use signals in Django?
I am developing an application, when I save a model, it queries information from an API to complete the fields. Where should I implement this logic? save model or a signals? -
Django CSS not updating
I have this code to refer to my css script in my base.html for my Django project: <link href="{% static 'css/project.css' %}" rel="stylesheet"> The problem is that whenever I add/remove styling from "project.css", it doesn't update when I run the server. I know this happens because every time the page loads the browser cache will think it’s seen the file before and reload the cached version from disk. I also know a solution is to change the css filename every time I make an update. Is there an easier way to reload the .css file every time I refresh my browser? Thanks in advance -
Filter second field in runtime in django admin based on first
I have a model class Event(models.Model): event_date = models.DateField(null=False, blank=True) start = models.ForeignKey(TimeSlots, verbose_name='Slot Time') what I need to do is when I click on date that is in admin panel as I select date the next value that is start should show filtered results as should not show those values that already exists with that date How can I do this in admin panel? -
timer restarts on page reload
{% load static %} <head> {% load static %} <link rel="stylesheet" type="text/css" href={% static 'styleee.css' %}> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Quiz</title> </head> <body > {% csrf_token %} <span id="remainingTime" style="position: fixed;font-size: 23px;background:#ff3300;border-radius: 5px;padding: 10px; box-shadow: 2px 2px 2px 0px;"></span> var time = 1; time--; var sec=60; document.getElementById("remainingTime").innerHTML = time+" : "+sec; //it calls fuction after specific time again and again var x= window.setInterval(timerFunction, 1000); function timerFunction(){ sec--; if (time < 0) { clearInterval(x); document.getElementById("remainingTime").innerHTML = "00 : 00"; document.getElementById("myform").submit(); } localStorage.setItem("key", " Time Left "+ time+" : "+sec); document.getElementById("remainingTime").innerHTML =" Time Left "+ time+" : "+sec; if(sec==0) { sec=60; time--; } } <form id="myform" action="/pythonr/" method="post"> {% csrf_token %} <center><h1 class ="hone">Online Quiz</h1></center> {% for item in query_results %} <div class="question-panel"> <div class="question" > <label class="question-label">{{ item.QUESTION_NO }}</label> <b>{{ item.QUESTION }}</b> </div> <ol class ="op" type='A'> <br><b><li ><input type='radio' name="java{{item.QUESTION_NO}}" value='1' />{{item.OPTION1}}<br><br></li></b> <br><b><li ><input type='radio' name="java{{item.QUESTION_NO}}" value='2' />{{item.OPTION2}}<br><br></li></b> <br><b><li ><input type='radio' name="java{{item.QUESTION_NO}}" value='3' />{{item.OPTION3}}<br><br></li></b> <br><b><li ><input type='radio' name="java{{item.QUESTION_NO}}" value='4' />{{item.OPTION4}}<br><br></li></b> </ol> <hr/> </div> {% endfor %} <center><input type="submit" value="Submit" onclick="return ValidateForm(this.form)"></center> </body> -
Django Heroku app doesn't run after successful deploy
After a successful deploy of a Django project I've made a few attempts to run this app on a dyno, however, it drops some errors. It's starting with no issues locally tho. ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? 2018-10-06T19:08:44.455276+00:00 app[api]: Starting process with command `python manage.py migrate` by user tamerlanium@gmail.com 2018-10-06T19:08:51.519039+00:00 heroku[run.5633]: State changed from starting to up 2018-10-06T19:08:51.515345+00:00 heroku[run.5633]: Awaiting client 2018-10-06T19:08:51.578011+00:00 heroku[run.5633]: Starting process with command `python manage.py migrate` 2018-10-06T19:08:57.062762+00:00 heroku[run.5633]: State changed from up to complete 2018-10-06T19:08:57.046603+00:00 heroku[run.5633]: Process exited with status 1 2018-10-06T19:09:21.974583+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tarlansblog.herokuapp.com request_id=b037e1d6-8a68-4992-8c4e-21462664ff0e fwd="176.107.221.177" dyno= connect= service= status=503 bytes= protocol=https 2018-10-06T19:09:23.424575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=tarlansblog.herokuapp.com request_id=05d085e7-cf21-47a8-9752-1da68c0fa940 fwd="176.107.221.177" dyno= connect= service= status=503 bytes= protocol=https 2018-10-06T19:10:05.844413+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tarlansblog.herokuapp.com request_id=9c64e68d-ba6c-422e-983c-9f9b30aac866 fwd="176.107.221.177" dyno= connect= service= status=503 bytes= protocol=https 2018-10-06T19:10:06.995437+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=tarlansblog.herokuapp.com request_id=9c9f6e8e-0233-4b3f-96c6-71882e4e17fe fwd="176.107.221.177" dyno= connect= service= status=503 bytes= protocol=https 2018-10-06T19:14:25.639377+00:00 app[api]: Starting process with command `python manage.py migrate` by user tamerlanium@gmail.com -
Filtering Django models by user & object
I'm learning Django with a dummy example but having difficulty in understanding how to correctly filter my Django models by an authorised user in my views. In my view I want to list the transactions associated with a users portfolio. The code below runs but when trying to access the result of 't' I get the error: 'ValueError: The QuerySet value for an exact lookup must be limited to one result using slicing.' Any help would be much appreciated, thanks. if request.user.is_authenticated: # Get model data pf = Portfolio.objects.filter(user=request.user) t = Transaction.objects.filter(pf=pf) My model is as below: from django.db import models from django.contrib.auth.models import User class Portfolio(models.Model): # Portfolio has one user associated with it user = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=100, default='-') def __str__(self): return self.name class Transaction(models.Model): # Transaction has one equity associated with it equity = models.ForeignKey('Equity', on_delete=models.CASCADE, null=True) # Transaction has one portfolio associated with it pf = models.ForeignKey('Portfolio', on_delete=models.CASCADE) BUY = 'BUY' SELL = 'SELL' BUY_OR_SELL = ( (BUY, 'BUY'), (SELL, 'SELL'), ) action = models.CharField(choices=BUY_OR_SELL, default=BUY, max_length=5) num = models.FloatField(default=1) price = models.FloatField(default=0) date = models.DateField('date') fee = models.FloatField(default=0) def __str__(self): return f'{self.equity}, {self.num}x{self.price}, {self.date:%d %b %Y}' class Equity(models.Model): class Meta: verbose_name_plural = "Equities" … -
Import Existing Django Project into Visual Studio Code
I have an existing Django application. I want to start developing it in VScode,I have opened my existing directory which i have cloned from a git repo into VScode. I'm totally clueless on how to set it up as a django project. All examples are for setting up a Django project from scratch in VScode which is not helpful because i already know how to that.I'm running on Windows btw. -
Django - ModelForm to template not working
my django template is not submitting data! i know it is very basic thing but there is something i cannot realize here! my Model is: Project_Name = models.CharField(max_length=50) And my ModelForm is: class Meta: model = project fields = ['Project_Name'] And my template is: <div> <label for="{{form.Project_Name}}">Project Name</label> <input type="text" name="Project_Name" id="{{form.Project_Name}}"> </div> My context dict is 'form', i tried so many ways searched online but no luck, can anyone help?... I haven't pasted all the project as the case is similar for the rest fields. -
How to specify type when using zeep
WSDL defines an element ad follows <xs:element minOccurs="0" name="address" nillable="true" type="q146:Address"/> My zeep request is as follows client.service.UpdateAddressDetails(address='sample@sample.com') But I am getting Missing element type (UpdateAddressDetails.address.type) From what i know i need to specify the type for this field. How can I do it, I have come across this zeep documentation but nothing clicked -
I get this error 'User' object has no attribute 'get' in contact form
H when i want to submit contact form when i push submit button i get error user object has no attribute 'get' i add else: in end of function else : contactform() but after that again i get this error i don't know what i have to do ? tnx for help . views.py def ContactUs(request): title = 'Contac Us' if request.method =="POST": form = ContactForm(request.user) if form.is_valid(): name = form.cleaned_data['name'] email = form.cleaned_data['email'] subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] from_email = settings.EMAIL_HOST_USER to_email = [email,"some other thing "] contact_message = (name,email) send_mail(subject,contact_message,message,from_email,to_email,fail_silently=True) else : form = ContactForm() context = {'title': title, 'form': form} return render(request,'contact_us.html',context) contact.html {% extends "base.html" %} {% block title %} Contact Us {{ block.super|title }} {% endblock %} {% block content %} <div class="container"> <div class="row"> <div class="col"> {{ title }} <form action="" method="POST"> {% csrf_token %} {% for field in form %} <div class="form-group" > {{ field.label_tag }} {{ field.error }} {{ field }} </div> {% endfor %} <input type="submit" class="btn btn-primary" value="Submit"> </form> </div> </div> </div> {% endblock %} Forms.py class ContactForm(forms.ModelForm): message = forms.TextInput() class Meta : model = ContactUs fields = ['name','email','subject'] -
Create Form dont submit
I'm a very beginner to python. I try to add a project whith user as foreign key. When i submit my frontend form, nothing happen. I come back to my submission form page but projects are not registered in database. I've got no error message even if my debbug is on. Any advise would be appreciate :) models.py from django.db import models from django.conf import settings from django.contrib.auth.models import User from template.models import Template from colorfield.fields import ColorField from django.utils import timezone def Project_directory_path(instance, filename): # file will be uploaded to MEDIA_ROOT/user_<id>/<filename> return "%s/%s" % (instance.user.username, filename) def Project_uploads_directory_path(instance, imgs, filename): # file will be uploaded to MEDIA_ROOT/user_<id>/<filename> return "%s/%s" % (instance.user.username, imgs, filename) class Tag(models.Model): name = models.CharField(max_length=255) description = models.CharField(max_length=255, null=True, default='') def __str__(self): return self.name class Project(models.Model): user = models.OneToOneField('auth.User', on_delete=models.CASCADE) status = models.CharField(max_length=200, default='Building') name = models.CharField(max_length=200) url = models.URLField() description = models.TextField() #tags = models.OneToOneField(Tag, on_delete=models.CASCADE) image = models.FileField(upload_to=Project_directory_path) create_date = models.DateTimeField(default=timezone.now) updated = models.DateTimeField(auto_now=True) template = models.ForeignKey(Template, on_delete=models.CASCADE) title = models.CharField(max_length=200) slogan = models.CharField(max_length=200) adresse = models.CharField(max_length=200) phone = models.CharField(max_length=200) mail = models.EmailField() focus1_titre = models.CharField(max_length=200) focus1_text = models.TextField() focus1_img = models.FileField(upload_to=Project_uploads_directory_path) focus1_btn = models.CharField(max_length=200) focus1_btn_link = models.CharField(max_length=200) ... def __str__(self): return self.title forms.py … -
Auto Complete field in django
here are my models class TimeSlots(models.Model): start = models.TimeField(null=True, blank=True) end = models.TimeField(null=True, blank=True) class Meta: ordering = ['start'] def __str__(self): return '%s - %s' % (self.start, self.end) class Event(models.Model): event_date = models.DateField(null=False, blank=True) start = models.OneToOneField(TimeSlots) end = models.TimeField(null=True, blank=True) available = models.BooleanField(default=True) patient_name = models.CharField(max_length=60, null=True, blank=True) phone_number = PhoneNumberField(blank=True, null=True) stripePaymentId = models.CharField(max_length=150, null=True, blank=True) stripePaid = models.BooleanField(null=False, blank=True, default=True) key = models.UUIDField(primary_key=False, default=uuid.uuid4, editable=False) sites = models.ManyToManyField(Site, null=True, blank=True) class Meta: verbose_name = u'Scheduling' verbose_name_plural = u'Scheduling' def __unicode__(self): return self.start def get_absolute_url(self): url = reverse('admin:%s_%s_change' % (self._meta.app_label, self._meta.model_name), args=[self.pk]) return u'<a href="%s">%s</a>' % (url, str(self.start)) What I want is that end value of Event Model should be auto filled by the selected Timeslot like when I choose a start value from timeslot for the event model the end value should automatically be filled -
Django REST JSONWebTokenAuthentication + Angular (Authorization details not provided)
For a couple of days i've been trying to get this rather simple authentication setup to work. I'm using the Django REST plugin 'django-rest-framework-jwt' to do JSON web token authentication. When CURLing the API, it works as supposed. Though, when issuing the requests through my Angular application; i'm constantly getting an Unauthorized error with the details 'Authorization details not provided'. However, when crawling the requests, one can clearly see that it is present (the token within the request is valid, as i've used it within the CURL': I'm injecting the authentication header via a interceptor I wrote; which looks like this: intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const auth = this.session.authorization; if (!auth) { return next.handle(req); } else { const newReq = req.clone({ setHeaders: { Authorization: auth, }, }); return next.handle(newReq); } } Further, the settings of the JWT_AUTH settings are defined as follows: JWT_AUTH = { 'JWT_ENCODE_HANDLER': 'rest_framework_jwt.utils.jwt_encode_handler', 'JWT_DECODE_HANDLER': 'rest_framework_jwt.utils.jwt_decode_handler', 'JWT_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_payload_handler', 'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler', 'JWT_RESPONSE_PAYLOAD_HANDLER': 'auth.views.jwt_response_payload_handler', 'JWT_SECRET_KEY': SECRET_KEY, 'JWT_GET_USER_SECRET_KEY': None, 'JWT_PUBLIC_KEY': None, 'JWT_PRIVATE_KEY': None, 'JWT_ALGORITHM': 'HS256', 'JWT_VERIFY': True, 'JWT_VERIFY_EXPIRATION': True, 'JWT_LEEWAY': 0, 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=300), 'JWT_AUDIENCE': None, 'JWT_ISSUER': None, 'JWT_ALLOW_REFRESH': True, 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(seconds=3600), 'JWT_AUTH_HEADER_PREFIX': 'Bearer', 'JWT_AUTH_COOKIE': None, } The framework settings are as follows: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': … -
Django ModelForm input restriction
i have models containing several datefield fields, and i want to make the user be able to enter values through ModelForm but i want to make a restriction that the entered date values must be greater than the previous datefield and lesser than the next datefield.