The POST request for images does not get validated on my form, when i created a new form it worked fine and was able to save the images. but going back to same old form i tried making the body part similar to the old one but got the same message even tried to check the console for form.errors but couldn't find anything.Still trying to figure out what is it that's missing in input as per the console log ValidationError[This field is required].
console log for the POST Request made
View.py function used to validate and get post
models.py
form.py ModelForm
main layout html template
<!DOCTYPE html>
<html lang="en">
<head>
<!-- <title>Encyclopedia</title> -->
<title>{% block title %} {% endblock %}</title>
<link rel="stylesheet" href="..\..\static\mywikiapp\style.css">
{% block head %}
{% endblock %}
</head>
<body>
<div class="main">
<div class="leftpart">
<h2 id="leftheading">Wiki</h2>
<div class="search_container_confinement">
<form>
<div class="searchcontainer">
<input type="text" name="q" placeholder="Search Encyclopedia">
</div>
</form>
</div>
<div class="listcontainer">
<ul id="left_col_li">
<li>Home</li>
<li>Create New Page</li>
<li>Upload Images</li>
<li>Random Page</li>
</ul>
</div>
<div class="navbar">
<div>
{% block navbar %}{% endblock %}
</div>
</div>
</div>
<div class="rightpart">
<!-- <h1>All Pages</h1>
<div>
<ul>
<li>Css</li>
<li>Django</li>
<li>Git</li>
<li>HTML</li>
<li>Python</li>
</ul>
</div> -->
{% block body %}{% endblock %}
</div>
</div>
</body>
</html>
The Template in which validation fails.The variable formimg is the modelform for imagefield passed rendered to the html to select mutiple images
{% extends "mywikiapp/layout.html" %}
{% block title %}
Add Images
{% endblock %}
{% block head %}
<style>
.rightpart{
/* border:black solid; */
display:grid;
place-items: center;
}
</style>
{% endblock head %}
{% block body %}
<div class="btn">
<form class="add_images" enctype="mutipart/form-data" name="Upload_Images" action="{% url 'mywikiapp:save_image' %}" method="POST">
<!-- <form class="add_images" enctype="multipart/form-data" name="Upload_Images" action="{% url 'mywikiapp:save_image' %}" method="POST"> -->
<div>
<input type="submit" value="Save Images">
{% csrf_token %}
{{formimg.management_form}}
{% for i in formimg %}
{{i}}
{% endfor %}
</div>
<!-- {{formimg}} -->
<!-- <input required name="images" type="file" multiple="multiple" name="images"> -->
</form>
</div>
{% endblock %}
The html form in which validation works without any errors.
<!DOCTYPE html>
<html>
<head>
<title>Upload images</title>
<style>
body {
height:100vh;
width:100vh;
}
.rightpart{
/* border:black solid; */
display:grid;
place-items: center;
height:100%;
width:100%;
}
</style>
</head>
<body>
<div class="rightpart">
<div class="btn">
<form class="add_images" enctype="multipart/form-data" name="Upload_Images" action="{% url 'mywikiapp:save_image' %}" method="POST">
<div>
<input type="submit" value="Save Images">
{% csrf_token %}
{{formimg.management_form}}
{% for i in formimg %}
{{i}}
{% endfor %}
</div>
<!-- {{formimg}} -->
<!-- <input required name="images" type="file" multiple="multiple" name="images"> -->
</form>
</div>
</div>
</body>
</html>
I am trying to extend my templates .
base_layout.html:
{% load static from staticfiles %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Articles</title>
<link rel = "stylesheet" href = "{% static 'styles.css' %}">
</head>
<body>
<div class="wrapper">
{% block content %}
{% endblock %}
</div>
</body>
</html>
article_list.html:
{% extends 'base_layout.html' %}
{% block content %}
<h1>Article List</h1>
<div class = "articles">
{% for article in articles %}
<div class = "article">
<h2>{{ article.title}}</h2>
<p>{{ article.body }}</p>
<p>{{ article.date }}</p>
</div>
{% endfor %}
</div>
{% endblock %}
When i run this i am getting the error like this:
django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 11: 'blockcontent'. Did you forget to register or load this tag?
What mistake am i doing?
I am making a child template in jinja which extends the parent template.In child template I am passing a variable to run a for loop in jinja template,but that part of for loop is not accessible inside the html page in chrome.
parent template-In parent template there is only navbar.
<html>
<head>
<link rel="stylesheet" href="static\navbar.css?v=1.1">
{% block head %}{% endblock %}
</head>
<body>
<nav class="menu">
<ul>
<li>Website</li>
<form action="{{ url_for('search') }}" class="search-form" target="_blank" method="POST">
<input type="text" name="text" placeholder="Search here..">
<button>Search</button>
</form>
{% if name %}
<li>{{name}}</li>
<li>Logout</li>
{% else %}
<li>Login & SignUp</li>
{% endif %}
<li><i class="fas fa-cart-plus"></i></li>
</ul>
</nav>
{% block content %}
{% endblock %}
</body>
</html>
Child template -In child template i am passing a variable for the for loop,but it is not working.
{% extends 'navbar.html' %}
{% block head %}
<title>Flipkart</title>
<!--new version 2nd way to update css-->
<link rel="stylesheet" href="static\gallary.css">
<script src="https://kit.fontawesome.com/04c28a3c9a.js"></script>
{% endblock %}
{% block content %}
<div class="description">
Shopping Website
</div>
<hr>
<h2>Deals Of The Day</h2>
<hr>
{% for i in ids %} -----this part is not coming in browser.----
<h1>sasadLink {{i}}</h1>
{% endfor %}
{% endblock %}
Flask file -- products function
#app.route('/products')
def products():
cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
cursor.execute('SELECT id FROM shoes')
shoes_ids=cursor.fetchall()
print(shoes_ids)
ids = []
for shoes_id in shoes_ids:
ids.append(shoes_id['id'])
return render_template('navbar.html',ids=ids) ---here i am passing the
variable to the child
template-----
I want the for loop content to be displayed on the browser.
I'm using djangoCMS to add CMS functionality in my website templates but the placeholders i have placed on the placed are not showing up, i have defined my CMS_TEMPLATES IN MY settings.py and put the {% load cms_tags sekizai_tags sorl_thumbnail %} on my base.html and also added {% load cms_tags sekizai_tags %} on my other templates that expand the base.html, but when i log into djangoCMS admin and visit my pages i find no placeholders in my structure view. what could be the problem here?
settings.py
CMS_TEMPLATES = [
('index.html','Home'),
('solutions.html','solutions'),
('commercial.html','Commercial Solar Solution'),
('residential.html','Residential Solar Solution'),
('on-grid.html','On grid solutions'),
('off-grid.html','Off Grid solutions'),
('water-heating.html','Solar Water Heating'),
('solar-water-pumping.html','Solar water pumping'),
('hybrid-grid.html','Hybrid Solutions'),
('outdoor-lighting.html','Outdoor Lighting'),
('contacts.html','Contacts'),
('terms-of-use.html','Terms of use'),
]
base.html
<!DOCTYPE html>
{% load static %}
{% load cms_tags menu_tags sekizai_tags %}
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %}</title>
{% render_block "css" %}
</head>
<body>{% cms_toolbar %}
<ul> {% show_menu 0 0 100 100 %} </ul>
<div id="mySidenav" class="sidenav">
<div class="div">
<img src="{% static 'administration/css/images/icons/logo.png' %}" alt="" class="img-responsive">
</div>
<ul class="navlist">
×
<li>Home</li>
<li>About us</li>
<li>Blog</li>
<li>Projects</li>
<li>Downloads</li>
</ul>
</div>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
<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="#">
<img src="{% static 'administration/css/images/icons/logo.png' %}" alt="" class="img-responsive">
</a>
</div>
</nav>
{% block content %}
{% endblock %}
{% render_block "js" %}
</body>
</html>
solutions.html
{% extends 'base.html' %}
{% block title %} Commercial pv solar heating solutions {%
endblock %}
{% load static %}
{% load cms_tags %}
{% block content %}
<div class="water__heating--section">
<div class="row">
<div class="col-lg-6 solutions__content--image" id="commercial__banner--image">
<h4 class="small__title">support and Evaluation</h4>
<div class="small__content small__content--default">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima soluta nesciunt consequuntur esse consectetur
</div>
</div>
<div class="col-lg-6 solutions__content--box">
<h1 class="heavy__title"> We Can Help your business <span class="emphasis">go solar</span> </h1>
<div class="small__content ribbon__content--default">
{% placeholder "commercial section one" %}
</div>
</div>
</div>
</div>
{% endblock %}
Inside your child template (which extends base template) there is should be something like this:
{% extends "base.html" %}
{% load cms_tags %}
{% block title %}{% page_attribute "page_title" %}{% endblock title %}
{% block content %}
<div>
{% placeholder "feature" %}
</div>
<div>
{% placeholder "content" %}
</div>
<div>
{% placeholder "splashbox" %}
</div>
{% endblock content %}
And base template should looks like this:
{% load cms_tags menu_tags sekizai_tags %}
<!doctype html>
<html>
<head>
<title>{% block title %}This is my new project home page{% endblock title %}</title>
</head>
<body>
{% cms_toolbar %}
<div class="container">
<ul class="nav">
{% show_menu 0 100 100 100 %}
</ul>
{% block content %}{% endblock content %}
</div>
</body>
</html>
I'm using django-pygments and am trying to us it like so (base.html)
<!DOCTYPE html>
{% load pygmentify %}
<head>
<link rel="stylesheet" media="screen" href="{% static 'django_pygments/css/pygments_default.css' %}" type="text/css">
</head>
<div class="row">
<div id="mainbody" class="small-12 large-8 large-offset-2 columns">
<body>
{% pygment %}
{% block content %}
{% endblock %}
{% endpygment %}
</body>
</div>
<div id="sidebar" class="small-12 large-2 columns">
</div>
<div class="small-12 large-8 large-offset-2 columns">
{% block comments %}
{% endblock %}
</div>
<div class="small-12 large-2 columns">
</div>
</div>
Then I'm passing {{ post.content|safe }} into block content. The pigmented code comes out as such:
I've tried changing the <ol> tags in the source code to <ul> but obviously that wasn't the issue. I also turned passed linenos=False and True but that only made it more weird as the line numbers aren't lined put correctly.
Anyone know what I might be doing wrong?
Apparently there was a problem with my css style sheet. I tried changing it and now it looks normal.