Skip to content

PYTHON-4814 Create project and app templates #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

PYTHON-4814 Create project and app templates #148

wants to merge 2 commits into from

Conversation

aclark4life
Copy link
Collaborator

@aclark4life aclark4life commented Oct 2, 2024

fixes #147

@aclark4life aclark4life changed the title PYTHON-4814 Create project template PYTHON-4814 Create project and app templates Oct 2, 2024
@aclark4life aclark4life marked this pull request as ready for review October 2, 2024 17:18
@aclark4life
Copy link
Collaborator Author

This is ready to go in assuming folks think this should go in here. It reduces setup of a new project and app to one extra command to generate migrations for Django apps:

python manage.py makemigrations admin auth contenttypes

Then:

python manage.py migrate

@Jibola
Copy link
Contributor

Jibola commented Oct 2, 2024

Could you also update the README instructions to reflect these new suggested steps?


Then
```console
$ python manage.py makemigrations admin auth contenttypes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we could include the migrations in the project template.

$ python manage.py migrate
```

### Manual steps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure the readme is structured so that readers don't skip over this section since it contains a lot of useful info that's needed beyond just getting this working. For example, creating migrations and custom app configs for third-party apps they want to use.

To create a new Django project that uses MongoDB, you can use the templates in this repository. For example:

```console
$ django-admin startproject --template=project_template mysite
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should include these templates in this repo. Normally, users will be pip installing this package, which means they would either have to reference --template=/path/to/site-packages/django_mongodb/project_template or install via a URL. It looks like you modified the source distribution not to include the templates, so it's unclear how you're expecting this command to work. Probably installing via URL makes the most sense, which means we could include them in this repo and exclude them from the source, or a separate repo could work just as well. We should have separate templates for each version of Django, which could just be branches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should include these templates in this repo. Normally, users will be pip installing this package, which means they would either have to reference --template=/path/to/site-packages/django_mongodb/project_template or install via a URL. It looks like you modified the source distribution not to include the templates, so it's unclear how you're expecting this command to work.

I'm running these local but I'm not sure either … now would be a good time to decide. I think I'm leaning slightly towards closing this PR and creating templates in a separate repository, particularly if we're going to be providing branches for each major Django release.

Probably installing via URL makes the most sense, which means we could include them in this repo and exclude them from the source, or a separate repo could work just as well. We should have separate templates for each version of Django, which could just be branches.

Agree! And the example you provided is nice. What do you think @Jibola ?

DEFAULT_AUTO_FIELD = 'django_mongodb.fields.ObjectIdAutoField'

MIGRATION_MODULES = {
'admin': '{{ project_name }}.mongo_migrations.admin',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way could be fine, but note this is configured differently than the manual steps where I put mongo_migrations in a top-level directory.

@aclark4life
Copy link
Collaborator Author

Moving to separate repo, thanks all 👍

@aclark4life aclark4life closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PYTHON-4814 create project and app templates
3 participants