Initialize Django project #8

Merged
rixx merged 34 commits from 1-initialize-project into main 2025-03-16 09:09:26 +00:00
Member

ref #1

  • Set up
    • uv
    • Django LTS (with Argon2 and PostgreSQL)
  • Developer setup
    • Install linters
    • Document linters
    • Run linters (initial run)
  • Django setup
    • Install Django
    • Use env variables in settings.py
    • Document env variables / add .env.example file
    • Trim unneeded features from settings.py
    • Set up two apps: core and portal (models and frontend)
    • Make sure that adding models works in servala.core
    • Add base.html to servala.frontend and make sure templates and static files (via whitenoise) work
  • Docker setup (@tobru)
  • Bootstrap template (@tobru) (not blocking, can be merged without)
  • Database model (not required to merge this PR)
    • Create custom user model or user profile
    • Create organization related models
    • Create admin for organization related models
    • Create service related models
    • Create admin for service related models
    • Create custom user model
    • Create remaining models
    • Create admin for remaining models

Open questions

  • Docker setup: only for production or also for development?
  • Default timezone when displaying data to users
  • Is logging to stdout sufficient, or should there be log files?
  • Data modeling: When would BillingEntity objects be shared between organizations practically (e.g. who would set that up etc)
  • Data modeling: Where does OrganizationOrigin come from / who fills in that data / is it mandatory? Object vs Enum?
  • Data modeling: user fields? (email / name / …).
  • Data model / data model documentation: service models
    • example objects for service, service category, service offering, service provider, plan, service offering plan
    • service : service offering: many2many?
    • service provider : service offering: many2 many?
    • plan : service offering plan?
    • plan.term: duration field? text field?
  • Payment: invoicing, pricing as json field, …
ref #1 - [x] Set up - [x] uv - [x] Django LTS (with Argon2 and PostgreSQL) - [x] Developer setup - [x] Install linters - [x] Document linters - [x] Run linters (initial run) - [ ] Django setup - [x] Install Django - [x] Use env variables in settings.py - [x] Document env variables / add .env.example file - [x] Trim unneeded features from settings.py - [x] Set up two apps: core and portal (models and frontend) - [x] Make sure that adding models works in servala.core - [ ] Add `base.html` to servala.frontend and make sure templates and static files (via whitenoise) work - [x] Docker setup (@tobru) - [x] Bootstrap template (@tobru) (not blocking, can be merged without) - [x] Database model (not required to merge this PR) - [x] Create custom user model or user profile - [x] Create organization related models - [x] Create admin for organization related models - [x] Create service related models - [x] Create admin for service related models - [x] Create custom user model - [x] Create remaining models - [x] Create admin for remaining models ## Open questions - ~~Docker setup: only for production or also for development?~~ - ~~Default timezone when displaying data to users~~ - ~~Is logging to stdout sufficient, or should there be log files?~~ - Data modeling: When would BillingEntity objects be shared between organizations practically (e.g. who would set that up etc) - Data modeling: Where does OrganizationOrigin come from / who fills in that data / is it mandatory? Object vs Enum? - Data modeling: user fields? (email / name / …). - Data model / data model documentation: service models - example objects for service, service category, service offering, service provider, plan, service offering plan - service : service offering: many2many? - service provider : service offering: many2 many? - plan : service offering plan? - plan.term: duration field? text field? - Payment: invoicing, pricing as json field, …
rixx added 3 commits 2025-03-05 10:16:38 +00:00
Installation of:
- Django[argon2]==4.2 (current LTS)
- psycopg2-binary (PostgreSQL driver)

Plus result of django-admin startproject servala src/
rixx added spent time 2025-03-05 10:17:27 +00:00
4 hours
rixx added 1 commit 2025-03-05 16:36:35 +00:00
rixx added spent time 2025-03-05 16:36:50 +00:00
4 hours
tobru added 1 commit 2025-03-07 08:16:32 +00:00
tobru added 2 commits 2025-03-07 08:21:53 +00:00
tobru added 1 commit 2025-03-07 08:27:01 +00:00
Owner

I added an initial version of a Dockerfile. While it builds, it doesn't run yet because it doesn't find the module.
Also, once we have static files configured, we need to uncomment "collectstatic" in the Dockerfile.

I've also added a pre-commit configuration to help with the coding standards defined in the README.

And there is an initial version of a Forgejo Action which will build and push the container image when the PR is merged to main (untested!).

Regarding the styling, do you think we could use https://github.com/unfoldadmin/django-unfold?

I added an initial version of a Dockerfile. While it builds, it doesn't run yet because it doesn't find the module. Also, once we have static files configured, we need to uncomment "collectstatic" in the Dockerfile. I've also added a [pre-commit](https://pre-commit.com/) configuration to help with the coding standards defined in the README. And there is an initial version of a Forgejo Action which will build and push the container image when the PR is merged to main (untested!). Regarding the styling, do you think we could use https://github.com/unfoldadmin/django-unfold?
tobru added spent time 2025-03-07 08:31:09 +00:00
1 day 21 hours
tobru deleted spent time 2025-03-07 08:39:38 +00:00
- 1 day 21 hours
tobru added spent time 2025-03-07 08:39:49 +00:00
45 minutes
Author
Member

I haven’t worked with django-unfold before, but it looks straightforward.

It seems fairly young within the Django ecosystem (Django is old, 3 years is nothing), but I don't think that's a big issue – I only mention it because you said you wanted to build the project with as few external dependencies as possible. But as long as we just use it for display purposes (and don't rely on its extra features), that should be fine – in that case, rolling things back to the default admin would be as simple as removing all references to it and changing the base class back to the default Django base class.

I pushed a fix for the gunicorn problem – application still won’t start up, but that’s because it requires a SECRET_KEY (which is meant to come from a .env file).

I haven’t worked with django-unfold before, but it looks straightforward. It seems fairly young within the Django ecosystem (Django is old, 3 years is nothing), but I don't think that's a big issue – I only mention it because you said you wanted to build the project with as few external dependencies as possible. But as long as we just use it for display purposes (and don't rely on its extra features), that should be fine – in that case, rolling things back to the default admin would be as simple as removing all references to it and changing the base class back to the default Django base class. I pushed a fix for the gunicorn problem – application still won’t start up, but that’s because it requires a `SECRET_KEY` (which is meant to come from a .env file).
rixx added spent time 2025-03-07 15:02:00 +00:00
4 hours
rixx added 3 commits 2025-03-07 15:02:18 +00:00
Owner

Thanks for your thoughts! You're right, adding this external dependency does bring certain risks. I think it's better to use a "plain" HTML template. I also discovered that Django Unfold uses TailwindCSS and not Bootstrap 5. TailwindCSS is much harder to work with for us non-frontend-devs, so we better stick with Bootstrap 5.

It's not easy to find a good Bootstrap 5 based admin template which is truly free (without many features hidden behind a proprietary "Pro" version). I found one which I think we can safely use: https://github.com/zuramai/mazer

Thanks for your thoughts! You're right, adding this external dependency does bring certain risks. I think it's better to use a "plain" HTML template. I also discovered that Django Unfold uses TailwindCSS and not Bootstrap 5. TailwindCSS is much harder to work with for us non-frontend-devs, so we better stick with Bootstrap 5. It's not easy to find a good Bootstrap 5 based admin template which is truly free (without many features hidden behind a proprietary "Pro" version). I found one which I think we can safely use: https://github.com/zuramai/mazer
tobru added 1 commit 2025-03-07 15:59:03 +00:00
Owner

Docker setup: only for production or also for development?

I feel with uv we don't need Docker for development, so for now, we can see Docker for production.

Default timezone when displaying data to users

Browsers timezone.

Is logging to stdout sufficient, or should there be log files?

stdout is sufficient

Data modeling: When would BillingEntity objects be shared between organizations practically (e.g. who would set that up etc)

For the MVP: This would be done by the admin of the portal, it's not required to have this in self-service yet.
See https://kb.vshn.ch/appuio-cloud/references/architecture/control-api-billing-entity.html for how we do it in APPUiO today.

Data modeling: Where does OrganizationOrigin come from / who fills in that data / is it mandatory?

It is mandatory, with a default set to "VSHN". This information will never be set by the user, always by a portal admin or a system integration. This is later being used for the integration into Exoscale via the Open Service Broker API endpoint (see https://kb.vshn.ch/app-catalog/csp/exoscale/osbapi.html and the WIP 3641da770f/docs/modules/ROOT/pages/csp/exoscale/osbapiv2.adoc).

Data modeling: user fields? (email / name / …)

For the user: first name, last name, email, company. Nothing more is required yet.

> Docker setup: only for production or also for development? I feel with `uv` we don't need Docker for development, so for now, we can see Docker for production. > Default timezone when displaying data to users Browsers timezone. > Is logging to stdout sufficient, or should there be log files? stdout is sufficient > Data modeling: When would BillingEntity objects be shared between organizations practically (e.g. who would set that up etc) For the MVP: This would be done by the admin of the portal, it's not required to have this in self-service yet. See https://kb.vshn.ch/appuio-cloud/references/architecture/control-api-billing-entity.html for how we do it in APPUiO today. > Data modeling: Where does OrganizationOrigin come from / who fills in that data / is it mandatory? It is mandatory, with a default set to "VSHN". This information will never be set by the user, always by a portal admin or a system integration. This is later being used for the integration into Exoscale via the Open Service Broker API endpoint (see https://kb.vshn.ch/app-catalog/csp/exoscale/osbapi.html and the WIP https://github.com/vshn/application-catalog-docs/blob/3641da770ff41e7b39987ab474b1a5a2a4f8716e/docs/modules/ROOT/pages/csp/exoscale/osbapiv2.adoc). > Data modeling: user fields? (email / name / …) For the user: first name, last name, email, company. Nothing more is required yet.
Owner

As Django 5.2 will be out April 2 and afaik it will be the next LTS release, would it make sense to directly go with that version (even with a beta version right now)? Or should we wait and update once it's out?

As Django 5.2 will be out April 2 and afaik it will be the next LTS release, would it make sense to directly go with that version (even with a beta version right now)? Or should we wait and update once it's out?
rixx added 1 commit 2025-03-09 13:59:32 +00:00
rixx added 2 commits 2025-03-09 14:21:31 +00:00
Author
Member
  • Updated to Django 5.2b1 (definitely the best choice to do this now)
  • added a thin custom user model
  • added a preliminary version of the service models

Some related data modeling questions that we can discuss on Monday.

Next steps on my end after we’ve spoken on Monday:

  • finalize models + model docstrings (especially re: JSON fields)
  • add admin integration + mazer

I think then this PR would be considered done, and we could proceed with #5 in order to figure out login + basic templates, layouts, testing.

- [x] Updated to Django 5.2b1 (definitely the best choice to do this now) - [x] added a thin custom user model - [x] added a preliminary version of the service models Some related data modeling questions that we can discuss on Monday. Next steps on my end after we’ve spoken on Monday: - finalize models + model docstrings (especially re: JSON fields) - add admin integration + mazer I think then this PR would be considered done, and we could proceed with #5 in order to figure out login + basic templates, layouts, testing.
rixx added spent time 2025-03-09 14:28:00 +00:00
4 hours
rixx added 13 commits 2025-03-16 09:07:30 +00:00
rixx added spent time 2025-03-16 09:07:56 +00:00
8 hours
rixx force-pushed 1-initialize-project from 3a8ce694be to d14b935242 2025-03-16 09:08:37 +00:00 Compare
rixx changed title from WIP: Initialize Django project to Initialize Django project 2025-03-16 09:09:13 +00:00
rixx merged commit 951c5cfbfb into main 2025-03-16 09:09:26 +00:00
rixx deleted branch 1-initialize-project 2025-03-16 09:09:27 +00:00
tobru deleted spent time 2025-03-26 08:08:13 +00:00
- 45 minutes
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Total time spent: 1 day
rixx
1 day
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: servala/servala-portal#8
No description provided.