<div class="modal left fade" id="sidebar_left" tabindex="1" role="dialog" aria-labelledby="sidebar_left">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close go-left" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><i class="close icon-angle-left"></i></span></button>
<h4 class="modal-title go-text-right" id="sidebar_left"><i class="icon_set_1_icon-65 go-right"></i> Settings</h4>
</div>
<ul class="nav navbar-nav navbar-side navbar-right sidebar go-left">
<li id="li_myaccount">
<i class="icon_set_1_icon-70 go-right"></i> My Account <b class="lightcaret mt-2 go-left"></b>
<ul class="dropdown-menu">
<li><a class="go-text-right" href="a.html"> Login</a></li>
<li><a class="go-text-right" href="b.html"> Sign Up</a></li>
</ul>
</li>
<div class="header-brdr pull-left hidden-xs hidden-md go-left"></div>
<li class="dropdown">
<a class="dropdown-toggle go-text-right" data-toggle="dropdown" href="#">
<strong><i class="icon-money-2 go-right"></i>
USD </strong>
</a>
<ul class="dropdown-menu wow fadeIn">
I am trying to click the a.html but every time I got an ElementNotVisibleException
I am using the following line to do the job. Any suggestions ..
elem=driver.find_element_by_id('li_myaccount').click()
Related
The HTML is located below, If the span value is less than 20%, then I want to remove the span child up until the <div class="action"> parent only.
So for example:
<div class="item">
<div class="info">
<div class="action">
<div class="content">
<span class="content-name"> 5% </span>
</div>
</div>
</div>
</div>
From the above HTML, these code should only be removed:
<div class="action">
<div class="content">
<span class="content-name"> 5% </span>
</div>
</div>
So what should left is:
<div class="item">
<div class="info">
</div>
</div>
This is my current python code:
items = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.XPATH, "//span[#class='content-name']")))
for item in items:
percentage_text = re.findall("\d+", item.text)[0]
if int(percentage_text) <= 20:
driver.execute_script("arguments[0].remove();", item)
But it only removes the span class and not its parent.
Here is the full HTML, I think it needs javascript to remove elements but I am very new on javascript I researched for more than 2 hours and I still can't find solutions. Thank you very much.
<div class="item">
<div class="info">
<div class="action">
<div class="content">
<span class="content-name"> 5% </span>
</div>
</div>
</div>
</div>
<div class="item">
<div class="info">
<div class="action">
<div class="content">
<span class="content-name"> 95% </span>
</div>
</div>
</div>
</div>
<div class="item">
<div class="info">
<div class="action">
<div class="content">
<span class="content-name"> 32% </span>
</div>
</div>
</div>
</div>
<div class="item">
<div class="info">
<div class="action">
<div class="content">
<span class="content-name"> 15% </span>
</div>
</div>
</div>
</div>
get to the parent of the parent:
driver.execute_script("arguments[0].parentElement.parentElement.remove();", item)
<li class="mod-tile">
<ul class="gallery-hidden gallery">
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/1982/1982-1579465585-271404739.png" data-sub-html="Stracker's Loader " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/1982/1982-1579465585-271404739.png" />
</ul>
<div data-mod-id="1982" data-game-id="2531" class="mod-tile-left ">
<div class="expandtile">
<ul class="btnexpand btnoverlay inline-flex">
<div class="padding"></div>
<svg title="" class="icon-plus"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-plus"></use></svg> <li>
<ul>
<li><a class="mod-view" href="index.html">View mod page</a></li>
<li><a class="mod-gallery" href="index.html">View image gallery</a></li>
</ul>
</li>
</ul>
</div>
<a class="mod-image" href="index.html">
<figure class="image_figure">
<img class="back" src="https://www.nexusmods.com/assets/images/default/noimage.svg" width="600" height="338">
<div class="fore_div_mods">
<img class="fore" onerror="imgError(this,'https://www.nexusmods.com/assets/images/default/noimage.svg')" loading="lazy" src="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/1982/1982-1579465585-271404739.png" alt="Stracker's Loader" title="Stracker's Loader">
</div>
</figure>
</a>
<div class="tile-desc motm-tile">
<div class="fadeoff"></div>
<div class="tile-content">
<h3>Stracker's Loader</h3>
<div class="meta clearfix">
<div class="category">
Utilities
</div>
<time class="date" datetime="2020-01-19 20:26"> <span class="label">Uploaded: </span>
19 Jan 2020 </time>
<div class="date"><span class="label">Last Update:</span> 04 Dec 2020</div>
<div class="realauthor"><span class="label">Author: </span> Stracker</div>
<div class="author"><span class="label">Uploader: </span> Stracker</div>
</div>
<p class="desc">
Restores full nativePC functionality. </p>
</div>
</div>
<div class="tile-data">
<ul class="clearfix">
<li class="sizecount inline-flex">
<svg title="" class="icon icon-filesize"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-filesize"></use></svg> <span class="flex-label">
703KB </span>
</li>
<li class="endorsecount inline-flex">
<svg title="" class="icon icon-endorse"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-endorse"></use></svg> <span class="flex-label">26.0k</span>
</li>
<li class="downloadcount inline-flex">
<svg title="" class="icon icon-downloads"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-downloads"></use></svg> <span class="flex-label"> -- </span>
</li>
</ul>
</div>
</div>
<div class="mod-tile-right">
<div class="tile-desc">
<div class="fadeoff"></div>
<div class="tile-content">
<h3>Stracker's Loader</h3>
<div class="meta clearfix">
<div class="category">
Utilities
</div>
<time class="date" datetime="2020-01-19 20:26"> <span class="label">Uploaded: </span>
19 Jan 2020 </time>
<div class="date"><span class="label">Last Update:</span> 04 Dec 2020</div>
<div class="author"><span class="label">Author: </span>Stracker</div>
</div>
<p class="desc">
Restores full nativePC functionality. </p>
</div>
</div>
</div>
</li>
<li class="mod-tile">
<ul class="gallery-hidden gallery">
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/112/112-1579010242-745113274.png" data-sub-html="Souvenir's Light Pillar " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/112/112-1579010242-745113274.png" />
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/112/112-1579010135-1239485031.png" data-sub-html="Souvenir's Light Pillar " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/112/112-1579010135-1239485031.png" />
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/112/112-1579010181-399571475.png" data-sub-html="Souvenir's Light Pillar " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/112/112-1579010181-399571475.png" />
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/112/112-1579259504-344088346.png" data-sub-html="Souvenir's Light Pillar " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/112/112-1579259504-344088346.png" />
</ul>
<div data-mod-id="112" data-game-id="2531" class="mod-tile-left ">
<div class="expandtile">
<ul class="btnexpand btnoverlay inline-flex">
<div class="padding"></div>
<svg title="" class="icon-plus"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-plus"></use></svg> <li>
<ul>
<li><a class="mod-view" href="index.html">View mod page</a></li>
<li><a class="mod-gallery" href="index.html">View image gallery</a></li>
</ul>
</li>
</ul>
</div>
<a class="mod-image" href="index.html">
<figure class="image_figure">
<img class="back" src="https://www.nexusmods.com/assets/images/default/noimage.svg" width="600" height="338">
<div class="fore_div_mods">
<img class="fore" onerror="imgError(this,'https://www.nexusmods.com/assets/images/default/noimage.svg')" loading="lazy" src="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/112/112-1579010242-745113274.png" alt="Souvenir's Light Pillar" title="Souvenir's Light Pillar">
</div>
</figure>
</a>
<div class="tile-desc motm-tile">
<div class="fadeoff"></div>
<div class="tile-content">
<h3>Souvenir's Light Pillar</h3>
<div class="meta clearfix">
<div class="category">
Visuals and Graphics
</div>
<time class="date" datetime="2018-09-03 19:58"> <span class="label">Uploaded: </span>
03 Sep 2018 </time>
<div class="date"><span class="label">Last Update:</span> 17 Jan 2020</div>
<div class="realauthor"><span class="label">Author: </span> 2hh8899</div>
<div class="author"><span class="label">Uploader: </span> 2hh8899</div>
</div>
<p class="desc">
It lights up the souvenirs for making them easier to find.유실물을 찾기 쉽게 하기 위해 빛기둥을 박아넣었습니다. </p>
</div>
</div>
<div class="tile-data">
<ul class="clearfix">
<li class="sizecount inline-flex">
<svg title="" class="icon icon-filesize"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-filesize"></use></svg> <span class="flex-label">
59KB </span>
</li>
<li class="endorsecount inline-flex">
<svg title="" class="icon icon-endorse"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-endorse"></use></svg> <span class="flex-label">22.7k</span>
</li>
<li class="downloadcount inline-flex">
<svg title="" class="icon icon-downloads"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-downloads"></use></svg> <span class="flex-label"> -- </span>
</li>
</ul>
</div>
</div>
<div class="mod-tile-right">
<div class="tile-desc">
<div class="fadeoff"></div>
<div class="tile-content">
<h3>Souvenir's Light Pillar</h3>
<div class="meta clearfix">
<div class="category">
Visuals and Graphics
</div>
<time class="date" datetime="2018-09-03 19:58"> <span class="label">Uploaded: </span>
03 Sep 2018 </time>
<div class="date"><span class="label">Last Update:</span> 17 Jan 2020</div>
<div class="author"><span class="label">Author: </span>2hh8899</div>
</div>
<p class="desc">
It lights up the souvenirs for making them easier to find.유실물을 찾기 쉽게 하기 위해 빛기둥을 박아넣었습니다. </p>
</div>
</div>
</div>
</li>
<li class="mod-tile">
<ul class="gallery-hidden gallery">
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/43/43-1534824818-145235267.png" data-sub-html="MHW Transmog " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/43/43-1534824818-145235267.png" />
<li class="thumb" data-src="https://staticdelivery.nexusmods.com/mods/2531/images/43/43-1534825195-804021906.png" data-sub-html="MHW Transmog " data-exthumbimage="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/43/43-1534825195-804021906.png" />
</ul>
<div data-mod-id="43" data-game-id="2531" class="mod-tile-left ">
<div class="expandtile">
<ul class="btnexpand btnoverlay inline-flex">
<div class="padding"></div>
<svg title="" class="icon-plus"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-plus"></use></svg> <li>
<ul>
<li><a class="mod-view" href="index.html">View mod page</a></li>
<li><a class="mod-gallery" href="index.html">View image gallery</a></li>
</ul>
</li>
</ul>
</div>
<a class="mod-image" href="index.html">
<figure class="image_figure">
<img class="back" src="https://www.nexusmods.com/assets/images/default/noimage.svg" width="600" height="338">
<div class="fore_div_mods">
<img class="fore" onerror="imgError(this,'https://www.nexusmods.com/assets/images/default/noimage.svg')" loading="lazy" src="https://staticdelivery.nexusmods.com/mods/2531/images/thumbnails/43/43-1534824818-145235267.png" alt="MHW Transmog" title="MHW Transmog">
</div>
</figure>
</a>
<div class="tile-desc motm-tile">
<div class="fadeoff"></div>
<div class="tile-content">
<h3>MHW Transmog</h3>
<div class="meta clearfix">
<div class="category">
Utilities
</div>
<time class="date" datetime="2018-08-21 05:37"> <span class="label">Uploaded: </span>
21 Aug 2018 </time>
<div class="date"><span class="label">Last Update:</span> 04 Dec 2020</div>
<div class="realauthor"><span class="label">Author: </span> Approved</div>
<div class="author"><span class="label">Uploader: </span> FineNerds</div>
</div>
<p class="desc">
A mod that allows you to hot swap your appearance with any armor of your choice. Visible to other players!As with any mod for games that don't support mods. This is USE AT YOUR OWN RISK. </p>
</div>
</div>
<div class="tile-data">
<ul class="clearfix">
<li class="sizecount inline-flex">
<svg title="" class="icon icon-filesize"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-filesize"></use></svg> <span class="flex-label">
260KB </span>
</li>
<li class="endorsecount inline-flex">
<svg title="" class="icon icon-endorse"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-endorse"></use></svg> <span class="flex-label">12.2k</span>
</li>
<li class="downloadcount inline-flex">
<svg title="" class="icon icon-downloads"><use xlink:href="https://www.nexusmods.com/assets/images/icons/icons.svg#icon-downloads"></use></svg> <span class="flex-label"> -- </span>
</li>
</ul>
</div>
</div>
<div class="mod-tile-right">
<div class="tile-desc">
<div class="fadeoff"></div>
<div class="tile-content">
<h3>MHW Transmog</h3>
<div class="meta clearfix">
<div class="category">
Utilities
</div>
<time class="date" datetime="2018-08-21 05:37"> <span class="label">Uploaded: </span>
21 Aug 2018 </time>
<div class="date"><span class="label">Last Update:</span> 04 Dec 2020</div>
<div class="author"><span class="label">Author: </span>FineNerds</div>
</div>
<p class="desc">
A mod that allows you to hot swap your appearance with any armor of your choice. Visible to other players!As with any mod for games that don't support mods. This is USE AT YOUR OWN RISK. </p>
</div>
</div>
</div>
</li>
So I want selenium to open the first link from that has the class "mod-tile" then it will do a script that I have made, then I want it to open the next link that has the same class "mod-tile". Is there any way to specify this? (btw don't mind the description I just copied the first 3 mod tiles that appeared on the website)
You can get a list of elements with the find_elements_by_class_name() method.
Then iterate through the list of elements.
[UPDATED]
Following should click the fist link (//a) within the "mod-tile" elements
elements = driver.find_elements_by_class_name("mod-tile")
print("mod-title count {}".format(len(elements)))
for element in range(len(elements)):
elements[element].find_element_by_xpath("//a").click()
I am creating the dashboard view for my CRM. However while displaying the card view, only two of the three card views are visible. Can anyone help me regarding this? Is this a code formatting issue?
I am adding an image of the dashboard for my CRM below as well as the code for the cards given below.
example.html:
{% extends 'base.html' %}
{% block content %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4 mt-4">
<h1 class="h3 mb-0 text-gray-800">Welcome to NexCRM</h1>
<i class="fas fa-download fa-sm text-white-50"></i> Generate Report
</div>
<!-- Main Content Here -->
<div class="row">
<!-- Company Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Companies</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">4,083</div>
</div>
<div class="col-auto">
<i class="fas fa-building fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Company Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Companies</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">4,083</div>
</div>
<div class="col-auto">
<i class="fas fa-building fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Contact Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-warning shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1">Contacts</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">18,002</div>
</div>
<div class="col-auto">
<i class="fas fa-comments fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Content Row -->
<div class="row">
<!-- Area Chart -->
<div class="col-xl-8 col-lg-7">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Earnings Overview</h6>
<div class="dropdown no-arrow">
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
<div class="dropdown-header">Dropdown Header:</div>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
</div>
<!-- Card Body -->
<div class="card-body">
<div class="chart-area">
<canvas id="myAreaChart"></canvas>
</div>
</div>
</div>
</div>
<!-- Pie Chart -->
<div class="col-xl-4 col-lg-5">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Revenue Sources</h6>
<div class="dropdown no-arrow">
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
<div class="dropdown-header">Dropdown Header:</div>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
</div>
<!-- Card Body -->
<div class="card-body">
<div class="chart-pie pt-4 pb-2">
<canvas id="myPieChart"></canvas>
</div>
<div class="mt-4 text-center small">
<span class="mr-2">
<i class="fas fa-circle text-primary"></i> Direct
</span>
<span class="mr-2">
<i class="fas fa-circle text-success"></i> Social
</span>
<span class="mr-2">
<i class="fas fa-circle text-info"></i> Referral
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
{% endblock content %}
I'm working with bootstrap3 and django. I want to update my navbar to add a dropdown list of links in my navbar on the right . My bootstrap code:
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Bob and Company</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Current Properties</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Village, Texas</a>
<a class="dropdown-item" href="#">Lake, Washington</a>
</div>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
so far I'm getting the screenshot. How can i fix this to get this working?
edit:
thank you, that's much better . Can the links be made verical instead of horizontal. Please see screenshot:
Is it working if you do it like this?
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">1</a>
<a class="dropdown-item" href="#">2</a>
<a class="dropdown-item" href="#">3</a>
</div>
</li>
I'm new to Jinja and this is my first post here on Stack Overflow.
I'm trying to loop through a gallery of images handled by bootstrap carousel/modal. I was able to let it work; <img> and <div> are rendered correctly, however I can't loop through the active element. Searching the web, I found that macros can help achieve it but I'm not familiar with using them. Here's the code I'm working on:
<div class="modal fade" id="myModalGal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<!-- Wrapper for slides -->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
{% for content in porte %}
{% if content.gal_porte %}
<img src="{{content.gal_porte}}" class="img-responsive" alt="test">
<div class="carousel-caption"></div>
</div>
<div class="item">
{% elif content.gal_porte %} <img src="{{content.gal_porte}}" class="img-responsive" alt="test1">
<div class="carousel-caption"></div>
{% endif %}
{% endfor %}
</div>
<!-- Controls -->
<a class="home-icon left" href="#carousel-example-generic" role="button" data-slide="prev"> <i class="fa fa-arrow-left"></i>
</a> <a class="home-icon right" href="#carousel-example-generic" role="button" data-slide="next"> <i class="fa fa-arrow-right" style="text-align: right;"></i>
</a>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Chiudi</button>
</div>
</div>
</div>
Jinja for loops have counters so you can check if you are on the first iteration of the loop and make that one the active slide.
Something like this:
<div class="carousel-inner">
{% for content in porte %}
<div class="item{% if loop.index == 1 %} active{% endif %}">
<img src="{{content.gal_porte}}" class="img-responsive" alt="test1">
<div class="carousel-caption"></div>
</div>
{% endfor %}
<!-- Controls -->
<a class="home-icon left" href="#carousel-example-generic" role="button" data-slide="prev">
<i class="fa fa-arrow-left"></i>
</a>
<a class="home-icon right" href="#carousel-example-generic" role="button" data-slide="next">
<i class="fa fa-arrow-right" style="text-align: right;"></i>
</a>
</div>