2022-07-21 12:46:19 +00:00
|
|
|
# Neptune
|
|
|
|
Django app to handle to manage subscriptions to products using Stripe, and implementation of the products themselves.
|
2022-07-21 12:44:52 +00:00
|
|
|
|
2022-07-21 12:46:19 +00:00
|
|
|
## Setting up the environment
|
|
|
|
Create the virtual environment, enable it, and install the dependencies.
|
|
|
|
```shell
|
2022-07-21 12:47:52 +00:00
|
|
|
$ python3 -m venv env
|
2022-07-21 12:46:19 +00:00
|
|
|
$ source env/bin/activate
|
|
|
|
(env) $ pip install -r requirements.txt
|
|
|
|
```
|
|
|
|
|
2022-07-21 12:47:49 +00:00
|
|
|
## Local settings
|
|
|
|
You'll need to copy the `app/local_settings.example.py` file to `app/local_settings.py`. The project won't start otherwise.
|
|
|
|
```
|
|
|
|
$ cp app/local_settings.example.py app/local_settings.py
|
|
|
|
```
|
|
|
|
|
2022-07-21 12:46:19 +00:00
|
|
|
## Running database migrations
|
|
|
|
Now we need to run the database migrations in order to get a working database.
|
|
|
|
```shell
|
|
|
|
(env) $ python manage.py migrate
|
|
|
|
```
|
|
|
|
|
|
|
|
## Creating a superuser
|
|
|
|
In order to access Django admin, we need a superuser.
|
|
|
|
```shell
|
|
|
|
(env) $ python manage.py createsuperuser
|
|
|
|
Username: t2
|
|
|
|
Email address: t2@google.com
|
|
|
|
Password:
|
|
|
|
Password (again):
|
|
|
|
Superuser created successfully.
|
|
|
|
```
|
|
|
|
|
|
|
|
## Running the server
|
|
|
|
```shell
|
|
|
|
(env) $ python manage.py runserver 8001
|
|
|
|
Starting development server at http://127.0.0.1:8001/
|
|
|
|
Quit the server with CONTROL-C.
|
|
|
|
```
|
|
|
|
As you've guessed, you can access it at http://127.0.0.1:8001/
|
2022-07-21 12:46:26 +00:00
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
Sometimes Django is difficult.
|
|
|
|
|
|
|
|
> `django.db.utils.OperationalError: no such table: core_user`
|
|
|
|
|
|
|
|
This means you haven't yet run the migrations. See above.
|
|
|
|
|
|
|
|
### Updating the models
|
|
|
|
If you make changes to the database models, you will need to create new migrations.
|
|
|
|
Do this like so:
|
|
|
|
```shell
|
|
|
|
(env) $ python manage.py makemigrations
|
|
|
|
```
|
|
|
|
Afterwards, we can apply them as normal.
|
|
|
|
```shell
|
|
|
|
(env) $ python manage.py migrate
|
|
|
|
```
|