Django not displaying block content - python

I'm fairly new to Django and I'm trying to set up my project so that there's a homepage and then off of the homepage a bunch of different links. The problem is whenever I click one of my other tabs (products, login, contact) etc. it just reloads the homepages block content despite the fact that I told it to load something else. so when I click the links it does show that I'm on a new webpage (ill see whatever my BASE_DIR is with '/courses/products/' for example in the url bar but its always the same website which is displaying views.homepage.
Here's my courses/urls.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'$', views.homepage, name='homepage'),
url(r'contact/$', views.contact, name='contact'),
url(r'login/$', views.login, name='login'),
url(r'products/$', views.products, name='products'),
url(r'register/$', views.register, name='register'),
]
here's my layout.html which is in the template folder:
{% load static from staticfiles %}
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>HealthSmart</title>
<link href="{% static 'images/photo.jpg' %}" rel='icon' type='image/x-icon' />
<link rel="stylesheet" href="{% static 'css/normalize.css' %}" />
<link href="http://fonts.googleapis.com/css?family=Lora|Open+Sans:400italic,700italic,400,700,300,800" rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Varela+Round|' rel='stylesheet' type='text/css' />
<link rel="stylesheet" href="{% static 'css/pavle.css' %}" />
<link rel="stylesheet" href="{% static 'css/responsive.css' %}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<header>
<a href="{% url 'courses:homepage' %}" id="logo">
<h1>{% block title %} {% endblock %}</h1>
</a>
<nav>
<ul>
<li>Home</li>
<li>Products</li>
<li>Contact</li>
<li>Login</li>
</ul>
</nav>
</header>
{% block content %} {% endblock %}
<div id="footer">
<footer>
<img src="{% static 'images/briggs.png' %}" alt="BriggsLogo" class="social-icon">
<p>©2015 HealthSmart Prototypes.</p>
</footer>
</div>
</body>
</html>
and finally, here's my views.py:
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from .models import Owner, Device, Page
# Create your views here.
def homepage(request):
home = Page.objects.all()
return render(request, 'courses/homepage.html', {'homepage': homepage})
def contact(request, contact_pk):
contact = get_object_or_404(Page, pk=contact_pk)
return render(request, 'courses/contact.html', {'contact': contact})
def login(request, login_pk):
login = get_object_or_404(Page, pk=login_pk)
return render(request, 'courses/login.html', {'login': login})
def products(request, products_pk):
product = get_object_or_404(Page, pk=products_pk)
return render(request, 'courses/products.html', {'product': product})
def register(request, register_pk):
register = get_object_or_404(Page, pk=register_pk)
return render(request, 'courses/register.html', {'register': register})
Also I'll include the homepage.html and products.html just in case:
homepage.html:
{% extends "layout.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block content %}
<article>
<div class="main_body">
<div class="hep">
<section class="product">
<h3 id="purify">Purifying your life</h3>
<p id="smartprod">Meet our smart products today.</p>
</section>
</div>
</div>
<div id="information">
<h3>Change your Home Environment with the new Briggs HealthSmart Air Purifier and Humidifier</h3>
<p>Run multiple devices at the same time all on your smartphone!</p>
</div>
<div id="getStarted">
<p>If you have an account Login, or you can get started today and Register!</p>
</div>
</article>
{% endblock %}
products.html:
{% extends "layout.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block content %}
<article>
<div id="wrapper">
<section>
<ul id="gallery">
<li>
<a href="{% static 'images/air purifier 03272015.png' %}">
<img src="{% static 'images/air purifier 03272015.png' %}" alt="" />
<p>The Briggs Air Purifier.</p>
</a>
</li>
<li>
<a href="{% static 'images/base 03272015.png' %}">
<img src="{% static 'images/base 03272015.png' %}" alt="" />
<p>The Briggs Base.</p>
</a>
</li>
<li>
<a href="{% static 'images/humidifier 03272015.png' %}">
<img src="{% static 'images/humidifier 03272015.png' %}" alt="" />
<p>The Briggs Air Humidifier.</p>
</a>
</li>
<li>
<a href="{% static 'images/water tank 03272015.png' %}">
<img src="{% static 'images/water tank 03272015.png' %}" alt="" />
<p>The Briggs Water Tank.</p>
</a>
</li>
</ul>
</section>
</div>
</article>
{% endblock %}

use
url(r'^$', views.homepage, name='homepage'),
for your homepage, can you also show us how you extends your "layout.html" ?
For your contact problem you can add the pk in your url pattern
url(r'contact/(?P<contact_pk>\d+)/$', views.contact, name='contact'),

Related

Django templates error; Reverse for 'search' not found. 'search' is not a valid view function or pattern name

my layout:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="{% static 'encyclopedia/styles.css' %}" rel="stylesheet">
</head>
<body>
<div class="row">
<div class="sidebar col-lg-2 col-md-3">
<h2>Wiki</h2>
<form action = "{% url 'search' %}" method="GET">
<input class="search" type="text" name="q" placeholder="Search Encyclopedia">
</form>
<div>
Home
</div>
<div>
Create New Page
</div>
<div>
<a>Random Page </a>
</div>
{% block nav %}
{% endblock %}
</div>
<div class="main col-lg-10 col-md-9">
{% block body %}
{% endblock %}
</div>
</div>
</body>
</html>
my views.py:
def search(request):
result = set()
entries = util.list_entries()
if request.method == 'GET':
query = request.GET.get('q')
if query == '': #If it's nothing
query = 'NONE'
if query in entries:
return redirect(f'wiki/{query}')
else:
results = [entry for entry in entries if query.lower() in entry.lower()]
return render(request, "encyclopedia/index.html", {
"entries": results
})
return render(request, 'encyclopedia/search.html', {'results':result})
my urls:
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from . import views
app_name = 'encyclopedia'
urlpatterns = [
path("", views.index, name="index"),
path('newpage/', views.new_page, name = 'newpage'),
path('wiki/<str:title>', views.entry, name = 'entries'),
path('wiki/<str:title>/edit',views.edit, name = 'edit'),
path('search', views.search, name = 'search'),
path('wiki/<str:entry>', views.random_page, name = 'random'),
]
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
How do i make it work? it worked before but now it just stopped working. The name in the urls matches with the name of a bar
What i have to know about url method?
I also tried to write {% url 'random'%} for a random page but it seems not working at all
When i added this to a random search url stopped working and i do not know why
Versions:
Django 4.1.4, Python 3.10.5
You have declared app_name in your urls.py file that makes it compulsory to add app_name before calling a url in django. Call your urls like this...
href={% url 'app_name:url_name' %}
So your code will be like this...
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="{% static 'encyclopedia/styles.css' %}" rel="stylesheet">
</head>
<body>
<div class="row">
<div class="sidebar col-lg-2 col-md-3">
<h2>Wiki</h2>
<form action = "{% url 'encyclopedia:search' %}" method="GET">
<input class="search" type="text" name="q" placeholder="Search Encyclopedia">
</form>
<div>
Home
</div>
<div>
Create New Page
</div>
<div>
<a>Random Page </a>
</div>
{% block nav %}
{% endblock %}
</div>
<div class="main col-lg-10 col-md-9">
{% block body %}
{% endblock %}
</div>
</div>
</body>
</html>

Hi, I have a problem with a django app. I want do make personalized pages for users with this url: url/user/id. But something doesn't work

I'm quite new in the programming world and that's my firs real project. Usually I solve my problems just sitting and thinking till my brain burns. But this time I'm really stacked. Maybe is easy but I really didn't find solutions
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('profilo/<int:my_id>/', views.profilo, name='profilo')
]
views.py
def profilo(request, my_id):
users = User.objects.get(id=my_id)
contex = {
"user": users
}
return render(request, 'profilo/profilo.html', contex)
base.html
{% load static %}
<html>
<head>
<title>Django Boyz blog</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link href='//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{% static 'css/blog.css' %}">
</head>
<body>
<div class="page-header">
{% if user.is_authenticated %}
<span class="glyphicon glyphicon-plus"></span>
<p class="top-menu">Ciao {{ user.username }} <small>(Log out)</small></p>
<span class="glyphicon glyphicon-user"></span>
{% if user.is_superuser %}
<span class="glyphicon glyphicon-inbox"></span>
{% endif %}
{% else %}
<span class="glyphicon glyphicon-lock"></span>
{% endif %}
<h1>Django Boyz Blog</h1>
</div>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>
The error is this: NoReverseMatch at /
Reverse for 'profilo' with arguments '('',)' not found. 1 pattern(s) tried: ['profilo/(?P<my_id>[0-9]+)/$']
Thanks
In this line:
<span class="glyphicon glyphicon-user"></span>
The u should be small in User.id:
<span class="glyphicon glyphicon-user"></span>

Django form doesn't show available values

I'm quite new to Django...
So, I have a model. Notice the two foreign key fields (DeviceProfile model actually has data, but MISMStateSnapshot does not):
class MISMWorkflow(models.Model):
createdAt = models.DateTimeField(default=timezone.now)
currentSnapshot = models.ForeignKey('MISMStateSnapshot', null=True, blank=True, on_delete=models.SET_NULL)
device = models.ForeignKey(DeviceProfile, null=True, blank=True, on_delete=models.SET_NULL, related_name='workflows')
def get_absolute_url(self):
return reverse('{}:workflow_detail'.format(VIEW_NAMESPACE), args=(self.pk,))
And a CreateView:
class WorkflowCreateView(generic.CreateView):
model = MISMWorkflow
fields = '__all__'
template_name = 'mism_web/workflow_create_form.html'
def form_valid(self, form):
form.instance.device = DeviceProfile.objects.get(pk=self.kwargs.get('device_id'))
form.instance.createdAt = timezone.now()
return super(WorkflowCreateView, self).form_valid(form)
And the template:
{% extends 'mism_web/base.html' %}
{% load material_form %}
{% block content %}
<form action="" method="POST">{% csrf_token %}
<!--{{ form.as_p }}-->
{% form form=form %}{% endform %}
<input type="submit" name="_submit" class="btn" value="Save" />
</form>
{% endblock %}
urls:
url(r'^workflow/workflow_create/$', workflow.WorkflowCreateView.as_view(), name='workflow_create_new'),
This is what I see when I go to create page:
There are couple of things wrong with this:
I don't see the calendar/clock widget for the DateTimeField (createdAt) that I expected to see here.
There's no selection input for either currentSnapshot or device fields (Even though there are devices in the DB)
This is not because I am using the django-material plugin. I tested without it and I still get the same "empty" form.
What's the cause of this and how to fix?
EDIT:
This is what I see in the admin panel for `MISMWorkflow', this is exactly the sort of form I expect to see (ofc, I don't want to create foreign key entities from here, just to list them down):
EDIT: The problem seems to happen only when I extend the base template. If I don't use it, I can see the fields properly. For example, template will be like so:
<html>
<body>
<form action="" method="POST">{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="_submit" class="btn" value="Save" />
</form>
<body>
<html>
And I can see the dropdowns now:
Here is my base.html:
{% load static %}
{% load compress %}
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{% static 'mism_web/css/materialize.min.css' %}" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="{% static 'mism_web/css/helper.css' %}" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<!-- TODO: Fix navbar links -->
<body>
<div>
<nav>
<div class="nav-wrapper">
MISM
<a href="#" data-activates="mobile" class="button-collapse">
<i class="material-icons">menu</i>
</a>
<ul class="right hide-on-med-and-down">
<li>
<a href="{% url 'mism_web:index' %}">
<i class="material-icons left">home</i>
Home
</a>
</li>
<li>
<a href="{% url 'mism_web:device_list' %}">
<i class="material-icons left">perm_device_information</i>
Devices
</a>
</li>
<li>
<a href="{% url 'mism_web:workflow_list' %}">
<i class="material-icons left">format_indent_increase</i>
Workflows
</a>
</li>
<li>
{% if user.is_authenticated %}
{{ user.get_username }}
{% else %}
Unknown user
{% endif %}
</li>
</ul>
<ul class="side-nav" id="mobile">
<li>
<a href="{% url 'mism_web:device_list' %}">
<i class="material-icons top">home</i>
Home
</a>
</li>
<li>
<a href="{% url 'mism_web:device_list' %}">
<i class="material-icons top">perm_device_information</i>
Devices
</a>
</li>
<li>
<a href="{% url 'mism_web:workflow_list' %}">
<i class="material-icons top">format_indent_increase</i>
Workflows
</a>
</li>
<li>
{% if user.is_authenticated %}
{{ user.get_username }}
{% else %}
Unknown user
{% endif %}
</li>
</ul>
</div>
</nav>
</div>
<div class="container">
{% block content %} {% endblock %}
</div>
<script type="text/javascript" src="{% static 'mism_web/js/jquery-3.2.1.min.js' %}"></script>
<script type="text/javascript" src="{% static 'mism_web/js/materialize.min.js' %}"></script>
<script type="text/javascript" src="{% static 'mism_web/js/helper.js' %}"></script>
</body>
</html>
So, it's the base.html interfering with the form display in some way. I have no idea how.
From what I understood. It seems you havent initialized the select in materialize.
Try adding a script tag in the html file with the form with the following contents:
$(document).ready(function() {
$('select').material_select();
});
You may need to initialize the datepicker plugin too to display the datepicker calendar.
More about this can be found here:
http://materializecss.com/forms.html

URL to each user's profile in a list of users

I have the following code in my userprofile_list.html template:
{% extends "base.html" %}
{% block content %}
{% for users in userprofile_list %}
<a href="{% url 'users:user_profile' user.pk %}">
<div class="user-card">
<img class="profile-pic" src="{%if user.userprofile.profile_pic%}{{user.userprofile.profile_pic.url}}{%endif%}">
<p class="user-card-name">{{ users.pk }}</p>
<p class="user-card-name">{{ users.first_name }}</p>
<p class="user-card-type">{{ users.user_type }}</p>
</div>
</a>
{% endfor %}
{% endblock %}
Note the line <a href="{% url 'users:user_profile' user.pk %}">, I am using it elsewhere in the my app and when clicked it takes you to the profile of the currently logged-in user. However, I would instead like it to take you to the profile of whichever user you clicked on in the users list being created by the for loop. How do I change the url to do that?
I think what has to be done is that instead of getting the pk of the currently logged in user it has to instead get the pk of that specific user in the users list, which is then passed through to the url patterns (already working so I didn't posting it).
Note: If I'm not right with my logic on what has to happen thats fine just let me know what you need to see in order to help. Thank you.
Edit
base.html:
<!DOCTYPE html>
{% load staticfiles %}
<html lang="en">
<head>
<title>Evverest</title>
<meta name"viewport" content="width=device-width, initial-scale=1">
<meta charset="uft-8">
<link rel="shortcut icon" href="/images/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Droid+Sans|Mukta+Mahee|Noto+Sans" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<nav>
<div class="container">
<a class="brand" href="{% url 'index' %}">Evverest</a>
<div class="navbar">
<a class="nav-link" href="{% url 'index' %}">Home</a>
{% if user.is_authenticated %}
<a class="nav-link" href="{% url 'users:user_profile' user.id %}">
{{ user.username|capfirst }}
</a>
<a class="nav-link" href="{% url 'users:user_list' %}">All Members</a>
<a class="nav-link" href="{% url 'account_logout' %}">Logout</a>
{% else %}
<a class="nav-link" href="{% url 'account_login' %}?next=/">Login</a>
<a class="nav-link" href="{% url 'account_signup' %}?next=/">Register</a>
{% endif %}
</div>
</div>
</nav>
<div class="container">
<div class="content">
{% block content %}
{% endblock %}
</div>
</div>
</body>
</html>
I think you have a typo in that link. Try this:
<a href="{% url 'users:user_profile' users.pk %}">
You are using user.pk The loop variable is users, so you need to use users.pk, assuming that you have created a view to edit user_profile by getting pk of user_profile .
EDIT
Try this base.html:
<!DOCTYPE html>
{% load staticfiles %}
<html lang="en">
<head>
<title>Evverest</title>
<meta name"viewport" content="width=device-width, initial-scale=1">
<meta charset="uft-8">
<link rel="shortcut icon" href="/images/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Droid+Sans|Mukta+Mahee|Noto+Sans" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<nav>
<div class="container">
<a class="brand" href="{% url 'index' %}">Evverest</a>
<div class="navbar">
<a class="nav-link" href="{% url 'index' %}">Home</a>
{% if request.user.is_authenticated %}
<a class="nav-link" href="{% url 'users:user_profile' request.user.id %}">
{{ request.user.username|capfirst }}
</a>
<a class="nav-link" href="{% url 'users:user_list' %}">All Members</a>
<a class="nav-link" href="{% url 'account_logout' %}">Logout</a>
{% else %}
<a class="nav-link" href="{% url 'account_login' %}?next=/">Login</a>
<a class="nav-link" href="{% url 'account_signup' %}?next=/">Register</a>
{% endif %}
</div>
</div>
</nav>
<div class="container">
<div class="content">
{% block content %}
{% endblock %}
</div>
</div>

Sign up django with cbv and AbstractUser model image error

i tried using class based views for signup but when i try to add images to the form fields, i keep getting this field is required the problem is with the image file
this is the forms.py file
`
from django import forms
from .models import User
class USerForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = User
fields = ['username', 'email', 'password', 'company', 'description', 'logo']
`
and the views.py file
from django.shortcuts import render, redirect
from django.views.generic import View, TemplateView
from .forms import USerForm
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.views.generic.edit import UpdateView
# Create your views here.
#login_required(login_url="/jembe/login/")
def index(request):
return render(request, 'base.html')
class SignUp(View):
form_class = USerForm
template_name = 'signup.html'
def get(self, request):
form = self.form_class(None)
return render(request, self.template_name, {'form': form})
def post(self, request):
form = self.form_class(request.POST, request.FILES)
if form.is_valid():
user = form.save(commit=False)
username = form.cleaned_data['username']
password = form.cleaned_data['password']
user.set_password(password)
user.save()
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return redirect('invoice:index')
return render(request, self.template_name, {'form': form})
class LogoutView(View):
def get(self, request):
logout(request)
return HttpResponseRedirect('/jembe/login')
class AboutView(TemplateView):
template_name = "about.html"
models.py file
`from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
company = models.CharField(max_length=300)
description = models.TextField(blank=True)
website = models.URLField()
logo = models.ImageField(upload_to='../media/')
`
register.html
{% load staticfiles %}
{% load i18n widget_tweaks %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="img/favicon_1.ico">
<title>{% block title %} Signup {% endblock %} |Jims</title>
""
<!-- Bootstrap core CSS -->
<link href="{% static 'login/css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'login/css/bootstrap-reset.css' %}" rel="stylesheet">
<!--Animation css-->
<link href="{% static 'login/css/animate.css' %}" rel="stylesheet">
<!--Icon-fonts css-->
<link href="{% static 'login/assets/font-awesome/css/font-awesome.css' %}" rel="stylesheet" />
<link href="{% static 'login/assets/ionicon/css/ionicons.min.css' %}" rel="stylesheet" />
<!--Morris Chart CSS -->
<link rel="stylesheet" href="{% static 'login/assets/morris/morris.css">
<!-- Custom styles for this template -->
<link href="{% static 'login/css/style.css' %}" rel="stylesheet">
<link href="{% static 'login/css/helper.css' %}" rel="stylesheet">
<link href="{% static 'css/style.css' %}" rel="stylesheet">
<link href="{% static 'css/bootstrap.css' %}" rel="stylesheet">
<link href="{% static 'css/main.css' %}" rel="stylesheet">
<link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','../../../www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-62751496-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=""><div class="logo">
<a href="" class="logo-expanded">
<i class="ion-compose"></i>
<span class="nav-label">Jigs</span>
</a>
</div></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><strong>About</strong></li>
<li><strong>Login</strong></li>
<li><strong>Register</strong></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="wrapper-page animated fadeInDown">
<div class="panel panel-color panel-primary">
<div class="panel-heading">
<h3 class="text-center m-t-10"> Create a new Account </h3>
</div>
{# error logic #}
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
<strong>{{ error | escape }}</strong>
</div>
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<strong> {{ error | escape }}</strong>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{# end error logic #}
<form class="form-horizontal m-t-40" action="" method="post">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
<div class="col-xs-12">
<label> {{ field.label }} </label>
{{ field|attr:"class:form-control" }}
</div>
</div>
{% endfor %}
<div class="form-group ">
<div class="col-xs-12">
<label class="cr-styled">
<input type="checkbox" checked>
<i class="fa"></i>
I accept <strong>Terms and Conditions</strong>
</label>
</div>
</div>
<div class="form-group text-right">
<div class="col-xs-12">
<button class="btn btn-purple w-md" type="submit">Register</button>
</div>
</div>
<div class="form-group m-t-30">
<div class="col-sm-12 text-center">
Already have account?
</div>
</div>
</form>
</div>
</div>
<!-- js placed at the end of the document so the pages load faster -->
<script src="{% static 'login/js/jquery.js' %}"></script>
<script src="{% static 'login/js/bootstrap.min.js' %}"></script>
<script src="{% static 'login/js/pace.min.js' %}"></script>
<script src="{% static 'login/js/wow.min.js' %}"></script>
<script src="{% static 'login/js/jquery.nicescroll.js' %}" type="text/javascript"></script>
<!--common script for all pages-->
<script src="{% static 'login/js/jquery.app.js' %}"></script>
<hr/>
<center><h3 class="text text-success"> Jembe™ © 2017</h3></center>
</body>
</html>
You have forgotten to set enctype in your form. It should be:
<form class="form-horizontal m-t-40" action="" method="post" enctype="multipart/form-data">
See the Django docs on file uploads for more info.

Categories