Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
request.user returns AnonymousUser even when authenticated
Moved from python 2.7 to 3.5 and django 1.9 to 1.10. Had to fix some minor code, but got everything working except this... request.user (in my index(request) in views.py) returns AnonymousUser, even though facebook authenticates, and gives back the username. Here is a pip freeze of the environment: decorator==4.0.11 defusedxml==0.5.0 Django==1.10.5 gunicorn==19.6.0 ipdb==0.10.2 ipython==5.3.0 ipython-genutils==0.1.0 oauthlib==2.0.1 pexpect==4.2.1 pickleshare==0.7.4 prompt-toolkit==1.0.13 psycopg2==2.6.2 ptyprocess==0.5.1 Pygments==2.2.0 PyJWT==1.4.2 python-social-auth==0.3.6 python3-openid==3.1.0 pytz==2016.10 requests==2.13.0 requests-oauthlib==0.8.0 simplegeneric==0.8.1 six==1.10.0 social-auth-app-django==1.1.0 social-auth-core==1.2.0 traitlets==4.3.2 wcwidth==0.1.7 Any ideas? -
Django Forms do not work on server but work on local machine
I have a Django site I have built and tested on my local machine it works fine (runserver command). When I upload it to my host, everything loads just fine but I have 2 issues that I believe are related when using forms. Issue 1: I have a profile form that you can update your name, photo, etc. When i click the submit button it brings to a django error page stating: Page not found (404) Request Method: POST Request URL: http://servername/accounts/profile/ Raised by: appname.views.profile The odd thing is, it is the same page I am on that loads the form. So if i just click the address bar and hit enter it reloads the page but my changes were not submitted. Issue 2: I have another page that allows you to update team information with the same sort of fields: name, photo, etc (i've included photo in the list as it may have something to do that). When I hit the submit button this page, it redirects me back to the root of the site but keeps the url. For example, the update URL is http://servername/updateteam. When i click submit, that URL stays the same, except i am on … -
Django create a 'back' function
I'm currently working on a CS project that works similar to kickstarter, which the user can back their projects. I already had a follow function which allows the user to follow their favorite projects, the model is shown below: class Team(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='team') following = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='followers', blank=True) There is a function in my view.py that adds the user to the MANYTOMANY field if the user clicks 'follow' button. My question is how should my 'back' model be structured? I need to store the amount the user backed this project, or 'team' in this case, and date they backed. Create a model for 'follow' function wasn't that hard because I didn't need to store any additional data other than just User. But for 'BACK' function, I need to store some additional data like 'date backed', 'amount backed'. -
Pandas from csv to sql in Django: OperationalError, table x has no column named y
I'm building a website to manage the data produced by household devices. The data is contained in .csv files, and there will be several hundreds/thousands of those to ingest over time. The csv looks like this: Timestamp, Address (64bit), Zone, Sensor Type, Data type, Value 12/23/16 02:05:30, some_64bit_address, 5, 0, 0, 255 I can read the csv and convert it to a pandas dataframe, but I'm having trouble saving it to sql. I get an OperationalError at /import/: table FromCsv has no column named Address (64bit). I know there are several questions similar to this one but I haven't been able to find an answer that fixes my problem and I don't know what to try next. I tried with and without index_col=False in read_csv, with and without index=False in to_sql, and I tried deleting the database and migration files and starting from scratch. I'm using python 3.5, django 1.11, pandas 0.19.2 and sqlite3. The view: def import_data(request): if request.method == "POST": files = request.FILES.getlist("csv_files") dateparse = lambda x: pd.datetime.strptime(x, "%m/%d/%y %H:%M:%S") for fichier in files: # convert the file in memory to stringio decoded = fichier.read().decode('utf-8') io_string = StringIO(decoded) try: # convert to dataframe chunks = pd.read_csv( filepath_or_buffer=io_string, parse_dates=["Timestamp"], … -
rendered script display inside body template django
Sorry for my bad english. I use {% ishout.js %} inside head to render scripts file in django template but they display as string "<script type="text/javascript" src="http://localhost:5500/socket.io/socket.io.js"></script> <script type="text/javascript" src="http://localhost:5500/client/ishout.client.js"></script>" and inside body not inside head. And other scripts after that are displayed in body too. I searched and find out by encoding but i cannot find how to fix it. -
Where is `LOGIN_REDIRECT_URL` located in django?
I have followed a couple tutorials that say to change LOGIN_REDIRECT_URL in the settings.py file to customize redirect, but I cannot find it anywhere. I also read that it would be deprecated in Django 1.10 (which I am using) but it is still listed in the docs.. Where is LOGIN_REDIRECT_URL located or am i supposed to customize another way? -
Django Forms MultipleChoiceField always saves all options
I've got the following problem with Django. I am using a generic CreateView with a form to create a new user. The form includes a custom field to save groups with the user. The generic view works and the user is created but it always saves all the groups available with the user and not just the selected ones. views.py: from django.core.urlresolvers import reverse_lazy from django.views.generic.edit import CreateView class UserCreateView(CreateView): form_class = UserCreateForm template_name = 'user-create.html' success_url = reverse_lazy('user-creation-successful') forms.py: from django import forms from django.forms import ModelForm from django.contrib.auth.models import User, Group class UserCreateForm(ModelForm): password2 = forms.CharField(widget=forms.PasswordInput(), label='Confirm password') groups = forms.ModelMultipleChoiceField(queryset=Group.objects.all(), label='Groups', required=False) def clean_password2(self): password1 = self.cleaned_data.get('password') password2 = self.cleaned_data.get('password2') if not password2: raise forms.ValidationError("You must confirm the password") if password1 != password2: raise forms.ValidationError("The passwords do not match") return password2 class Meta: model = User fields = ['username', 'email', 'password', 'first_name', 'last_name'] Do you have an idea, why it does that? -
Listing unique M2M objects
I've got a Person model with a ManyToMany to Tags. I'm trying to get all combinations of tags, and list the persons that have these tags uniquely. E.g.: Tags a b c d Person 1 has tags a and b Person 2 has tags a Person 3 has tags c Person 4 has tags a b and c What I want to get to is something like: Tag A: Person 2 Tag B: None Tag C: Person 3 Tag D: None Tags [A, B]: Person 1 Tags [A, C]: None Tags [A, D]: None Tags [B, C]: None Tags [B, D]: None Tags [C, D]: None Tags [A, B, C]: Person 4 Tags [A, B, D]: None (etc.) With itertools.combinations I'm able to iterate all tags, like: for L in range(0, len(tag_list)+1): for tag_combination in combinations(tag_list, L): print(Person.objects.filter(tag__name__in=tag_list)) But the problem with the above (in the print() statement) is that Person 4 would pop up in "Tag A", "Tag B", Tag C", "Tag [A, B]", "Tag [A, C]", "Tag [B, C]", "Tag [B, D]", "Tag [C, D]", "Tag [A, B, C]", etc., while I only want this person to be listed under "Tags [A, B, C]". Any idea how to … -
Making a Website with idea from Console Application using Django
I'm sorry if the title are too abstract or not clear enough. I already have a console application [findtext] with python and i want to make a django website [findtext] with the same funcionality of the console application. The main function of the console findtext are to find text with the same text in wordlist. File input in this findtext application are file .txt and the output are print in the console. Before reading my question, please see this image.. image : http://i.imgur.com/i8keTYX.png And my question are : In my console application, i'm using input file .txt , and in django using textfield, anything user type in textfield goes to database and when user click process, there's a code to check similarity of the text/words (text/words that stored in database) with wordlist, and after processing, program will printout an html output showing how many text/words are found the similarity with wordlist. I found these : Django design: storing and retrieving text files [Django design: storing and retrieving text files ], but this just about retrieving text. I found these too : integrating Django with a console application [integrating Django with a console application ], my question are not about integrating … -
Where should module specific templates live? [django]
This is what my project looks like now: project |-app1 (and all its subclasses) |-app2 (and all its subclasses) |-project | |-__init__.py | |-urls.py | |-settings.py | |-wsgi.py | |-templates (with some base templates for the whole project) |-manage.py |-an sqlite3 database |-lib |-module1 (with some .py files in there) |-module2 (with some .py files in there) I guess, I should add a templates directory to the module, so it would look like this: |-lib |-module1 (with some .py files in there) |-module2 |-__init__.py |-somefiles.py |-templates |-module2 |-exampletemplate.html Is this right? If not, why not? If this was right: how do I acces the templates in there (they are made to be included, like some special navbar)? Explanation: the module contains the nav and an objects which has the information about where we are and what to do with this knowledge. The template has to be get an instance of this class to know which one of the different link to mark as "you are here". So I have to give an instance of this to the context of every template I use. Can I include directly a rendered template to my normal one, like this? normaltemplate.py ==================== ... {% … -
Django as home directory, THEN PHP as example.com/example in site.conf
I have seen many posts explaining how to use PHP and Django together on the same Apache server. However, each one explains how to use PHP as the main root framework and Django as the subsidiary. I would like to implement the reverse. In other words. I would like connecting to example.com to be handled by Django, but connecting to example.com/stats to be handled by PHP. Here is my Django- site.conf file with SSL enabled: <VirtualHost 0.0.0.0:80> ServerName localhost Redirect / https://example.com/ </VirtualHost> <VirtualHost 0.0.0.0:443> ServerAdmin support@example.com ServerName example.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem WSGIApplicationGroup %{RESOURCE} WSGIDaemonProcess watchprod_wsgi user=www-data group=www-data maximum-requests=10000 WSGIProcessGroup watchprod_wsgi WSGIScriptAlias / /var/www/Example/production/example/main/apache/wsgi.py <Directory /var/www/Example/production/example/game/apache/> Require all granted </Directory> Alias /.well-known/ /var/www/Example/production/example/static/.well-known/ <Directory /var/www/XXXXX/website/static/.well-known/> Require all granted </Directory> Alias /static/ /var/www/Example/production/example/static/ <Directory "/var/www/Example/production/example/static/"> Require all granted </Directory> Alias /media/ /var/www/Example/production/example/static/media/ <Directory "/var/www/Example/production/example/static/media/"> Require all granted </Directory> </VirtualHost> Also, if you see anything wrong that is unrelated to the question in the .conf please let me know! Thank you kindly for the help. -
How to to get objects from the model with multiple filters?
I'm having a little problem with retrieving data from the models. On my HTML i have a form in which i get multiple filters for the data, for example: I have quality and presentation variables, the user choose how he wants to filter, and i send a query in the format 'key1=value1&key2=value2' and things like that. My problem is that, in the views, i don't know how to use this to filter the data. I have this little code to give format to the query filt = {'quality':[],'presentation':[], 'color':[]} quer1 = request.POST.get('value'); print quer1 quer = quer1.split('&') for i in quer: val = i.split('=') filt[val[0]].append(val[1]) With this i create a dict with the data to filter, but then, How can i make a get with the variables of the dict? I mean something like Products.objects.get(filt) Where filt would be a variable in which i only left the non empty lists. I know that if i made it manually, would be something like Products.objecs.get(quality__in = filt['quality'], presentation__in = filt['presentation'], color__in = filt[''color]) But i don't want to make it like this, because if the user didn't set a value for any of the values, then it will be an empty list … -
No module named rest_framewrok . Django + Docker
I'v installed djangorestframework with markdown and django filter using pip in virtualenv in django docker container , checked via pip freeze. The absolute path in OS X is /Users/user/project/denv/lib/python2.7/site-packages. Added 'rest_framework', in settings.py but still after docker-compose up get the following error. I guess it has something to do with wrong path, but have no idea how to fix that Traceback (most recent call last): web_1 | File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper web_1 | fn(*args, **kwargs) web_1 | File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run web_1 | autoreload.raise_last_exception() web_1 | File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception web_1 | six.reraise(*_exception) web_1 | File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper web_1 | fn(*args, **kwargs) web_1 | File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup web_1 | apps.populate(settings.INSTALLED_APPS) web_1 | File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate web_1 | app_config = AppConfig.create(entry) web_1 | File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 90, in create web_1 | module = import_module(entry) web_1 | File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module web_1 | __import__(name) web_1 | ImportError: No module named rest_framework -
Django Graphene custom scalar type with model
I'm using Django Graphene with Python 3.5.3. I have fields in my models that are of the type BigIntegerField. Per the GraphQL specification, numbers can only be up to the int32 size, so when querying my model I receive an error saying the number is too large for the type. Fair enough. What I would like to do then is turn the BigIntegerField into a string before returning it via GraphQL. Where do I specify in the below code where to tell GraphQL to use my custom type? I'm having difficulty even testing that my type works as I'm unsure how to include it in my Django Graphene model. # -*- coding: utf-8 -*- """**GraphQL schema**""" from graphene import relay, Field, AbstractType from graphene.types.scalars import MIN_INT, MAX_INT from graphene.types import Scalar from graphql.language import ast from graphene_django import DjangoObjectType from graphene_django.filter import DjangoFilterConnectionField from graphene_django.debug import DjangoDebug from django.conf import settings from sources.models import AdwAccountGraphQL from django_filters import FilterSet, OrderingFilter MAX = settings.GRAPHENE_MAX_RESULTS class LongString(Scalar): """ Turn an ``ast.IntValue`` into a string if it's greater than the ``MAX_INT`` or less than the ``MIN_INT`` value. TODO: is this right? """ @staticmethod def long_to_string(value): num = int(value) if num > MAX_INT or … -
Django admin static files 404
I'm using Django version 1.10. Project work fine on Debug = True, but when I set it to False is not. Django just can't find static files. My Django settings looks like: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'master', 'update', ] STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) STATIC_ROOT = os.path.join(BASE_DIR, "static") STATIC_URL = '/static/' STATICFILES_DIRS = () And the urls.py from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^master/', include('master.urls')), url(r'^update/', include('update.urls')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) I aslo used python manage.py collectstatic, and it collected everything but still not working. I tried to solve this by reading other articles on this site, but nothing really worked for me. Hope, that someone will at last help. -
Django 1.10: No module named admindjango.contrib
Somehow Admin does not seem installed and neither I can include Admin in INSTALLED_APPS nor I can create superuser of it. What do I do? -
Adding a new backend in Python Social Auth
No where specified where to specify the CLIENT ID and CLIENT SECRET of our custom added backed. http://python-social-auth.readthedocs.io/en/latest/backends/implementation.html#oauth -
How to secure password transition between client to server i.e LDAP server
Could anyone explain me the process of first time authorisation of credentials for Django app, if I will use Ldap for first line of authorisation. and JWT for rest of my api authentication. (I am not able to figured it out to secure password transition between client to server i.e LDAP server) -
What is the purpose of virtualenv if it is docker django application?
What is the purpose of virtualenv inside docker django application? Python and other dependencies are already installed, but at the same time it's necessary to install lots of packages using pip, so it seems that virtualenv is still unclear . Could you please explain the concept? -
ImproperlyConfigured MySQL in Django
settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'OPTIONS': { 'read_default_file': 'my.cnf', }, } } my.cnf: [client] database=fake host=127.0.0.1 port=3306 user=fake password=fake default-character-set=utf8 These files are in the same directory of my Django project. (The actual my.cnf has real credentials). I have installed mysqlclient. However, when I try to runserver I get the error Traceback (most recent call last): File "//anaconda/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "//anaconda/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "//anaconda/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "//anaconda/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "//anaconda/lib/python2.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "//anaconda/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "//anaconda/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "//anaconda/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "//anaconda/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "//anaconda/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module> class AbstractBaseUser(models.Model): File "//anaconda/lib/python2.7/site-packages/django/db/models/base.py", line 108, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "//anaconda/lib/python2.7/site-packages/django/db/models/base.py", line 299, in add_to_class value.contribute_to_class(cls, name) File "//anaconda/lib/python2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "//anaconda/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "//anaconda/lib/python2.7/site-packages/django/db/utils.py", line 212, in __getitem__ backend = load_backend(db['ENGINE']) File "//anaconda/lib/python2.7/site-packages/django/db/utils.py", line 116, in load_backend return import_module('%s.base' % backend_name) File "//anaconda/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) … -
Cloud Foundry Django exit_status=-1
Im trying to deploy an app using cloud foundry an im getting this error and the app is crashing. i've tried to change the buildpack but nothing happens. I don't know how to get more errors. cf logs returns this log OUT Submodule 'compile-extensions' (https://github.com/cloudfoundry/compile-extensions.git) registered for path 'compile-extensions' 2017-02-25T11:08:59.56-0300 [STG/0] ERR Cloning into 'compile-extensions'... 2017-02-25T11:09:00.23-0300 [STG/0] OUT Submodule path 'compile-extensions': checked out 'a76a1ecab87f514248222e50fdc9f46c37078109' 2017-02-25T11:09:00.39-0300 [STG/0] OUT -------> Buildpack version 1.5.15 2017-02-25T11:09:13.34-0300 [STG/0] OUT $ pip install -r requirements.txt 2017-02-25T11:09:48.99-0300 [STG/16] OUT -----> Uploading droplet (159M) 2017-02-25T11:10:16.77-0300 [DEA/16] OUT Starting app instance (index 0) with guid a627703f-3fc8-48a2-869c-572b2abec573 2017-02-25T11:10:26.87-0300 [API/0] OUT App instance exited with guid a627703f-3fc8-48a2-869c-572b2abec573 payload: {"cc_partition"=>"default", "droplet"=>"a627703f-3fc8-48a2-869c-572b2abec573", "version"=>"3ead9c26-4535-4dbd-b3ce-d21483bae661", "instance"=>"cb6eda1feaf647aead2e9ef6c2d435b6", "index"=>0, "reason"=>"CRASHED", "exit_status"=>-1, "exit_description"=>"failed to start", "crash_timestamp"=>1488031826} my manifest.yml is this --- applications: - name: cs instances: 1 command: bash run.sh memory: 200M disk_quota: 256M random-route: false buildpack: https://github.com/cloudfoundry/python-buildpack.git my Procfile has this line web: python cs/manage.py migrate && python cs/manage.py runserver 0.0.0.0:$PORT --noreload and the run.sh has #!/bin/bash if [ -z "$VCAP_APP_PORT" ]; then SERVER_PORT=5000; else SERVER_PORT="$VCAP_APP_PORT"; fi python manage.py makemigrations python manage.py migrate echo [$0] Starting Django Server... python cs/manage.py runserver --noreload 0.0.0.0:$SERVER_PORT The same app it's deployed on heroku without any problem so i cannot understand … -
Can't activate django python environment in docker django application
Can't understand django command in docker application. I am trying to run command which normally would work. source project/bin/activate Which results in : -bash: project/bin/activate: No such file or directory The command would work in non docker django app for sure. Also tried : docker-compose run web source project/bin/activate docker-compose up source project/bin/activate What is right command then? -
Retrieve information from forms with Django
I just started to learn Django (i am familiar with python) and after i completed the tutorial, i dont really get the concept. I tried to write a really small project: At the index there should be a text filed and two check buttons, and i would like to store each "name" written to the text box with the corresponding choices. For this i created a model, like this: from django.db import models class Jelentkezo(models.Model): def __str__(self): return self.nev nev = models.CharField(max_length=200) jelentkezett = models.CharField(max_length=1000) idopont = models.DateTimeField('Jelentkezes ideje') class Edzes(models.Model): def __str__(self): return "{} {} {}".format(self.edzes_ido, self.tipus , self.edzo) tipus = models.CharField(max_length=50) edzes_ido = models.CharField(max_length=200) edzo = models.CharField(max_length=200) jelentkezok_szama = models.IntegerField(default=0) In the class Edzes i store the options which should be selectabe at the index page below the textbox. The class Jelentkező should be the actuall information. Its nev should be the input of the textbox, and jelentkezett should be the checked options text in some kind of string format. I worte the views.py like this: from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_list_or_404, render, reverse from .models import Edzes, Jelentkezo def index(request): edzes = get_list_or_404(Edzes) return render(request, 'ujjero/index.html', {'edzesek': edzes}) def vote(request, edzes_id): print(edzes_id) return HttpResponse("Hello, … -
Django displaying error messages from two separated methods?
I have a Django model defined as below: class Category(models.Model): name = models.CharField(max_length=100, unique=True) slug = models.SlugField(unique=True) Although both defined as uniqe, django admin allows me to add categories like "python", "Python", "PYTHON". I know this is the default behavior. To prevent this i have created a clean() method in Category models as follows: def clean(self, *args, **kwargs): from django.core.exceptions import ValidationError slug = slugify(self.name.lower()) r = Category.objects.filter(slug=slug) print("size") print(r.count()) if r: raise ValidationError("Category with this name already exists. Try again with a new name.") self.slug = slug super(Category, self).clean(*args, **kwargs) It works for most of the cases. But lets say database already has Python category and if i try to add Python again, it will show me two errors one from clean() method and one from validate_unique() method. Here is how it looks. I want to display only one message is there a way to prevent it. Is there any way to override this behavior or something. Thanks in advance. -
Cant extend html template on Django
I cant extends one html document (child - base_home.html) to another parent html document - base.html I have next Django project structure: Testdjango/ blog/ migrations/ templates/ blog/ base.html base_home.html __init.py__ admin.py apps.py models.py tests.py urls.py views.py db.sqlite3 manage.py My parent template is a base.html, with the next code: <!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 --> <meta name="description" content=""> <meta name="author" content=""> <title>{% block title %}{% endblock %} &ndash; Blog</title> <!-- Bootstrap core CSS --> <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/journal/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template <link href="starter-template.css" rel="stylesheet"> --> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <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="#">Blog</a> </div> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> </ul> </div><!--/.nav-collapse --> </div> </nav> <div class="container"> {% block content %} {% endblock %} </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script …