Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Want to save returned value or printed value of another python file in postgresql's existing table of a specific column.from django file DB created
I have the smtp mailing code in smtp.py file with following below code. In the field "number_of_emails_sent in (models.py).At the beginning when the user will post his details that field will be empty as default. But when we start our process to implement the smtp.py file it(number_of_emails_sent in database) should be appended each time we run the code for the specific user with his details. For example there are 3 users["king","queen","soldier"], when they post at the first time he has fields in api like {"user_email" :"King@gmail.com", "password":"1587687", "SMTP_PORT" :" 078", "SMTP_HOST" : "025", "Is_Active" :"True", "subject" : "Hi", "Body" : "How are you", "Number_of_emails_sent: "" } So this data will be saved in Database of specific table but the number of fields will be empty for all users.So here I want to insert value which should be increases each time the smtp flow of a specific user will done. For example today for user "king" I run the smtp flow 3 times so the value of particular user will be 3.And if I run the flow after two days,the code I run in that day suppose 5 times so the value in the ("Number_of_emails_sent") should be 8. So it should … -
How to upload a file using forms in django
I have being having issues with uploading an image file into my database. Here is the code. models.py from django.db import models from datetime import datetime class Product(models.Model): name = models.CharField(max_length=1000, blank=False, null=False) image = models.FileField() price = models.IntegerField(default=0, blank=False, null=False) stock = models.IntegerField(default=0, blank=False, null=False) forms.py from django import forms from .models import Product class ProductCreationForm(forms.ModelForm): class Meta: model = Product fields = ( "name", "image", "price", "stock", ) views.py from .models import Product from .forms import ProductCreationForm def product_create(request): form = ProductCreationForm() if request.method == "POST": form = ProductCreationForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] image = form.cleaned_data['image'] price = form.cleaned_data['price'] stock = form.cleaned_data['stock'] item = Product.objects.create(name=name, image=image, price=price, stock=stock) item.save() return redirect('product-view') else: messages.info(request, 'Invalid information entry!') return redirect('product-create') else: return render(request, "create.html", {"form": form}) create.html {% if user.is_authenticated %} <form method="post"> {% csrf_token %} {% for message in messages %} {{ message }} {% endfor %} {{ form.as_p }} <input type="submit", value="Done"> </form> {% endif %} settings.py STATIC_URL = 'static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') urls.py from django.conf.urls.static import static from django.conf import settings if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) Everytime i create a new product from … -
How to create correct url in tepmplate Django
I have this link in my templates: <a href="{% url 'main:user-main-account' %}?=client_account{{ client_account.id }}"> like a link it looks like: https://mysite.ua/main/user_main_account/?=client_account=1 How can I change my template link to get link like this: https://mysite.ua/main/client_account/1/user_main_accounts My 2 urls in urls.py look like this: path('user_main_account/<int:pk>/', ........) path('client_account'/<int:pk>/'.........) Please help me!I am stuck of 3 days. -
How to make REST Search-filter case-insensitive for none english letters?
Accordance to the REST's search-filter, "By default, searches will use case-insensitive partial matches". Everything works fine for english letters but for none-english ones it doesn't. class ProductsAPIView(generics.ListCreateAPIView): queryset = Product.objects.all() serializer_class = ProductSerializer filter_backends = (filters.SearchFilter,) search_fields = ['title', 'name'] My view path('all/', views.ProductsAPIView.as_view()), My url path For example: When I search in english letters: When I search in none-english letters: I have an item: { "id": 10, "productType": "Напитки", "measurment": "л", "product_image": "http://127.0.0.1:8000/images/logo.png", "title": "Фанта (0.5)", "name": "Фанта", "price": 40, "description": "", "created": "2022-06-21T07:20:07.582387Z", "updated": "2022-06-21T07:20:07.582435Z" }, "title": "Фанта (0.5)", - starts with upper case. So when I try /api/all/?search=ф. ( ф - lower, Ф - upper, in this case I wrote the lower ). I don't get this item. But I get it when I try with /api/all/?search=Ф (The upper one) I get the item what is contrary to case-insensitive. -
Django Recursive Query with self Foreign Key
I have following django model with parent attribute being as self foreign key class PolicyCoverage(TimeStampedModel): policy = models.ForeignKey(Policy, on_delete=models.CASCADE) name = models.CharField(max_length=100) slug = AutoSlugField(populate_from='name', editable=True, slugify_function=slugify) amount = models.DecimalField(max_digits=19, decimal_places=10) parent = models.ForeignKey( 'self', on_delete=models.CASCADE, null=True, blank=True) I have setup my serializer to send data for front end but I am not getting desired output but I am not getting desired output for easiness I want to get data in this way {parent A--> {child A of parent A, child B of parent A[ {child A of Parent B Child B of Parent A} ] but data i am getting right now is as {parent A--> {child A of parent A, child B of parent A[ {child A of Parent B Child B of Parent A } ]}, {child A of Parent B}, {Child B of Parent A} how do i make recursive query work I tried almost all previuos stack overflow qsn but I am going nowhere. here is serializer I have been doing class ParentSerializer(serializers.ModelSerializer): class Meta: model = PolicyCoverage fields = [ 'slug', 'policy', 'name', 'amount', 'parent' ] class PolicyCoverageSerializer(serializers.ModelSerializer): parent = serializers.SerializerMethodField() class Meta: model = PolicyCoverage fields = [ 'slug', 'policy', 'name', 'amount', 'parent' … -
Ngnix - Django 413 Request Entity Too Large
i already read and tried the foundable soulutions here but nothing helped me out. I have this conf file of nginx: user nginx; # Sets the worker threads to the number of CPU cores available in the system for best performance. # Should be > the number of CPU cores. # Maximum number of connections = worker_processes * worker_connections # Default: 1 worker_processes auto; # Maximum number of open files per worker process. # Should be > worker_connections. # Default: no limit worker_rlimit_nofile 8192; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; load_module modules/ngx_http_image_filter_module.so; events { # If you need more connections than this, you start optimizing your OS. # That's probably the point at which you hire people who are smarter than you as this is *a lot* of requests. # Should be < worker_rlimit_nofile. # Default: 512 worker_connections 4000; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; client_max_body_size 200M; # Hide nginx version information. # Default: on server_tokens off; sendfile on; #tcp_nopush on; keepalive_timeout 65; include /etc/nginx/conf.d/*.nginx; } I also added this to my settings.py : FILE_UPLOAD_MAX_MEMORY_SIZE = 1005242880 Can anyone help me? -
SuspiciousFileOperation at /report/ The joined path is located outside of the base path component: Django
hi i need to get to generate a pdf with images using xhtml2pdf; I have added the method link_callback like that: def link_callbacke(uri, rel): result = finders.find(uri) print("0") if result: if not isinstance(result, (list, tuple)): result = [result] result = list(os.path.realpath(path) for path in result) path=result[0] else: sUrl = settings.STATIC_URL sRoot = settings.STATIC_ROOT mUrl = settings.MEDIA_URL mRoot = settings.MEDIA_ROOT if uri.startswith(mUrl): path = os.path.join(mRoot, uri.replace(mUrl, "")) elif uri.startswith(sUrl): path = os.path.join(sRoot, uri.replace(sUrl, "")) else: return uri # make sure that file exists if not os.path.isfile(path): return path this is in views.py , how i was getting the image field: image1_full = CustomerPersonalData.objects.get(user_related=request.user) obj_image1 = CustomerPersonalData._meta.get_field("image1" value_image1 = obj_image1.value_from_object(image1_full) in models.py: class CustomerPersonalData(models.Model): user_related = models.OneToOneField(User, on_delete = models.CASCADE) image1 = models.ImageField(blank=True, upload_to="media") def save(self, force_insert=False, force_update=False): img = Image.open(self.image1) super(CustomerPersonalData, self).save(force_insert, force_update) and in the generated_pdf.html: <p><img src="/home/dev/.virtualenvs/django-projects/project1/static/media/{{ value_image1 }}"></p> in settings.py: STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') ---> an error displayed : SuspiciousFileOperation at /report/ The joined path (/home/dev/.virtualenvs/django-projects/project1/static/media/media/image1.png) is located outside of the base path component (/home/dev/.virtualenvs/django-projects/lib/python3.7/site-packages/django/contrib/admin/static) ---I want to know what does mean this error and how i can resolve it otherwise the path(/home/dev/.virtualenvs/django-projects/project1/static/media/media/image1.png) is correct. -
the Data doesnt get deleted from CRUD page and aso doesnt get deleted in Database
Hi I am new to django and I am doing CRUD operations,I have successfully completed CRU,only delete remains,I am try to SOFT DELETE the data. below is my del_cat function: def del_cat(request,id): delcategory = Categories.objects.get(id=id) delcat={} delcat['isactive']=False form = CategoriesSerializer(delcategory,data=delcat) if form.is_valid(): print(form.errors) form.save() messages.success(request,'Record Deleted Successfully...!:)') return redirect('categories:show_cat') else: print("sfsdrf",form.errors) return redirect('categories:show_cat') below is the urls path below is the href path for the delete button yet the data doesnt get deleted and it aso remains in the databse,what could the problem in the code be? -
Django / duplicate key value violates unique constraint every time creating new object with CreateAPIView
django.db.utils.IntegrityError: duplicate key value violates unique constraint "publication_article_pkey" DETAIL: Key (id)=(13233) already exists. Seeing this error every time using ArticleCreateView endpoint. Object is created fine, but i can’t understand where and because of what this error raises. I would be grateful for any help and clarification! class ArticleCreateView(generics.CreateAPIView): """Article add""" permission_classes = [permissions.IsAuthenticated] queryset = Article.objects.all() serializer_class = AddArticleSerializer lookup_field = "slug" def perform_create(self, serializer): serializer.save(author=self.request.user, status=0) Serializer: class AddArticleSerializer(serializers.ModelSerializer): tag = serializers.SlugRelatedField( many=True, queryset=Tag.objects.all(), slug_field='name' ) class Meta: model = Article fields = ("title", "content", "description", "language", "tag", "cover") Overrided Article Model save method: def save(self, *args, **kwargs): if not self.id: self.created_at = timezone.now() self.updated_at = timezone.now() if not self.slug: super().save(*args, **kwargs) self.slug = slugify(unidecode.unidecode(f'{self.id} {self.title}')) self.save() self.updated_at = timezone.now() super().save(*args, **kwargs) -
Why do I keep getting the axios error in my Django React app on Heroku?
I developed a simple Django React application and deployed on to heroku: https://friendly-interview-duck.herokuapp.com/ Even though the backend and frontend connection was working correctly via axios in local, I started getting the infamous GET http://127.0.0.1:8000/api/questions/ net::ERR_CONNECTION_REFUSED error in the deployed app. Obviously, I thought this had something to do with hosts/CORS. I initially had CORS_ALLOWED_ORIGINS = [ 'https://friendly-interview-duck.herokuapp.com', 'https://127.0.0.1:8000.com', 'https://localhost.com' ] ALLOWED_HOSTS = [ 'https://friendly-interview-duck.herokuapp.com', 'https://127.0.0.1:8000.com', 'https://localhost.com'] in my setting.py but getting this error, I changed it to: CORS_ORIGIN_ALLOW_ALL = True ALLOWED_HOSTS = ['*'] to experiment. And guess what? I am still getting connection refused error! I cleared the cash multiple times and even browsed into the deployed url from another computer and the error still exists. As a note, I know many people miss '/' at the end of their urls which causes this but I have a '/' at the end of my request urls as well so that can't be the problem. What am I missing here? https://github.com/gokceozer1/friendly-interview-duck.git -
How to assign a local IP address to a public IP/Port address using NGINX with UWSGI?
I have a web application that is running in a local server using a local IP address and the port 80. However, I would like to be able to access the web application from the Internet. Thus, I have got a public a IP address from a telecommunication company. I have configured the NGINX server as followed: upstream django { server unix:///my_path/my_project.sock; # server 127.0.0.1:8000; } # configuration of the server server { # the port your site will be served on listen 80; # the domain name it will serve for server_name local_ip_address; charset utf-8; # max upload size client_max_body_size 75M; # Django media location /media { alias /my_path/media; } location /static { alias /my_path/static; } location / { uwsgi_pass django; include /my_path/uwsgi_params; } } In my setting.pyfile, I have used the local IP address in the ALLOWED_HOSTS = ['local IP address']. But in my firewall, I have forwarded this IP to the public one. I have done all the nginx configurations. When I run the application from the local IP address, it is working perfectly, but I run the application from the public IP, it is showing page not found. How can I assign the local IP address … -
How to get request user or logged user from model manager?
We have created a manager class in models.py We can not access request user. class Course(models.Model): instructors = models.ManyToManyField(get_user_model(), .... class InstructorCourseManager(models.Manager): def get_queryset(self): return super().get_queryset().filter(instructors=request.user) class ProxyInstructorCourse(Course): objects = InstructorCourseManager() class Meta: proxy = True Do you have any idea? -
Issues playing mp4 on apple on django website
I'm building a Django website. My users can record a video and then others can see these videos. The recording is done with javascript: const mimeType = 'video/mp4'; shouldStop = false; const constraints = { audio: { echoCancellation: true, noiseSuppression: true, }, // audio: true, video: { width: 480, height: 480, facingMode: 'user', }, }; const stream = await navigator.mediaDevices.getUserMedia(constraints); const blob = new Blob(recordedChunks, { type: mimeType }); And the sent to a django view: let response = await fetch("/send-video/", { method: "post", body: blob, headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', "X-CSRFToken":csrftoken, }, }).then( ... ) In my views if request.method == 'POST': user = request.user file_name = f"{user}.mp4" if (len(sys.argv) >= 2 and sys.argv[1] == 'runserver'): file_path = file_name else: file_path = f"{your_media_root}temp/{file_name}" webm_bytes = bytes(request.body) video_file = open(file_path, "wb") video_file.write(webm_bytes) if mimetypes.guess_type(file_path)[0].startswith('video/mp4'): print(mimetypes.guess_type(file_path)) video_file.close() else: video_file.write(b"") video_file.close() Now I can save these files to a django model field. I use django-private-storage to make sure only users with the correct authentication can view the files. django-private-storage uses a FileReponse to play the video. and it generates a template with: <video controls="" autoplay="" name="media"> <source src="http://127.0.0.1:8000/play-job-video/" type="video/mp4"> </video> All works fine on any browser on android. I can record … -
How to store 2D Array in model of Django
Problem: I am in need to store 2D array in one of the field of the Table. Example id:1 Teacher_name:"Amit" time: [[9:00am, 2:00pm], [2:00pm,6:00pm], [6:00am, 9:00pm]] # Need to store 2-D array kind of multiple time stamps in a field, code is here: Model.py class ScheduleClassification(models.Model): vendor_id = models.ForeignKey(Vendor, on_delete=models.CASCADE, default=None, null=True) id = models.IntegerField(primary_key=True) name = models.CharField(max_length=100) description = models.CharField(max_length=1000) start_date = models.DateField(auto_now_add=True) end_date = models.DateField(auto_now_add=True) duration = models.CharField(max_length=20, default="forever") day_type = models.CharField(max_length=20) time = #how do i make this field how can i store this please let me know the best way to do this. in django models -
I don't know how to resolve this error 'RemovedInDjango110Warning'
when I created the project. And run the server I got the error django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'django.templatetags.future': cannot import name 'RemovedInDjango110Warning' -
How to reorder Wagtail admin menu items
There are some custom menu items in the admin's menu, it is easy to order them (the items marked in red below). Just set menu_order of the custom ModelAdmin object. The question is how to reorder the built-in menu items, such as Pages, Images, Media, and Settings. -
django Queryset status count between week dates inappropriate data is coming
I want to calculate the active status count between week dates. what I am trying that is given below. date_list : ['2022-04-06', '2022-04-13', '2022-04-20', '2022-04-27', '2022-05-04', '2022-05-11', '2022-05-18', '2022-05-25', '2022-06-01', '2022-06-08', '2022-06-15', '2022-06-22', '2022-06-29'] def get_status_count(date_list): status_dict = [] for i in range(0,len(date_list)): week_list = date_list[i:i-7] print(week_list,'ttttttttt') datetime_object = datetime.strptime(str(date_list[i]), '%Y-%m-%d') last_date = datetime_object + timedelta(days=-7) dateStr = last_date.strftime("%Y-%m-%d") tsts = [dateStr,date_list[i]] count = Status.objects.filter(arrival_date__range = tsts).values("arrival_date").annotate(dcount=Count('arrival_date')) status_dict.append({"date" : date_list[i],"count":count}) return status_dict Output i am getting like : {'date': '2022-04-06', 'count': <QuerySet [{'arrival_date': '2022-04-06', 'dcount': 1}]>}{'date': '2022-04-13', 'count': <QuerySet [{'arrival_date': '2022-04-06', 'dcount': 1}]>}{'date': '2022-04-20', 'count': <QuerySet []>}{'date': '2022-04-27', 'count': <QuerySet []>}{'date': '2022-05-04', 'count': <QuerySet []>}{'date': '2022-05-11', 'count': <QuerySet []>}{'date': '2022-05-18', 'count': <QuerySet []>}{'date': '2022-05-25', 'count': <QuerySet []>}{'date': '2022-06-01', 'count': <QuerySet []>}{'date': '2022-06-08', 'count': <QuerySet []>}{'date': '2022-06-15', 'count': <QuerySet []>}{'date': '2022-06-22', 'count': <QuerySet []>}{'date': '2022-06-29', 'count': <QuerySet [{'arrival_date': '2022-06-28', 'dcount': 1}, {'arrival_date': '2022-06-29', 'dcount': 1}]>} But it is not coming as I want data like : [{'arrival_date': '2022-04-06', 'dcount': 1},{'arrival_date': '2022-04-13', 'dcount': 2},{'arrival_date': '2022-04-20', 'dcount': 0}, and so on.....] In database data I have : +----+-----------+--------+-------------+--------------+--------------+--------+ | id | number | state | name | checker_name | arrival_date | locals | +----+-----------+--------+-------------+--------------+--------------+--------+ | 1 | 1665022 | close | ab | … -
Django, Heroku - [remote rejected] main -> main(pre-receive hook declined)
I am reading the Django for Beginners book to learn deploy django app. From Chapter 3: Pages App, deployment with heroku is taught. However everytime I follow the steps for deployment I get the same error everytime, similar to something shown below with different heroku url. ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/afternoon-anchorage-50413.git' -
django: how to control user access to web content with limited allowence per day?
I have an online pricing website using django. Now I want to restrict non-vip users to use my website to obtain price. For non-vip users, after login they can only use my web to get price only 3 times per day. If they click "get price" button the fourth time during the day, there should be an alert message showing "non-vip users can only check price 3 times per day" Can we do this directly in frontend using javascripts? -
TemplateSyntaxError at /comments/10/ Could not parse the remainder: '==comm.user.id' from 'request.user.id==comm.user.id'
After using for loop I get a specific comment and its related user and only want to delete the comment if that user has written it. How to write variable inside {% if ---%}. Template error: In template C:\Users\SHAFQUET NAGHMI\socialnetwork\socialapp\templates\socialapp\comment.html, error at line 27 Could not parse the remainder: '==comm.user.id' from 'request.user.id==comm.user.id' 17 : <P>Please <a href="{% url 'login' %}">login</a> to add comment </P> 18 : 19 : {% endif %} 20 : </form> 21 : <h3>comments..</h3> 22 : 23 : {% for comm in comments %} 24 : 25 : <a class="comment-user" href="{% url 'profile' comm.user.username %}">{{comm.user}}</a> 26 : {{comm.comment}} 27 : {% if request.user.id==comm.user.id %} 28 : <a class="delete" href="/delete_comment/{{post.id}}/{{comm.id}}/">Delete</a> 29 : {% endif %} 30 : <br><br> 31 : {% endfor %} 32 : <!--{{post}} {{comm.id}}--> 33 : 34 : </div> 35 : </div> 36 : {% endblock %} -
How to store fetched data in Django?
I don't understand how to store or where to store large data when Django app is running. IDEA: I have data in postgreSQL and time to fetch it is about 10-20sek (that's not a point). Then I run Django app with Nginx and run it with some workers. And when rach worker open specific URl fetch function runs and fetch data from DB (10-20sek), but data for each worker is SAME. I want to fetch data from DB and store it somewhere, and when each worker open specific URL it doesn't need to fetch data, but it is also fetched and just return data. What is main approach on that situation? -
How to ignore some errors with Sentry (not to send them)?
I have a project based on django (3.2.10) and sentry-sdk (1.16.0) There is my sentry-init file: from os import getenv SENTRY_URL = getenv('SENTRY_URL') if SENTRY_URL: from sentry_sdk import init from sentry_sdk.integrations.django import DjangoIntegration from sentry_sdk.integrations.redis import RedisIntegration from sentry_sdk.integrations.celery import CeleryIntegration init( dsn=SENTRY_URL, integrations=[DjangoIntegration(), RedisIntegration(), CeleryIntegration()], traces_sample_rate=1.0, send_default_pii=True, debug=True, ) I have a CustomError inherited from Exception Every time I raise the CustomError sentry-sdk sends it to the dsn-url. I want to ignore some class of error or something like this. How can I do this? -
want to be able to do the post method and display the data in the table field
currently when i submit the function first takes me to the api page where i have to click on post again for the results to update in the database then click on back button and refresh the page to see the updated data, it will be nice if the reduce button could update and display the data on the table without redirecting to the api page. Thank You, Please Help. trying to render the data here @api_view(['POST']) def sRd(request, pk): sw = get_object_or_404(Swimmers,id=pk) # gets just one record current_sessions = sw.sessions + 10 sw.sessions = current_sessions # updates just the one in memory field for sw (for the one record) sw.save() # you may want to do this to commit the new value serializer = SubSerializer(instance=sw, data=request.data) if serializer.is_valid(): serializer.save() return JsonResponse(serializer.data, safe=False, status=status.HTTP_201_CREATED) return JsonResponse(data=serializer.errors, safe=False, status=status.HTTP_400_BAD_REQUEST) Want to render the data here on this page: return render(request, 'accounts/modals/swimming/_vw_table.html', {'sw': sw}) -
Fastest way to count Django manytomanys?
What is the fastest way to count Django manytomanys? I have hundreds of thousands rows of data, and I want to count answers. Need are: how many objects where answer is not null and answer's counts per Option. Models: class Option(models.Model): text = models.CharField(max_length=255, blank=False) class MultiChoiceAnswer(models.Model): user = models.ForeignKey(User) answers = models.ManyToManyField( Option, blank=True, verbose_name=_("options"), ) -
How to get country flag selected on edit html form?
I am trying to do get country code selected on edit form but somehow it's not appear while during update form. if field has no country code then it's showing flag icon in field but if it's county code is there then no flags icon will be there on contact field. it's working very well on For Insert User but some how it's not working for edit. I don't know what's issue is there. I am not sure there is issue of two same fields with same id's javascript is conflict or may be there is another issue? and all form element is running in for loop . in django python HTML CODE : <script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.17/js/intlTelInput.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.17/css/intlTelInput.css" rel="stylesheet"/> <div class="form-row"> <div class="form-group col-md-6 smsForm2"> <label for="contact1">SMS No.<span style="color:#ff0000">*</span></label> <input type="tel" class="form-control" name="smsno2" id="smsno2" value="{{vr.sms_no}}" placeholder="SMS No." pattern="^(00|\+)[1-9]{1}([0-9][\s]*){9,16}$" required onkeyup="myFunctionsms(this)" /> <div class="custm-valid" id="sms_validate" style="display:none;color: #28a745;font-family: 'Inter',sans-serif;font-weight: 400;font-size: 80%;">Valid.</div> <div class="custm-invalid" id="sms_ntvalidate" style="display:none;font-family: 'Inter',sans-serif;font-weight: 400;font-size: 80%;color: #dc3545;">Please enter valid contact no.</div> </div> <div class="form-group col-md-6 whatsappForm2"> <label for="contact2">WhatsApp No.<span style="color:#ff0000">*</span></label> <input type="text" class="form-control" name="whtspno2" id="whtspno2" value="{{vr.whtsp_no}}" placeholder="WhatsApp No." pattern="^(00|\+)[1-9]{1}([0-9][\s]*){9,16}$" required onkeyup="myFunctionwhtsapp(this)" /> <div class="custm-valid" id="whts_validate"style="display:none;color: #28a745;font-family: 'Inter',sans-serif;font-weight: 400;font-size: 80%;">Valid.</div> <div class="custm-invalid" id="whts_ntvalidate" style="display:none;font-family: 'Inter',sans-serif;font-weight: 400;font-size: 80%;color: #dc3545;">Please enter valid contact …