Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why my css file is not linking with html files in django
here is all my code why css file is not linked with html file. what is the problem as it dosent shows any error and not any effect on webpage. my setting.py and base.html and base.css Also my static folder outsite my app base.html code below: <!DOCTYPE html> {% load static %} <html> <head> <title>First Project</title> <link href="{% static 'css/base.css' %}" rel="stylesheet" > </head> <body> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> <div class="container"> <h1>Parvinder</h1> {% block content %} {% endblock %} </div> </body> </html> base.css code body{ background-color: black; color: blue; } h1{ color: red; } setting.py from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent TEMPLATES_DIR = os.path.join(BASE_DIR,"templates") STATIC_DIR = os.path.join(BASE_DIR,"static",'Users/shree/First_Project/static/') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '(1i-@kb057g&x*8ahp1r5f#f(7f99@6uixjl#j*&x%%sp3ily6' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app', 'register', 'crispy_forms' ] 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', ] ROOT_URLCONF = 'first_project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', … -
React and Django: How to build and edit functionality with Redux?
I'm working on a CRUD app (blog app basically), i sucessfully created the create, read and delete functionality only update/edit is remaining. Im a beginner with redux i really need your help guys to make my app work. I deployed the frontend part on bitbucket here https://bitbucket.org/Yash-Marmat/frontend-part-of-blog-app/src/master/src/ and the backend looks like this (pic below) -
Django 3 error - NoReverseMatch at /; Reverse for 'car_detail' with no arguments not found. 1 pattern(s) tried: ['cars/(?P<id>[0-9]+)$']
I'm currently taking a tutorial on Django from an ebook. I keep getting this error despite doing what is written in the book. Maybe, I'm having an oversight and must have missed something. Can a kind person kindly help go through my code and tell me what I must have been doing wrong? I've attached my code snippets below. Any help will be greatly appreciated. Thanks NoReverseMatch at / Reverse for 'car_detail' with no arguments not found. 1 pattern(s) tried: ['cars/(?P<id>[0-9]+)$'] Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 3.0.7 Exception Type: NoReverseMatch Exception Value: Reverse for 'car_detail' with no arguments not found. 1 pattern(s) tried: ['cars/(?P<id>[0-9]+)$'] Exception Location: C:\Python37\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 677 Python Executable: C:\Python37\python.exe Python Version: 3.7.7 Python Path: ['D:\\Django_Tests\\CarZone_Project', 'C:\\Python37\\python37.zip', 'C:\\Python37\\DLLs', 'C:\\Python37\\lib', 'C:\\Python37', 'C:\\Python37\\lib\\site-packages'] Server time: Wed, 16 Dec 2020 14:46:01 +0000 Error during template rendering In template D:\Django_Tests\CarZone_Project\templates\base.html, error at line 0 Reverse for 'car_detail' with no arguments not found. 1 pattern(s) tried: ['cars/(?P<id>[0-9]+)$'] 1 {% load static %} 2 3 <!DOCTYPE html> 4 <html> 5 6 <head> 7 <title></title> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <meta charset="utf-8"> 10 Traceback Switch to copy-and-paste view C:\Python37\lib\site-packages\django\core\handlers\exception.py in inner response = get_response(request) … ▶ Local vars C:\Python37\lib\site-packages\django\core\handlers\base.py … -
Django/Supervisor: environment variables not set
stack : Django/Nginx/Gunicorn/Sueprvisor I try to work with environment variable but it does not work settings.py SECRET_KEY = os.environ.get('SECRET_KEY', '******************') # if os.environ.get('ENV') == 'PRODUCTION': DEBUG = False ALLOWED_HOSTS = ['192.168.**.*','https://****'] else: DEBUG = True ALLOWED_HOSTS = ['127.0.0.1','localhost', '[::1]'] myapp-gunicorn.conf [program:myapp-gunicorn] ... #environment = ENV="DEV" environment = ENV="PRODUCTION",SECRET_KEY="*****************" When I get url of my web site, DEBUG=True as I can see Django debug toolbar If I run env command, ENV and SECRET_KEY variable are not listed I try to sudo supervisorctl reread and sudo supervisorctl update and restart gunicorn sudo supervisorctl restart myapp-gunicorn but does not change anything I try with tabs without success environment = ENV="PRODUCTION", SECRET_KEY="*****************" -
Create a seconds field in django
I'm trying to create a field that only stores seconds, without the option to enter hours and seconds. Thank you! -
Single template and dynamic menu
I'm new to Django and what I'm trying to do is using a single template for my whole site (which we will call MySite). The page content will dynamically be loaded from a class which returns the page content : content = PageContent().get_content_for("index") My template looks like this : <!DOCTYPE html> <html lang="en-fr"> <head></head> <body> {{ menu | safe }} {{ content | safe}} </body> </html> The menu will be loaded using : def get_menu() -> str: # List of dict menu = [ {"name": "Home", "link": "index"}, {"name": "Products, "link": "products" ] # Generated the HTML formatted menu html_menu = "<ul> for elem in menu: html_menu = f"<li><a href=\"{% url '{elem['link']}' %}\">{elem['name']}</a>" html_menu = "</ul>" return html_menu The output should be : <a href="{% url 'index' %}">Home</a> <a href="{% url 'products' %}>Products</a> The thing is that I am not able to pass a static django url using python string I've tried using {% for elem in menu %} <li><a ...></a> {% endfor %} But I can't use a dict with this Do you guys have any on how I can do it ? If it's not clear enough, don't hesitate to ask me for more details in comment Thank … -
unidentified name errors for mime_types, os and slugify
My IDE is giving me errors for unidentified name for mime_types, os and slugify. To be specific the error lies in the following codes mime_type, _ = mimetypes.guess_type(url) , _, extension = os.path.splitext(url.split('/')[-1]) and slugify(imagefieldinstance.title),. These are my django codes that should list down all images from the D:\testsystem\mysite\images folder and users can choose an image to download into their download folder. image_download.html {% extends "main/header.html" %} {% block content %} <head> </head> <body> <a href="images/" download class="btn btn-dark float-right">Download</a> </body> {% endblock %} views.py def imgdownload(self, request, *args, **kwargs): # first get the instance of your model from the database imagefieldinstance = self.get_object() # Then get the URL of the image to download url = imagefieldinstance.img.url try: # Download the image to the server img = request.get(url) if not 200 <= img.status_code < 400: raise Http404() except Exception as e: raise Http404() from e # Figure out the mimetype of the file mime_type, _ = mimetypes.guess_type(url) # Get the file extension _, extension = os.path.splitext(url.split('/')[-1]) # Create the filename of the download filename = '{}{}'.format( slugify(imagefieldinstance.title), extension ) # Add the content of the (image) file to the response object response = HttpResponse( img.content, content_type=mime_type ) response['Content-Disposition'] = \ … -
Problem loading background image from external css (django)
I'm having trouble loading an image via external CSS on Django. It works fine using inline CSS but I want to understand why it doesn't work using external one. Any help would be appreciated: My tree: ├───migrations │ └───__pycache__ ├───static │ └───website │ ├───css │ ├───img │ └───js ├───templates │ └───website └───__pycache__ CSS: .body { background: url('/static/website/img/Racoon.jpg'); } HTML: {% load static %} <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="{% static 'website/css/main.css' %}"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="preconnect" href="https://fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css2?family=Russo+One&display=swap" rel="stylesheet"> {% block title %} <title> Home </title> {% endblock %} {% block content %} <h1> Home </h1> <p> Homepage of the website </p> {% endblock %} settings.py: STATIC_URL = '/static/' P.S I'm using localhost and image does load via URL: http://127.0.0.1:8000/static/website/img/Racoon.jpg -
Django queryset/orm from postgres sql cross join generate_series
Based on my previous stackoverflow question: Handling of generate_series() in queries with date or timestamp with / without time zone, I'd like to get a django queryset/orm on the following sql. (reason is raw() has some limitation problems with array_agg and only returns 3 items instead of returning all items) SELECT * FROM ( -- complete employee/date grid for division in range SELECT g.d::date AS the_date, id AS employee_id, name, division_id FROM ( SELECT generate_series(MIN(created_at) AT TIME ZONE 'Asia/Kuala_Lumpur' , MAX(created_at) AT TIME ZONE 'Asia/Kuala_Lumpur' , interval '1 day') FROM attendance ) g(d) CROSS JOIN employee e WHERE e.division_id = 1 ) de LEFT JOIN ( -- checkins & checkouts per employee/date for division in range SELECT employee_id, ts::date AS the_date , array_agg(id) as rows , min(ts) FILTER (WHERE activity_type = 1) AS min_check_in , max(ts) FILTER (WHERE activity_type = 2) AS max_check_out , array_agg(ts::time) FILTER (WHERE activity_type = 1) AS check_ins , array_agg(ts::time) FILTER (WHERE activity_type = 2) AS check_outs FROM ( SELECT a.id, a.employee_id, a.activity_type, a.created_at AT TIME ZONE 'Asia/Kuala_Lumpur' AS ts -- convert to timestamp FROM employee e JOIN attendance a ON a.employee_id = e.id WHERE a.created_at >= timestamp '2020-11-20' AT TIME ZONE 'Asia/Kuala_Lumpur' -- "sargable" expressions … -
can't adapt type 'SimpleLazyObject' with get_context_data (Class Based View)
I have a Django web app deployed to Heroku. App is deployed and working well, except for the related issue. Some specs : In my local env I use SQLite 3 DB In Heroku env I use Postgress DB When I try to render a class based view this error happens to me: can't adapt type 'SimpleLazyObject' After some checks about this issue I suspect it is related to the get_context_data. but i don't know how to approach it. View Code: class ProfileListView(LoginRequiredMixin, ListView): model = Profile template_name = 'profiles/profile_list.html' context_object_name = 'qs' def get_queryset(self): qs = Profile.objects.get_all_profiles(self.request.user) return qs def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) return context URL : urlpatterns = [ path('', ProfileListView.as_view(), name='all-profiles-view'), ] -
How to update model object if it exist or create object if isn't
I need some guidance on how properly use update_or_create method As mentioned in django documentation The update_or_create method tries to fetch an object from database based on the given kwargs. If a match is found, it updates the fields passed in the defaults dictionary. Here is raise my misunderstanding. In order to describe in more understandable way Lets make a deal that by kwargs i mean all kwargs passed to update_or_create method except default dictionary. As i understood when **kwargs passed to update_or_create these kwargs are used to fetch database objects. If objects with the same key values will found update_or_create will update object by key values passed in defaults dictionary. But if object wasnt fetched method will create new object from passed kwargs. If it work like i described than using update_or_create can raise dont expectable behaviour. Lets look by example I have created a model class Testmodel(model.Models): call_datetime=models.DateTimeField() i create objects from it. Than i extended model class Testmodel(models.Model): call_datetime=models.DateTimeField() additional=models.CharField() Lets assume that i need to add value of this additional field to objects which was created before extending Testmodel b=Testmodel.objects.update_or_create(call_datetime=value,additional=another_value,defaults={'additional':another_value}) For db objects which was created before extending Testmodel fetching **kwargs (call_datetime, additional) never fetch old … -
How to save char field line by line using enter keyword into database using django models?
i want to save text field line by line into database using enter keyword. After writing some text if i press enter remainging text should save as next line. How to do this? someone help me. I am using form in django. Form contains charfiled (Text area). -
Sending Email with Image inside the body of the html - Django
I know that there have been questions like this on the site, but none of them have been able to answer my difficulty. So I have the code as following: # custom_methods.py from django.core.mail import EmailMultiAlternatives from django.conf import settings from pathlib import Path from email.mime.image import MIMEImage import threading, random, os class EmailThread(threading.Thread): def __init__(self, subject, body, from_email, recipient_list, fail_silently, html): self.subject = subject self.body = body self.from_email = from_email self.recipient_list = recipient_list self.fail_silently = fail_silently self.html = html threading.Thread.__init__(self) def run(self): msg = EmailMultiAlternatives(self.subject, self.body, self.from_email, self.recipient_list) image_path = os.path.join(settings.BASE_DIR, '/static/images/instagram_icon.png') image_name = Path(image_path).name if self.html: msg.attach_alternative(self.html, "text/html") msg.content_subtype = 'html' msg.mixed_subtype = 'related' with open(image_path, 'rb') as f: image = MIMEImage(f.read()) image.add_header('Content-ID', f"<{image_name}>") msg.attach(image) msg.send(self.fail_silently) def send_mail(subject, recipient_list, body='', from_email=settings.EMAIL_HOST_USER, fail_silently=False, html=None, *args, **kwargs): EmailThread(subject, body, from_email, recipient_list, fail_silently, html).start() # views.py class UserRegisterView(CreateView): model = User form_class = CustomUserCreationForm template_name = 'accounts/register.html' def form_valid(self, form): self.object = form.save(commit=False) self.object.is_active = False self.object.save() send_mail( subject=f'{self.object.code} is your Instagram code', recipient_list=[self.object.email], html=render_to_string('accounts/register_email.html', { 'email':self.object.email, 'code':self.object.code, }) ) return redirect('accounts:login') # register_email.html - This is the html that is connected to the email that will be sent {% load static %} {% load inlinecss %} {% inlinecss "css/email.css" %} … -
Model doesn’t show in admin
I am currently working on a science django blog. I've finished coding it all and I realized that the models items overview and content don't appear in my django.admin. Here's an image so you can see. I know there are other threads related to it. However, I couldn't find the solution in those. Models.py: class Post(models.Model): title = models.CharField(max_length=100) overview = models.TextField() timestamp = models.DateTimeField(auto_now_add=True) content = HTMLField() author = models.ForeignKey(Author, on_delete=models.CASCADE) thumbnail = models.ImageField() categories = models.ManyToManyField(Category) featured = models.BooleanField() previous_post = models.ForeignKey( 'self', related_name='previous', on_delete=models.SET_NULL, blank=True, null=True) next_post = models.ForeignKey( 'self', related_name='next', on_delete=models.SET_NULL, blank=True, null=True) Admin.py: from django.contrib import admin from .models import Author, Category, Post, Comment, PostView # Register your models here. admin.site.register(Author) admin.site.register(Category) admin.site.register(Post) Settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'crispy_forms', 'tinymce', 'marketing', 'posts' ] And urls.py: urlpatterns = [ path('admin/', admin.site.urls), By the way, the models.py is in the app Posts. Just in case somebody needs this information. The other models work perfectly. It’s just the overview and the content -
Nginx config of websockets
I have a problem with my bearle django-private-chat server configuration and websockets. I am getting the following ERR_CONNECTION_TIMED_OUT error: WebSocket connection to 'wss://www.example.me:5002/vzyhorv3hkinr105zh34oab3akgu4685/Chat_with_User failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT Here is my django settings.py: CHAT_WS_SERVER_HOST = 'www.example.me' CHAT_WS_SERVER_PORT = 5002 CHAT_WS_SERVER_PROTOCOL = 'wss' CHAT_WS_CLIENT_HOST = 'www.example.me' CHAT_WS_CLIENT_PORT = 80 CHAT_WS_CLIENT_ROUTE = 'wss/' Here is my nginx (/etc/nginx/sites-available/nginx): server { server_name example.me www.example.me; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/christian/project_mojo/project_mojo; } location /media/ { root /home/christian/project_mojo/project_mojo; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/example.me/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.me/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = www.example.me) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = example.me) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name example.me www.example.me; return 404; # managed by Certbot } server { listen [::]:5002; location / { proxy_pass https://example.me; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } } Nginx -t is okay. However, I am sure that the nginx is not correctly set up. Can anybody … -
django_heroku.settings(locals()) not at the end for collectstatic
I created an webapp with Django, heroku and S3. In production it seems that the upload and urls of my static files are only working when I put in the settings.py the STATIC_URL and STATIC_ROOT after django_heroku.settings(locals()). django_heroku.settings(locals()) STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') So far I understand that django_heroku.settings(locals()) would overwrite my locations with a default value and I was wondering what exaclty happens here and if this is an appropriates solution for production, as django_heroku.settings(locals()) should be actually at then end as far as I know. -
How to retrieve all models data by User id in Django Serializer?
I have following serializers class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['id'] class PersonSerializer(serializers.ModelSerializer): user = UserSerializer() comments = CommentSerializer(source='comment_set', many=True) class Meta: model = Person fields = '__all__' And related views class PersonRetrieveView(generics.RetrieveAPIView): queryset = Person.objects.all() serializer_class = PersonSerializer class UserRetrieveView(generics.RetrieveAPIView): queryset = User.objects.all() serializer_class = UserSerializer permission_classes = (permissions.IsAuthenticated, ) The models are standard, Person related to User by Foreign key. So my url path('persons/<int:pk>/', PersonRetrieveView.as_view()), returns Person object with user field with user id. I want to make kinda reverse logic. By user id I want to query all users with field person with all persons related to this user by user id. I can't just make class UserSerializer(serializers.ModelSerializer): person = PersonSerializer() class Meta: model = User fields = ['id'] because Person serializer defined below the User serializer. -
Changes not applied on production
One of my vassal Django apps not updating/apply changes on production. I try to touch app ini file in turned on master, but nothing happened. I didn't have any errors in console, so I don't know what can be wrong. Also I tryed touch-reload but I still have old data. Server use Django + Nginx + uWsgi. -
MYSQL equivalent query in Django Average and Group By
Please help me to write the same query in Django using ORM SELECT DATE(`created_at`) DateOnly, AVG(`amout`) AS val_1 FROM `account` GROUP BY DateOnly -
How to change div data-src to image_tag in django?
I need this expression but using static tag otherwise the images are not being displayed in project. I tried something like this. but it is not working for div tag. I can't find anything on google.. thankyou. -
import name patterns issue with django
After digging I cannot manage to understand what happened with our server. I got this error when loading the web. It was working and anyone touch anything. I have changed the ownership of the application.txt because this error. [Wed Dec 16 04:38:12.059839 2020] [wsgi:error] [pid 12343:tid 140072894818048] [remote xx.xx.xxx.xx:xxxxx] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/yhmp-app/YHMP/eamena/logs/application.txt' After this it is showing up the next error in the browser: and all this is coming form the error.log when trying to access: ed Dec 16 13:05:46.856703 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client] AH01626: authorization result of Require all granted: granted [Wed Dec 16 13:05:46.856746 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client ] AH01626: authorization result of <RequireAny>: granted [Wed Dec 16 13:05:46.856782 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client :56384] AH01626: authorization result of Require all granted: granted [Wed Dec 16 13:05:46.856787 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client :56384] AH01626: authorization result of <RequireAny>: granted [Wed Dec 16 07:05:46.857793 2020] [wsgi:error] [pid 14047:tid 140483690739456] Internal Server Error: / [Wed Dec 16 07:05:46.857809 2020] [wsgi:error] [pid 14047:tid 140483690739456] Traceback (most recent call last): [Wed Dec 16 07:05:46.857814 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in … -
Django won't migrate because one model used to be a subclass
I'm using Django 3.0.4 with MySQL 5.7 on Ubuntu 18.04. I have a model Apples. I created a second model BadApples as a subclass of it: # models.py class Apples(models.Model): # fields class BadApples(Apples): pass I ran the migration, which completed successfully. Then, I decided that the 'subclass' approach wasn't working and that BadApples should be its own model. I rewrote the models like this: # models.py class Apples(models.Model): # fields class BadApples(models.Model): # fields When I tried to run the migration, I ran into the following error: MySQLdb._exceptions.OperationalError: (1090, "You can't delete all columns with ALTER TABLE; use DROP TABLE instead") As best I can tell, migrating BadApples from one form to the other involves changing all of its columns. Instead of dropping the table and recreating it, Django uses ALTER TABLE commands only, which throws the MySQL error when it attempts to remove the last column of the original BadApples. This seems related to this bug, purportedly fixed over two years ago, but evidently not fully. To work around this bug, my idea was to remove BadApples from models.py and all references to BadApples from the rest of the code (in this case, views.py and admin.py). Then I'd … -
Get top n records for each group with Django queryset
I have a model like the following Table, create table `mytable` ( `person` varchar(10), `groupname` int, `age` int ); And I want to get the 2 oldest people from each group. The original SQL question and answers are here StackOverflow and One of the solutions that work is SELECT person, groupname, age FROM ( SELECT person, groupname, age, @rn := IF(@prev = groupname, @rn + 1, 1) AS rn, @prev := groupname FROM mytable JOIN (SELECT @prev := NULL, @rn := 0) AS vars ORDER BY groupname, age DESC, person ) AS T1 WHERE rn <= 2 You can check the SQL output here as well SQLFIDLE I just want to know how can I implement this query in Django's views as queryset. -
Scheduling API: This involves a single endpoint, which accepts Date-Time and a URL as a parameter
When the API is called, a task will be scheduled. A GET request (no parameters needed) should be sent on the URL specified (second parameter), when the current Date-Time matches the one specified in the Date-Time parameter (first parameter). The GETrequest on the URL parameter will only return a status code, and no response body please tell me this what i have to do in this task. -
validate django formsets single felid
I need to validate if the start year is less than the end year using the form clean function but it is not working in Django this is the formset formset ExperienceModelFormFormset = inlineformset_factory( PersonalInfo,Experience, fields = ('Company', 'Position', 'YearofExp','Start', 'End'), extra=0, min_num= 1, validate_min=True, widgets = { 'Company': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'company Name', 'required':'False', 'oninput':'process(this)', 'onKeyPress':'return ValidateAlpha(event)', } ), 'Position': forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Position', 'oninput':'process(this)', 'required':'False', } ), 'YearofExp': forms.Select( attrs={ 'class': 'form-control', 'placeholder': 'Year of experiance', 'required':'False', } ), 'Start': forms.DateInput( attrs={ 'class': 'form-control', 'placeholder': 'Your email', 'type': 'DATE', 'required':'False', } ), 'End': forms.DateInput( attrs={ 'class': 'form-control', 'placeholder': 'DATE', 'type': 'date', 'required':'False', } ), } ) )