Skip to content

Instantly share code, notes, and snippets.

View kda33's full-sized avatar

Dmitrii Kalashnikov kda33

View GitHub Profile
@kda33
kda33 / Base.py
Created September 24, 2019 22:36
Settings.py
"""
Django settings for brain project.
Generated by 'django-admin startproject' using Django 2.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
@kda33
kda33 / TemplateDoesNotExist
Created September 24, 2019 22:34
TemplateDoesNotExist
TemplateDoesNotExist at /bra/
base1.html
Request Method: GET
Request URL: http://127.0.0.1:8000/bra/
Django Version: 2.2.4
Exception Type: TemplateDoesNotExist
Exception Value:
base1.html
Exception Location: /usr/local/lib/python3.7/site-packages/django/template/backends/django.py in reraise, line 84
Python Executable: /usr/local/bin/python
{% block content %}
<h1 class='mb-5'> </h1>
<div class="card mb-5" style="width:400px; border-radius: 8px;">
{% if post.image %}
<img class="img-responsive" src="{{ post.image.thumbnail.400x400 }}" style="border-radius: 8px;" alt="Card image" font-size:8px;>
{% endif %}
<div class="card-body">
<h4 class="card-title">{{ post.title }}</h4>
<p class="card-text">{{ post.body1 }}</p>
<p class="card-text">{{ post.body2 }}</p>
@kda33
kda33 / models.py
Created January 9, 2019 22:30
Model
class Post(models.Model): # Books
user = models.ForeignKey(User, on_delete=models.CASCADE)
image = VersatileImageField(
'Image',
upload_to='media_my/',null=True,
blank=True
)
title = models.CharField(max_length=150, db_index=True)
slug = models.SlugField(max_length=150, unique=True, blank=True)
tags = models.ManyToManyField('Tag', blank=True, related_name='posts')
from django.db import models
from django.shortcuts import reverse
from django.utils.text import slugify
from time import time
from django.contrib.auth.models import User
from django.utils import timezone
from django.conf import settings
from versatileimagefield.fields import VersatileImageField
Operations to perform:
Apply all migrations: accounts, admin, auth, contenttypes, face, sessions
Running migrations:
Applying contenttypes.0001_initial...Traceback (most recent call last):
File "/home/daniel/Projects/dj/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 392, in cmd_query
raw_as_string=raw_as_string)
_mysql_connector.MySQLInterfaceError: Table 'django_content_type' already exists
During handling of the above exception, another exception occurred: