When I submit my form, it doesn't post the form data and just reloads the form.
It was working beforehand but I'm not sure what I've changed that doesn't make it work anymore. Posting the data through the admin still works fine.
The only 'error' message I can see is in the terminal:
which can be seen here
It sends a get request instead of a post request as well. I've also tested it with removing the JS and bootstrap CDNs but the issue is still the same.
My code is below:
Here is my views.py
def create(request):
if request.method == 'POST':
form = EventCreateForm(request.POST, request.FILES)
if form.is_valid():.
instance = form.save(commit=False)
instance.author = request.user
instance.save()
instance.save_m2m()
return redirect('event:home')
else:
form = EventCreateForm()
return render(request, 'event/create.html', {'form': form})
create.html
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block content %}
{{ form.media }}
<div class="container-fluid">
<div class="col-md-4">
<div class="page-header">
<p> Create an event!</p>
</div>
<form method="post" action="" enctype="multipart/form-data">
{% csrf_token %}
{{ form | crispy}}
<button type="submit">Submit</button>
<br>
<br>
</form>
</div>
</div>
{% endblock %}
Base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous" integrity="sha384-xBuQ/xzmlsLoJpyjoggmTEz8OWUFM0/RC5BsqQBDX2v5cMvDHcMakNTNrHIW2I5f"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" crossorigin="anonymous" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" crossorigin="anonymous" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'event/css/custom.css' %}">
<title>Django Project</title>
</br>
<div class="container-fluid" style='font-family:arial'>
<center>
<h2> Welcome to the django website!</h2>
</center>
</div>
{{ form.media }}
</head>
<!-- body of the text -->
<body>
{% if messages %}
{% for messages in messages %}
{{ message }}
{% endfor %}
{% endif %}
{% if user.is_authenticated %}
<nav class="navbar navbar-expand-md navbar-dark bg-dark sticky-top">
<div class="navbar-nav">
<a class="nav item nav-link active" href="{% url 'event:home' %}">Home</a>
<a class="nav item nav-link" href="{% url 'profiles:profile' %}">Profile</a>
<a class="nav item nav-link" href="{% url 'profiles:edit' %}">Edit profile</a>
<a class="nav item nav-link" href="{% url 'event:create' %}">Create</a>
<a class="nav item nav-link" href="{% url 'profiles:logout' %}">Logout</a>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-success" type="submit">Search</button>
</div>
{% else %}
Login
Register
{% endif %}
</nav>
{% block content %}
{% endblock %}
</body>
</html>
Models.py
class Event(models.Model):
title = models.CharField(max_length=100)
link = models.TextField()
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
image = models.ImageField(default='default.jpg', upload_to='event_images')
image_thumbnail = ImageSpecField(source='image',
processors=[ResizeToFill(100, 100)],
format='JPEG',
options={'quality': 60})
start = models.DateField(blank=True, null=True)
start_time = models.TimeField(blank=True, null=True)
end = models.DateField(blank=True, null=True)
end_time = models.TimeField(blank=True, null= True)
description = HTMLField('description')
tags = models.ManyToManyField(Tags)
subject = models.ManyToManyField(Subject)
attendees = models.ManyToManyField(User, related_name = 'attendees', blank=True)
def __str__(self):
return f'{self.title}'
def get_absolute_url(self):
return reverse('event:detail', kwargs={'pk': self.pk})
Thanks everyone in advance,
All help will be greatly appreciated!
You may have deleted your action. Try adding the url back?
<form method="post" action="{% url "event:create" %}" enctype="multipart/form-data">
I had a problem like this too. I solved it by getting rid of a div tag containing a bootstrap class (<div class="form-group>" to be more precise) located around my form.
same problem existed for me also , the silly mistake you have done is the button thing in your create.html file , replace that with input tap with type submit and class btn , button doesn't submit request
Try this :
<input type="submit" class="btn btn-primary" value="Submit">
i know its bit late but this may seem helpful
Related
I've tried to implement the comments within the html page after creating them in my models and I have migrated them but they still wont appear within the page although when I add a comment from the admin side of the website the add comment button I added in before the else statement in the html disappears, which means that it isn't empty but the comments still wont show?
Models.py
class Photo(models.Model):
category=models.ForeignKey(Category,on_delete=models.SET_NULL,null=TRUE,blank=TRUE)
image=models.ImageField(null=False,blank=False)
description= models.TextField()
def __str__(self):
return self.description
class Comment(models.Model):
user = models.ForeignKey(UserProfile, related_name="profile", on_delete=models.CASCADE)
photo = models.ForeignKey(Photo, related_name="comments", on_delete=models.CASCADE)
text = models.TextField()
date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.user.user.username + ': ' + self.text
and then here is the Html portion
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible" content="IE-edge'>
<title>Photo</title>
<meta name='viewport' content='width-device-width, initial-scale=1'>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-
1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body class="m-5">
<div class="container">
<div class="row justify-content-center">
<div class="col">
Go Back
<div style="height: 90vh;">
<img style="max-width: 100%; max-height: 100%;"
src="{{photo.image.url}}">
<p>
{{photo.description}}
</p>
<h4>Comments...</h4>
{% if not photo.comments.all %}
No Comments Yet...<a href="#">
add one
</a>
{% else %}
{% for comment in photo.comment.all %}
<strong>
{{ comment.date }}
</strong>
<br/>
{{ comment.text }}
{% endfor %}
{% endif %}
</div>
</div>
</div>
</div>
</body>
I looking for a resolving of my issue.
I have custom User model:
class User(AbstractUser):
username = models.CharField(max_length=150, unique=True, blank=False, null=False)
first_name = models.CharField(max_length=150, blank=True)
last_name = models.CharField(max_length=150, blank=True)
password = models.CharField(max_length=150, blank=False)
email = models.EmailField(unique=True, blank=False)
date_create = models.DateTimeField(auto_now_add=True)
address = models.CharField(blank=True, max_length=128)
phone = PhoneNumberField(unique=True)
photo = models.ImageField(upload_to='images/', blank=True)
is_active = models.BooleanField(default=True)
In my app I have e-mail-confirmation. When I create user I hit the "is_active=False". When user activate account then flag "is_active=True". Everything works good.
But when INactive user tries to log in I wanna get message from Django in Login form.
Django has it(source code):
def confirm_login_allowed(self, user):
if not user.is_active:
raise ValidationError(
self.error_messages['inactive'],
code='inactive',
)
But doesn't work for me.
Update: When inactive user tried to log in I get same message as user with incorrect username or password.
I tried to override AuthenticationForm:
User = get_user_model()
class CustomAuthenticationForm(AuthenticationForm):
class Meta: # tried with Meta and without
model = User
def confirm_login_allowed(self, user):
if not user.is_active:
raise forms.ValidationError('There was a problem with your login.')
View:
class CustomLoginView(SuccessMessageMixin, LoginView):
form_class = CustomAuthenticationForm
success_url = reverse_lazy('home')
success_message = "You was logged in successfully"
url:
path('login/', CustomLoginView.as_view(), name='login'),
Update, templates base and login:
<!doctype html>
{% load static %}
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx"
crossorigin="anonymous"></script>
{% block mystyle %}
{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark justify-content-center">
<a class="navbar-brand" href="#">Site</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link" href="{% url 'home' %}">Home</a>
{% if user.is_authenticated %}
<a class="nav-link" href="{% url 'cabinet' %}">Cabinet</a>
<a class="nav-link" href="{% url 'logout' %}">LogOut</a>
{% else%}
<a class="nav-link" href="{% url 'signup' %}">SignUp</a>
<a class="nav-link text-right" href="{% url 'login' %}">LogIn</a>
{% endif %}
</div>
</div>
</nav>
{% if messages %}
{% for message in messages %}
<div class="alert alert-success">{{ message }}</div>
{% endfor %}
{% endif %}
{% block content %}
{% endblock %}
</body>
</html>
{% extends "base.html" %}
{% load crispy_forms_tags %}
<!DOCTYPE html>
{% block title %}Log In{% endblock %}
{% block content %}
<h1 class="row justify-content-center p-4">Log In</h1>
<div class="row justify-content-center">
<div class="col-4">
<form autocomplete="off" method="post">
{% csrf_token %}
{{ form|crispy }}
<div class="container p-2">
Forgot your password?
</div>
<div class="container p-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
{% endblock %}
Could someone help me? Thanks.
I understood it from point of security. I resolved it just override ModelBackend
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth import get_user_model
UserModel = get_user_model()
class CustomModelBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
if username is None:
username = kwargs.get(UserModel.USERNAME_FIELD)
if username is None or password is None:
return
try:
user = UserModel._default_manager.get_by_natural_key(username)
except UserModel.DoesNotExist:
# Run the default password hasher once to reduce the timing
# difference between an existing and a nonexistent user (#20760).
UserModel().set_password(password)
else:
if user.check_password(password): # here (remove 'and self.user_can_authenticate(user):')
return user
Settings
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'accounts.backends.CustomModelBackend',
]
So I have a base.html file where all the components that are common in all the other templates are present. I'm trying to implement Newsletter form functionality in my django project. This form should be displayed on all the pages(in the top navbar).
But the problem here is that this form only shows up on base.html and not the other template pages which extend this file.
base.html
{% load static %}
<html lang="en">
<body>
<div id="overlay">
<div class="overlay-body form-group">
<h2>Subscribe to our newsletter</h2>
<form method="post">
{% csrf_token %}
{{form}}
<button type="reset" onclick="off()">Cancel</button>
<button type="submit" value="submit">Submit</button>
</form>
</div>
</div>
<div class="container">
<header>
<div>
<div class="col-4 "><a id="blog-side" onclick="on()">Subscribe</a></div>
<div class="col-4 ">
<img src="{% static 'img/logo.png' %}" alt="Logo">
Blog
</div>
<div class="col-4 ">About</div>
</div>
</header>
{% block content %}
{% endblock content %}
</div>
</body>
</html>
Here's the Newsletter form from models.py
class Newsletter(models.Model):
email = models.EmailField()
entered_on = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=True)
def __str__(self):
return self.email
forms.py
class NewsletterForm(forms.ModelForm):
class Meta:
model = Newsletter
fields = ('email', )
Any idea as to how to setup this form in the other templates?
The thing here is that you will need to make sure you send in the form in every single view you create. Can I see your views.py file please?
I've been unable to make this work although I realise there are similar questions. Hoping someone can point me in the right direction.
I have a django app which allows uploads of images with it. Right now my model looks like this.
The image is not displaying for some reason when it is called from the code. The reasons I can imagine are in the view.py file, or how I am calling it in the template file.
Appreciate your help in advance,
MODELS
class Category(models.Model):
name = models.CharField(max_length=128, unique=True)
image = models.ImageField(blank=True, null=True, upload_to="locations/%Y/%m/%D")
views = models.IntegerField(default=0)
likes = models.IntegerField(default=0)
slug = models.SlugField(unique=True)
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super(Category, self).save(*args, **kwargs)
class Meta:
verbose_name_plural = 'categories'
def __str__(self):
return self.name
VIEWS
def index(request):
# Query the databse for a list of ALL categories currently stored.
# Order the categories by no likes in descending order .
# Retrieve the top 5 only - or all if less than 5.
# Place the list in context_dict dictionary
# that will be passed to the template engine.
category_list = Category.objects.order_by('-likes')[:5]
page_list = Page.objects.order_by('-views')[:5]
context_dict = {'categories': category_list, 'pages': page_list}
# Render the response and send it back!
return render(request, 'Spaces/index.html', context_dict)
def show_category(request, category_name_slug):
# Create a context dictionary which we can pass
# to the template rendering engine.
context_dict = {}
try:
# Can we find a category name slug with the given name?
# If we can't, the .get() method raises a DoesNotExist exception.
# So the .get() method returns one model instance or raises an exception.
category = Category.objects.get(slug=category_name_slug)
# Retrieve all of the associated pages.
# Note that filter() returns a list of page objects or an empty list
pages = Page.objects.filter(category=category)
# Adds our results list to the template context under name pages.
context_dict['pages'] = pages
# We also add the category object from
# the database to the context dictionary.
# We'll use this in the template to verify that the category exists.
context_dict['category'] = category
# We get here if we didn't find the specified category.
# Don't do anything -
# the template will display the "no category" message for us.
except Category.DoesNotExist:
context_dict['category'] = None
context_dict['pages'] = None
# Go render the response and return it to the client.
return render(request, 'Spaces/category.html', context_dict)
TEMPLATES
{% load staticfiles %}
{% load i18n %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Side Spacer</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<link href="style.css" rel="stylesheet">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-md navbar-light bg-light sticky-top">
<div class="container-fluid">
<a class="navbar-brand" href="#"><img src="#"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active"><a class="nav-link" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#">Spaces</a></li>
<li class="nav-item"><a class="nav-link" href="/Spaces/about/">How it works</a></li>
<li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
{% if user.is_authenticated %}
<li class="nav-item"><a class="nav-link" href="{% url 'logout' %}">Log out {{user.username}}</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{% url 'signup' %}">Sign Up</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'login' %}">Login</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
<!--- Image Slider -->
<div id="slides" class="carousel slide" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#slides" data-slide-to="0"class="active"></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="carousel-caption">
<h3 class="display-2">Need a workspace on the go?</h3>
<h3>Great locations and flexible pricing!</h3>
<button type="button" class="btn btn-outline-light btn-lg" href="{% url 'signup' %}">Join Now!</button>
</div>
</div>
</div>
</div>
<!--- Jumbotron -->
<hr class="my-4">
<div class="container-fluid">
<div class="row jumbotron">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9 col-xl-10">
<p class="lead">For mobile professionals, startups, and business that need the extra deskpace!<br> Productive workspaces are available to help you get things done!<br> Our plans start at $99/month! </p>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3 col-xl-2">
<button type="button" class="btn btn-outline-secondary btn-lg">Our Services</button>
</div>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class ="row">
<div class ="col">
<h2>Most Viewed Spaces</h2>
{% if categories %}
<ul>
{% for category in categories %}
<li>
{% if item != None %}
<img src="{% get_media_prefix %}{{ category.image }}" width="500px" />
{% endif %}
{{ category.name }}
</li>
{% endfor %}
</ul>
{% else %}
<strong>There are no Spaces present.</strong>
{% endif %}
</div>
<div class ="col">
<h2>Most Viewed Events</h2>
<p>
{% if pages %}
<ul>
{% for page in pages %}
<li>{{ page.title }}</span></li>
{% endfor %}
</ul>
{% else %}
<strong>There are no Events present.</strong>
{% endif %}
</p>
</div>
<div>
{% if user.is_authenticated %}
<div>
<p><a class="btn btn-success" href="/Spaces/add_category/" role="button">Add New Space »</a></p>
<p><a class="btn btn-success" href="/Spaces/add_page/" role="button">Create New Event »</a></p>
</div>
{% endif %}
</div> <!-- /container -->
<hr>
<div class="container-fluid padding">
<div class="row text-center">
<div class="col-md-4">
<hr class="light">
<img src="#">
<hr class="light">
<p>555-555-55555</p>
<p>email#someonesmail.com</p>
<p>100 Street name</p>
<p>City, State, 0000</p>
</div>
<div class="col-md-4">
<hr class="light">
<h5>Our hours</h5>
<hr class="light">
<p>Monday: 9AM - 5PM</p>
<p>Saturday: 10AM - 4PM</p>
<p>Sunday: Closed</p>
</div>
<div class="col-md-4">
<hr class="light">
<h5>Service Area</h5>
<hr class="light">
<p>City, State, 0000</p>
<p>City, State, 0000</p>
<p>City, State, 0000</p>
</div>
<div class="col-12">
<hr class="light">
<h5>© nameofthebusiness </h5>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery-slim.min.js"><\/script>')</script>
<script src="../../assets/js/vendor/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
You have to add get_media_prefix before the image. I use {{ category.image.url }} to serve media from AWS S3, but I think here you would just use {{ category.image }}. Play with it a little bit and see.
<img src="{% get_media_prefix %}{{ category.image }}" width="500px" />
You should give proper path for the image. for me below code works properly.
in settings:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
to display image
<img src="/media/{{category.image}}" width="500px" />
Found the problem.
{% if item != None %}
<img src="{% get_media_prefix %}{{ category.image }}" width="500px" />
{% endif %}
Changed too
{% if category.image %}
<img src="{{ category.image.url }}" />
{% endif %}
Problem solved
I have a following problem. In login.html I added {% If user.is_authenticated %} and there everything work. I also added this in navbar.html and home.html, but there it doesn't work, and I don't know why.
This is my views.py
def index(request):
return render(request, 'website/home.html', {'user': user_panel})
def register(request):
registered = False
if request.method =='POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'picture' in request.FILES:
profile.picture = request.FILES['picture']
profile.save()
registered = True
else:
print (user_form.errors, profile_form.errors)
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render(request, 'website/register.html', {
'user_form': user_form,
'profile_form': profile_form,
'registered': registered})
def auth_login(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)
if user:
if user.is_active:
login(request, user)
return HttpResponseRedirect(reverse('index'))
else:
return HttpResponse("Konto jest nieaktywne")
else:
print ("Invalid login details: {0}, {1}".format(username, password))
return HttpResponse("Invalid login details supplied.")
else:
return render(request, 'website/login.html', {})
basic.html
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}" type = "text/css"/>
<link rel="stylesheet" href="{% static 'css/style.css' %}" type = "text/css"/>
<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
</head>
<body>
{% include 'website/navbar.html' %}
{% block body_block %}
{% endblock %}
</body>
</html>
home.html
{% extends 'website/basic.html' %}
{% block body_block %}
{% load staticfiles %}
<div class="container-full-bg" style="background-image:url('{% static 'images/website/jumbotron-website.PNG' %}');" height="100%">
<div class="jumbotron" style="background: transparent">
<div class="container" style="margin-top: 6em"><h1>Agencja Reklamy FUX</h1>
<p>Nasza Agencja to firma z ponad dwudziestoletnią tradycją. Zajmujemy się głównie wielkoformatową
reklamą zewnętrzną, dającą niemalże nieograniczone możliwości przekazu.</p></div>
{% if user.is_authenticated %}
Hello {{ user.username }}
{% else %}
You are not loggin in
{% endif %}
</div>
</div>
{% endblock %}
navbar.html
{% load staticfiles %}
<nav class="navbar navbar-inverse navbar-fixed-top" style="background-color: #363636;">
<div class="container-fluid">
<div class = "container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" style="padding: 0em"><img src="{% static 'images/website/logo.png' %}"></img></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="active">Home <span class="sr-only">(current)</span></li>
<li>O Firmie</li>
<li>Oferta</li>
<li>Klienci</li>
<li>Praca</li>
<li>Kontakt</li>
{% if user.is_authenticated %}
<li>Wyloguj się</li>
{% else %}
<li>Zaloguj się</li>
{% endif %}
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</div>
</nav>
login.html
{% extends 'website/basic.html' %}
{% block body_block %}
<div class="container" style="margin-top: 8rem">
{% if not user.is_authenticated %}
<form id="login_form" method="post" action="/login/">
{% csrf_token %}
<div class="form-group" style="padding-right: 80rem">
<label for="username">Username</label>
<input type="text" class="form-control" name="username" size="60" />
</div>
<div class="form-group" style="padding-right: 80rem">
<label for="username">Password</label>
<input type="password" class="form-control" name="password" size="60" />
</div>
<div class="form-group" style="padding-right: 80rem">
<button type="submit" class="btn btn-default" value="submit">Submit</button>
</div>
</form>
{% else %}
You are logged! {{ user.username }}
{% endif %}
</div>
{% endblock %}