How to get first element of the list in Django template

python html django 6 years, 2 months ago
<h3> Print all elements</h3> <div> {% for item in my_list %} {{item}} {% endfor %} </div> <h3> Access first element of list</h3> {{ my_list.0 }} <h3> Also you can use first</h3> {{ my_list.first}}
10537
Posted By
work with react without node installation in
//Basic way
<!DOCTYPE html>
<html>
javascript react js html
harika
Render custom components without node install
<!DOCTYPE html>
<html>
  <head>
react js html
harika
Search options in bootstrap select , search s
<script src="https://ajax.googleapis.com
<script src="https://maxcdn.bootstrapcdn
<link href="https://maxcdn.bootstrapcdn.
html bootstrap
kishore_kumar
How to iterate json object in angular js
<html>
    <body>
        <table data-ng-repeat="(key, val
html json angular js
harika
How to get key value pairs of json object in
<html>
    <body>
        <table data-ng-repeat="(key, val
html json angular js
harika
template filters for slice string and print n
<!-- will give first 100 characters from
{{ my_string | slice:"100 "}}

html python django
kishore_kumar
for loop counter in python Django template
{% for my_object in my_object_list %}
    {{ forloop.counter }} {# starting in
    {{ forloop.counter0 }} {# starting i
python django html
kishore_kumar
Load html inside webview using react native
// html.js
module.exports = function() { return `
<html>
html react-native webview javascript js
harika
Load native javascript inside webview in reac
import React, { Component } from 'react'
import {View,  WebView} from 'react-nati

html react-native webview javascript js
harika
Python Script to create AWS beanstalk
#!/usr/bin/python
  
import boto
python aws beanstalk
sandeep sandeep
List all files and folders using python os mo
import os

def list_files_folders(path):
python python-os
kishore_kumar
Get current environment variables in python
import os
env = os.environ

python python-os
kishore_kumar
Get os details using python os
import os
print os.uname()
# Don't use os.system('uname -a'), its j
python python-os
kishore_kumar
Get stats ( lines, words, char count ) of fil
def file_stats(path):
    f = open(path, 'r')
    lines = f.readlines()
python
kishore_kumar
Use map function in python
def get_double(num):
    return num * 2

python
kishore_kumar
Python sample codes for beginners
print "Welcome to python"
python
gaya38 gaya38
Python program for even number checking
a=input("Enter a value:")
if (a%2==0):
    print "The given number is even numb
python
gaya38 gaya38
Python program for prime number check
a=input("Enter a value:")
k=0
b=(a/2)+1
python
gaya38 gaya38
Pass command line arguments in python
import sys
x=len(sys.argv)
a=[]
python
gaya38 gaya38
Python program for the largest number in an a
a = [1,43,98,5]#Dummy data
for l in range(len(a)-1):
        if (a[l]>a[l+1]):
python
gaya38 gaya38