Skip to content

Commit

Permalink
Adiciona upload de imagem para receitas
Browse files Browse the repository at this point in the history
  • Loading branch information
brnocesar committed Nov 8, 2020
1 parent c1eddb8 commit 74caf89
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ venv/
.vscode/
db.sqlite3
*.pyc
static/
static/
media/
18 changes: 18 additions & 0 deletions apps/receitas/migrations/0004_receita_foto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2020-11-08 16:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('receitas', '0003_receita_publicada'),
]

operations = [
migrations.AddField(
model_name='receita',
name='foto',
field=models.ImageField(blank=True, upload_to='receitas/fotos/'),
),
]
1 change: 1 addition & 0 deletions apps/receitas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Receita(models.Model):
rendimento = models.CharField(max_length=100)
categoria = models.CharField(max_length=100)
data_criacao = models.DateTimeField(default=datetime.now, blank=True)
foto = models.ImageField(upload_to='receitas/fotos/', blank=True)
publicada = models.BooleanField(default=False)

def __str__(self):
Expand Down
3 changes: 3 additions & 0 deletions djangoreceitas/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'djangoreceitas/static')
]

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
asgiref==3.3.0
Django==3.1.3
Pillow==8.0.1
psycopg2-binary==2.8.6
pytz==2020.4
sqlparse==0.4.1

0 comments on commit 74caf89

Please sign in to comment.