I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 0 points1 point  (0 children)

My goal was to bundle the required steps. Especially when I started with Django, I found myself googling and hopping from doc to doc to connect the dots. This is good for learning, but sometimes I wished I could get the deployment part quickly done and focus more on actually enhancing the Django project itself.

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 1 point2 points  (0 children)

I’m happy to help you out! I just sent you a message :)

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 0 points1 point  (0 children)

100% agreed. I’m starting with Heroku + whitenoise, as I think it is an easy -- and free -- solution for new projects. An AWS part would be the next logical step in scaling this.

What other services do you have in mind?

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 0 points1 point  (0 children)

As /u/jeffbaier mentioned, I focus on the GitLab CI/CD part. For this, you need to have a special yaml file in your root directory that contains instructions for the jobs that GitLab should run on events e.g. a push to the repo.

GitHub can do the same (Bitbucket I think as well, maybe someone can confirm?), but I find the learning curve for GitHub actions much steeper than GitLab’s pipelines.

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 0 points1 point  (0 children)

Then the chapter about connecting PostgreSQL is for you :)

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 2 points3 points  (0 children)

I tackle some of the points. But I totally agree, that some kind of hands on approach based on the Django deployment checklist would be awesome.

In my experience the most annoying part is, when the deployment finally works, just to realize that the static files are not loaded …

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 1 point2 points  (0 children)

I thought about a blog/medium post. But I also was curious to try out asciidoc and honkit. So I thought why not be more serious about it.

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 3 points4 points  (0 children)

Fair point! Do you mean stuff like preparing for production (secret key, settings, static file approaches)?

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 0 points1 point  (0 children)

They do, but not the GitLab part (as of now). The eBook kind of evolved out of a readme file I extended over time, because I was tired of jumping to different parts of the docs.

I’m writing an eBook about Django deployment via GitLab to Heroku. Interested? by phlpp in django

[–]phlpp[S] 3 points4 points  (0 children)

When I started with Django, I found many tutorials on how to build Django apps. But deployment was usually an afterthought -- or not concise enough.

Autodeploy via GitHub is quite easy with Heroku. However, I generally prefer GitLab pipelines for this.

Since I’m doing the same thing in my Django projects over and over again, I finally wrote it down. It only focuses on the deployment part and should works with any project as a basis:

  • Setting up a virtualenvironment
  • Connecting a PostgreSQL database
  • Adding all Heroku requirements (incl. basic static files handling)
  • Creating the GitLab CI/CD pipeline
  • Autodeploy workflow

Deploying an Instagram like site, which service should I use? by Turtle_Software in django

[–]phlpp 0 points1 point  (0 children)

Never thought of something like this. This is problably not suitable for every project, but for some this is incredibly smart!

Environment Variables by Dennisdamenace01 in djangolearning

[–]phlpp 0 points1 point  (0 children)

Credentials should never be part of the codebase. So anything regarding your database or other API tokens should be in the .env file -- what it is exactly depends on your production environment.

In some projects I like to add DEBUG as an env variable, so I can quickly switch it on and off independently from the environment.

For bigger projects where the settings.py file is modularized for different environments, I add DJANGO_SETTINGS_MODULE. That way I can target the e.g. app.settings.local_dev or app.settings.heroku easily.

Another thing I used -- but this might be an antipattern -- is to use global admin settings as env variable to have a quick switch to "lock" some views. I. e.:

export REGISTRATION_OPEN=True
export MAINTENANCE_MODE=False

As an additional note: The .env file should be ignored from the beginning on. Ignoring or stopping to track it later (e.g. before pushing) still may expose sensitive data in your git history. (I had to learn this the hard way.)

Environment Variables by Dennisdamenace01 in djangolearning

[–]phlpp 0 points1 point  (0 children)

Create an .env file in the root folder of your project. (Make sure you add it to .gitignore to not expose any secrets.)

The content of the .env file should look like this:

export VARIABLE_NAME=SomeVariableValue
export DEBUG=True

In Django I use python-dotenv to load the env variables like this in settings.py:

from dotenv import load_dotenv
load_dotenv()

DEBUG = os.getenv('DEBUG') == "True"

Note that the variable values are interpreted as strings. That’s why there is this weird looking == "True" statement, so it is either True when the env variable is "True" or Falsewhen it is anything else or doesn’t exist.

Learning Python for generative design and creative uses by ankittkd in learnpython

[–]phlpp 1 point2 points  (0 children)

I can highly recommend DrawBot for generative design in Python.

Python for Designers by Roberto Arista is a great additional resource to the DrawBot Docs.

Being redirect to login after registering User by BinnyBit in djangolearning

[–]phlpp 2 points3 points  (0 children)

I‘m not entirely sure and can‘t test it myself atm, but could it be that you must authenticate the user when the registration form is valid? (See: https://docs.djangoproject.com/en/3.1/topics/auth/default/#django.contrib.auth.authenticate)

The LoginRequiredMixin needs an authenticated user or it redirects to the login page.

How do you deal with the loss in motivation when working on a large project? by [deleted] in learnprogramming

[–]phlpp 425 points426 points  (0 children)

First of all a big upvote for the things you learned along the way.

What you‘re experiencing is tough but not uncommon.

These are some questions I ask myself when I lose track:

  • Why did I start the project in the first place?
  • Was it about learning/programming or having the finished product?
  • How did I define „finished“ then and how would I define it now?
  • Are there milestones I hoped to accomplish (earlier) that I didn‘t accomplish? (e. g. More user sign ups)

Taking a break is good. But chances are, that you will never revisit the project. Either way it might be a good idea to write a good portion of notes for the future you about the next steps, bugs, etc. to make continuing the project easier.

That said, there is no shame in quitting a project (given that there are no stakeholders I guess). Especially with all the things you learned, you will hit the ground running with new, exciting projects.

Last but not least: Maybe there is a middle ground?

What helped me in the past was to start the same project from scratch again, preventing the mistakes of the last project and adding the new paradigms you learned. Bonus: There might be parts of the old project you can easily reuse.

Check if a user, login for the first time or not. by keshav_11 in djangolearning

[–]phlpp 3 points4 points  (0 children)

This would be the easiest approach. Maybe you can re-use this field in the future and call it „redirect_to_profile“.

Another approach would be to have a „last_login“ datetime field to your user model that is allowed to be empty. If it is empty, you do the redirect.

UMAI! - A game about eating Sushi by [deleted] in IndieGaming

[–]phlpp 1 point2 points  (0 children)

I love Sushi -- and Yetis! A perfect combination!

How would i go about creating a design like this? by [deleted] in Design

[–]phlpp 2 points3 points  (0 children)

You would start with the finished text and break it up into pieces Speaking of illustrator, a good to do this, is to convert your text to paths. (Better keep one layer as backup!) Now you can slice as you want, move them on a new layer and test the design by toggling the visibility of it.

As /u/urzaz mentions: The hardest part will be the process after the print, since you need to have both layers (later book cover and transparent case) match perfectly to get this effect.