This project for learning to create contact app using django
python3 -m venv venv
source venv/bin/activate
pip install -r requirement.txt
django-admin startproject app .
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
TIME_ZONE = 'Asia/Jakarta'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
python manage.py migrate
python manage.py runserver
python manage.py startapp <module-name>
from django.db import models
from phonenumber_field.modelfields import PhoneNumberField
from django.utils import timezone
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
email = models.EmailField(max_length=250)
phone = PhoneNumberField()
def publish(self):
self.published_date = timezone.now()
self.save()
def full_name(self):
return '{} {}'.format(self.first_name, self.last_name)
def __str__(self):
return self.full_name()
python manage.py makemigrations <module-name>
python manage.py migrate <module-name>
Source: https://medium.com/@siddharthshringi/how-i-made-my-first-django-app-4ede65c9b17f