Answer the question
In order to leave comments, you need to log in
Field for uploading pictures, videos and django documents?
I'm making a Django blog, now my models.py looks like this:
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(
default=timezone.now)
published_date = models.DateTimeField(
blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
image = ImageField(upload_to='images/', null=True, blank=True)
Answer the question
In order to leave comments, you need to log in
image = models.ImageField(upload_to='images/', null=True, blank=True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question