Skip to content

Commit

Permalink
Add adopt application
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi Hu committed Mar 28, 2021
1 parent 87496ef commit cd0876a
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
db.sqlite3
project/__pycache__/**
*.cpython-38.pyc
Empty file added adopt/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions adopt/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions adopt/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AdoptConfig(AppConfig):
name = 'adopt'
27 changes: 27 additions & 0 deletions adopt/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.0.7 on 2021-03-28 13:26

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Pet',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Name of pet', max_length=100)),
('breed', models.CharField(help_text='Breed of pet', max_length=100)),
('sex', models.CharField(choices=[('male', 'Male'), ('female', 'Female'), ('other', 'Other')], default='other', help_text='Sex of pet', max_length=15)),
('birth_date', models.DateField(help_text='Birth day of pet')),
('vaccinated', models.BooleanField(help_text='Whether or not pet is vaccinated')),
('profile_image', models.ImageField(blank=True, help_text='Picture of the pet', upload_to='profile_images')),
('bio', models.TextField(blank=True)),
],
),
]
Empty file added adopt/migrations/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions adopt/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from django.db import models
from django.utils.translation import gettext as _


class Pet(models.Model):
name = models.CharField(
max_length=100,
help_text=_('Name of pet'),
)
breed = models.CharField(
max_length=100,
help_text=_('Breed of pet'),
)

MALE = 'male'
FEMALE = 'female'
OTHER = 'other'

SEX_CHOICES = [
(MALE, _('Male')),
(FEMALE, _('Female')),
(OTHER, _('Other')),
]
sex = models.CharField(
max_length=15,
help_text=_('Sex of pet'),
choices=SEX_CHOICES,
default=OTHER,
)
birth_date = models.DateField(
help_text=_('Birth day of pet'),
)
vaccinated = models.BooleanField(
help_text=_('Whether or not pet is vaccinated'),
)
profile_image = models.ImageField(
help_text=_('Picture of the pet'),
blank=True,
upload_to='profile_images',
)
bio = models.TextField(
blank=True,
)
# Create your models here.
4 changes: 4 additions & 0 deletions adopt/templates/adopt/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!doctype html>
<html>
<body>Hi!</body>
</html>
3 changes: 3 additions & 0 deletions adopt/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions adopt/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.index),
]

5 changes: 5 additions & 0 deletions adopt/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.shortcuts import render

def index(request):
return render(request, 'adopt/index.html', {})
# Create your views here.
3 changes: 3 additions & 0 deletions adopt/views.py.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
1 change: 1 addition & 0 deletions project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'adopt',
]

MIDDLEWARE = [
Expand Down
3 changes: 2 additions & 1 deletion project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('adopt/', include('adopt.urls')),
]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Django == 3.0.7
pillow == 7.1.2

0 comments on commit cd0876a

Please sign in to comment.