The first thing you can learn HTML, whether you want to become a professional web developer or just want to learn more about how websites work. The basic language for developing web pages and web applications is HTML. A server ...
Asynchronous Javascript One of AJAX’s benefits is it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However, using AJAX does not guarantee the user will not wait for the asynchronous JavaScript and ...
How To Make Cookie Free Domain An HTTP cookie (also known as a web cookie, Internet cookie, browser cookie, or simply cookie) is a small piece of data sent from a website and stored on the user’s computer by the ...
How To Use Static CSS JS Files In Django
Create static folder(assets or any name) at root of your project and specify this in your project settings.py file like this #CODE IN settings.py STATIC_URL = '/assets/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'assets'), ] IN HTML FILE {% load static %} <script src="{% static 'js/jquery-3.3.1Read more
Create static folder(assets or any name) at root of your project and specify this in your project settings.py file like this
#CODE
IN settings.py
STATIC_URL = ‘/assets/’
STATICFILES_DIRS = [
os.path.join(BASE_DIR, ‘assets’),
]
IN HTML FILE
{% load static %}
<script src=”{% static ‘js/jquery-3.3.1.min.js’ %}”></script>
See less<link rel=”stylesheet” href=”{% static ‘css/dept_emp_style.css’ %}”>
Where to specify or define routes in django?
You can define routes in urls.py file in "subfolder" which has same like you your project folder name in project. You can specify any route in urls.py like this path('/index', app_name.views)
You can define routes in urls.py file in “subfolder” which has same like you your project folder name in project.
See lessYou can specify any route in urls.py like this path(‘/index’, app_name.views)
how to create custom tags in django?
Create a file like file_name.py in any app and place this below code #Code from django import template register = template.Library() IN TEMPLATE FILE @register.simple_tag <------------------------------------------------ Regestring a tag def get_otp_sec(token): <-------------------------------Read more
Create a file like file_name.py in any app and place this below code
#Code
from django import template
register = template.Library()
IN TEMPLATE FILE
@register.simple_tag <———————————————— Regestring a tag
def get_otp_sec(token): <———————————————— Function or tag name
user = models.users.objects.get(token=token,end_date__isnull=True);
diff = datetime.now() – user.otp_created_at;
return diff.total_seconds();<—————————————— Calculating Seconds betweend two dates
IN HTML FILE
{% random_quote token_value as rand%}
To DISPLAY THE VALUE
{{ rand }}
See lessHow many calls is required to link the php and mysql in PHP?
There is only one call placed first time while checking connection between php and mysql database using connection file in php
There is only one call placed first time while checking connection between php and mysql database using connection file in php
See lessWhat is hooks in WordPress?
A Hook is a generic term in WordPress that refers to places where you can add your own code or change what WordPress is doing. Two types of hooks exist in WordPress: actions and filters.
A Hook is a generic term in WordPress that refers to places where you can add your own code or change what WordPress is doing.
See lessTwo types of hooks exist in WordPress: actions and filters.
validation postal code global
Use this regex / [A-Za-z0-9]+ /g
Use this regex / [A-Za-z0-9]+ /g
See lessi have text area field on which there is front …
Because text area see "Enter" key as a character also like "white space"
Because text area see “Enter” key as a character also like “white space”
See lessHow to get data from Ajax without success function?
You can't get response without success function but if you want to get data out of success function then you can use "Async" and global variable of javascript, Like this e.g :- var data = ""; ajax({ type:"", url:"", data:{}, async:false, success:function(res){ data = res; } });
You can’t get response without success function but if you want to get data out of success function then you can use “Async” and
global variable of javascript, Like this
e.g :-
See lessvar data = “”;
ajax({
type:””,
url:””,
data:{},
async:false,
success:function(res){
data = res;
}
});
How to calculate number of charters in the string, in …
You can simply use "strlen()" function of php to count number of chracter in string like this $string = "hello"; echo length($string) Output :- 5
You can simply use “strlen()” function of php to count number of chracter in string like this
See less$string = “hello”;
echo length($string)
Output :- 5
‘ImageFile’ object has no attribute ‘_committed’ error coming while using …
I find out the solution to fix this error is to place url or name behind img = get_thumbnail(my_file, '100x100', crop='center', quality=99).url Or img = get_thumbnail(my_file, '100x100', crop='center', quality=99).name
I find out the solution to fix this error is to place url or name behind
img = get_thumbnail(my_file, ‘100×100′, crop=’center’, quality=99).url
Or
img = get_thumbnail(my_file, ‘100×100′, crop=’center’, quality=99).name
See lessImageFiled is not updating when using QuerySet.update() function in Django?
I find out the solution to fix this error is to place url or name behind img = get_thumbnail(my_file, '100x100', crop='center', quality=99).url Or img = get_thumbnail(my_file, '100x100', crop='center', quality=99).name
I find out the solution to fix this error is to place url or name behind
img = get_thumbnail(my_file, ‘100×100′, crop=’center’, quality=99).url
Or
img = get_thumbnail(my_file, ‘100×100′, crop=’center’, quality=99).name
See lessHow to add minutes or hours to current datetime in …
from datetime import datetime, timedelta #Add hours to current dateetime datetime.now() + timedelta(hours=9) #Add minutes to current dateetime datetime.now() + timedelta(minutes=9)
from datetime import datetime, timedelta
#Add hours to current dateetime
datetime.now() + timedelta(hours=9)
#Add minutes to current dateetime
datetime.now() + timedelta(minutes=9)
See lessHow to calculate hours between two time strings
You can calculate hours using datetime and timedelta of datetime library of python. from datetime import datetime s1 = '10:33:26' s2 = '11:15:49' # for example FMT = '%H:%M:%S' tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT) In condition of time 12pm you can add below code in aboveRead more
You can calculate hours using datetime and timedelta of datetime library of python.
from datetime import datetime
s1 = ’10:33:26′
s2 = ’11:15:49′ # for example
FMT = ‘%H:%M:%S’
tdelta = datetime.strptime(s2, FMT) – datetime.strptime(s1, FMT)
In condition of time 12pm you can add below code in above code also : –
if tdelta.days < 0:
See lesstdelta = timedelta(days=0,
seconds=tdelta.seconds, microseconds=tdelta.microseconds)