This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils import timezone | |
from django.contrib.auth.models import User | |
class Post(models.Model): | |
author = models.ForeignKey('auth.User') | |
title = models.CharField(max_length=200) | |
text = models.TextField() | |
image = models.ImageField(upload_to='img') | |
created_date = models.DateTimeField( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block content %} | |
<form action="" method="post"> | |
{% csrf_token %} | |
<!-- as_p для того, чтобы каждый элемент формы был с новой строки --> | |
{{ form.as_p }} | |
<button type="submit">Регистрация</button> | |
</form> | |
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from .models import Post | |
class PostForm(forms.ModelForm): | |
class Meta: | |
model = Post | |
fields = ('title', 'text', 'image') |
NewerOlder