Site icon JnPnote

Following Django Tutorial (CRM)-Part2

This post is for myself to remember how to build Django project.
I did follow the tutorial from the JustDjango Learn website free tutorial.
And this is the fourth tutorial named Getting Started With Django.
I am not going over all the details and descriptions for each part. There are good explanations on video of the JustDjango Learn. So, visit their site and try their tutorials if you need more details. Also, the orders of this post and their video might be different because I put things first what I think should come first.

I am doing this on Windows 10 with just Windows PowerShell. Not using virtual machines at all.

This post

1. Run Server

python manage.py runserver

2. Migrations

python manage.py migrate

3. Startapp

python manage.py startapp leads

4. Models


class Lead(models.Model):
	first_name = models.CharField(max_length=20)
	last_name = models.CharField(max_length=20)
	age = models.IntegerField(default=0)
python manage.py makemigrations
python manage.py migrate

5. Database

6. Custom User

from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
	pass
AUTH_USER_MODEL = 'leads.User'

7. Foreignkey

class Agent(models.Model):
	user = models.OneToOneField(User, on_delete=models.CASCADE)
agent = models.ForeignKey("Agent", on_delete=models.CASCADE)

Done for this post.

Exit mobile version