i always have a starter template for my django projects, but i couldn't help but feel like it does not cover much: fyi - i still have to do deployment configurations on every project and that's overwhelming.
Sheena O'Connell has an amazing starter template that I think I can pick a few things from it, and most importantly, it shares some of my beliefs ... and it has a big focus on frontend(i always forget about that)
There are many excellent Django templates out there. They all have different priorities and opinions.
This template repo is different from the rest in that it's primary focus is frontend development, and frontend testing.
You could simply use this repo as a starting point for your own work - download it however you choose, and start adding your own code to the mix.
Or you can poke around and use this as a learning resource. Make sure you understand how everything was wired up and why certain decisions were made.
The latter is the best bet if you want to grow your own skills - it's likely that you will have different preferences, you might want to lay out your project in different ways and use different tools. That's perfectly normal. In fact, creating your own opinionated template repo is a useful learning experience :)
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
or simply:
pip install uv
after that:
Then run uv sync - this will set up a virtual environment in a directory called .venv. This environment works in the usual way.
this is actually very easy ...
Going forward, if you need to run a command using this environment you have the option of activating the environment or using the uv run command. Eg uv run pytest
then of course setting up tailwind:
npm i
npm run tailwind_build
i will disable the social logins for now(too lazy to settup a new app on github). so on config/settings.py:
# create the database tables
uv run manage.py migrate
# make some fake data inside the database tables so you have something to look at
uv run manage.py fake_news
# Run the server
uv run manage.py runserver
on a successful setup, your app should be running well on port 8000
running tests
the template is using playwright(end-to-end testing for modern web apps) for tests.
a custom authentication model is set under the accounts app. a custom user model with email-based authentication instead of the default username-based one.
fromdjango.dbimportmodelsfromdjango.contrib.auth.modelsimportAbstractBaseUser,BaseUserManagerfromdjango.contrib.auth.modelsimportPermissionsMixinclassUserManager(BaseUserManager):defcreate_user(self,email,password=None,is_active=True,is_staff=False,is_admin=False,):ifnotemail:raiseValueError("User must have an email address")ifnotpassword:raiseValueError("User must have a password")user_obj=self.model(email=self.normalize_email(email),)user_obj.set_password(password)user_obj.is_staff=is_staffuser_obj.is_superuser=is_adminuser_obj.is_active=is_activeuser_obj.save(using=self.db)returnuser_objdefcreate_superuser(self,email,password=None):user=self.create_user(email,password=password,is_staff=True,is_admin=True,)returnuserclassUser(AbstractBaseUser,PermissionsMixin):email=models.EmailField(unique=True)full_name=models.CharField(null=True,max_length=200)is_active=models.BooleanField(default=True)is_staff=models.BooleanField(default=False)is_superuser=models.BooleanField(default=False)USERNAME_FIELD="email"EMAIL_FIELD="email"# The fields required when user is created. Email and password are required by default
REQUIRED_FIELDS=[]objects=UserManager()
conclusion
i love this template because it makes it easier to have the following:
custom user management with django-allauth
very straightforward allauth configurations and customizations, comes in handy
a cool django admin using unfold (i prefer using jazzmin or daisy, but unfold is giving me doubts)
i finally learned how to use django channels for realtime communications ... pretty awesome
fyi: using these learnings to make my template better.
if you wanna try other starter templates, checkout: