Was not able to get this tutorial to work. Facccccccccccck. I see that others were , so that's cool. My project setup is slightly different than yours (different virtual environment, some of the tricks you used didn't work for me), so I was not able to adjust it to make it work. The f*&king joy of deploying Django... I'll try again tomorrow 😁 Cheers Thanks for your time and effort putting this together.
Tbh I got it from either stack overflow or the Django discord server lol. I don't fully understand it myself, but I asked the person who showed it to me how to display the errors in herokus logs haha.
My Django DB settings were not added automatically to Heroku Config Vars like yours were, not sure what I did wrong -- any ideas on how to connect that manually or fix it? Thx
I keep getting a "Import "django_on_heroku" could not be resolved" error both when I followed your instructions and when I follow the Python Crash Course book's instructions for django_heroku.....any idea what coult cause this? when I import django_heroku/django_on_heroku it just gives me this error with a yellow squiqly line.
Hey Symbolic Meta! Hmm, it could be a number things. Firstly, I'd recommend not using django_heroku because it's not maintained anymore (or wasn't last time I checked). Then, I'd recommend checking the following: 1. Are you getting your error on Heroku or locally? (I'd assume on Heroku, but I could be wrong). 2. Were you able to pip install django-on-heroku in general? 3. Did you create virtual environment via pipenv (or anything else) with a python version above 3.6? (this is where I started, so moreso just a curiousity) 4. Did you set your VSCode environment for that folder to that virtual environment? This is likely the cause of the yellow squiggly line. 5. Did you run `pip install django-on-heroku` or `pip install django_on_heroku` inside of your virtual environment? 6. When you ran `python manage.py runserver`, was your virtualenvironmnt activated? 7. Did you update your requirements.txt file after installing django-on-heroku and .gitignore your Pipfile? I believe it'll likely be one of those above.
@@zackplauche Thank you for your detailed reply! Seems to be none of these. 1. I got this error both locally and on heroku. (the site still runs fine in browser though) 2. Yes, I just check and I could install it in general(you mean globally outside the VE right?) 3. My python version is 3.10.0 4. I think so, but 10% unsure what that entails. I changed directory to where manage.py is and used the source myprogram/bin/activate command before doing runserver if that's what you mean. (so my commandline starts with (SE_env) now. 5. I used the version with underscores, and yes, my virtual environment was activated. 6. yes 7. yes This is driving my crazy >_
@@symbolicmeta1942 Hm, if you'd like, we can do a free session where I can look at your environment and see if I can fix it 🙂. You can message me on Codementor and we'll hop on a zoom call. You can reach me at codementor.io/@zackknowspython
I actually don't use the Pipfile in builds. I .gitignore the Pipfile so Heroku knows to use requirements.txt instead. Because not everyone uses pipenv, but requirements.txt is universal. But maybe that's a good idea if someone wants to use Pipfiles 🙂 but I'm not sure because I haven't tried it and don't see a reason to yet. Do you prefer to use Pipfiles?
@@zackplauche the main point is to avoid update the requirements.txt every time you install something new. In solo projects work great but when working in a team someone awayls forget to update requirements.txt....😁... And discovery what is the correct version of the library is a nightmare. With fbprophet (for Data Science) we spend a week to figure out all the versions.
@@HaderAzzini ahhhh wow I didn't know that lol. What's the command you're recommending to use pipenv instead of pip with? Also, are you doing this inside of or outside of the virtual environment?
@@zackplauche just replace pip for pipenv when you are installing. After that you can use pip freeze >requirements.txt as usual or just use the Pipfile if you prefer. But I think that for this specific case, for deploy in heroku, pip freeze is the way
Checkout the www.github.com/zackplauche/django-heroku-s3-template repo and BE SURE TO ADD THE LOGGING PART TO YOUR PROJECT so you can see what is causing the 500 error on your project in production when you use "heroku logs --tail"
It would be more helpful if you explained 'why' you were doing certain things, similar to how Corey Shafer explains the why in his tutorials. This tutorial is blowing through key parts without explaining why you're doing it, with the assumption that the watcher already knows or understands it. This prevents us from actually learning for our own future use, and rather limits us to simply copying the code that you're writing. Not chastising, just advice for future tutorials. I understand explaining every single line of code is way too time consuming, so it would help to layer on more 'whys' in the fundamental parts so we can go on to coding our own things. Otherwise, thank you for helping me on my journey into learning Python and deploying my own app.
Hey Shawn! Thanks for the feedback! I'm curious, which parts specifically did you feel I could've gone more in depth on? Also if you're confused as to why I did something, please ask away and I will reply 🙂.
@@zackplauche For sure, I'll list out examples that I think some further elaboration could help. I think a big thing here is that people looking up these sorts of tutorials are probably beginners like myself who have a very limited understanding for Python as a whole along with heroku and django. Otherwise I assume they wouldn't need a tutorial on how to do this! 3:29 - What is the purpose of models.py? Why are you inputting the code here? 4:26 - Why are you putting this code in views.py instead of other files? What is the significance of this file? Continuing this question for all other files you access (like admin.py) 7:53 - What is 'make migrations'? Why is this necessary? Do I need to do this every time I set up a new page? 8:31 - Why is this path to nothing? What is the purpose of adding 'include' after import path? 8:43 - I'd like to better understand the directories you're using. Why does something like urls.py go in the blog folder? Why do you have a urls.py file in config as well? 8:56 - What was the purpose of all this code you did here? Why do we need it? These are just some examples watching the early part of the video - it's the most important section to me to learn since I already set up a heroku project using heroku's written tutorial. I gauge how useful a tutorial is based on if I'm able to go out and code my own project afterwards. After watching this, I can easily copy everything you wrote and did, but I don't feel like I can go out and set up my own project without hand holding. I bring up Corey Shaffer's channel because when I watch his tutorials, he elaborates every step of the way with the assumption that the viewer doesn't understand why he's doing something. Might also explain why he has the most subscribers out of any channels I've seen. Hope this helps for your future tutorials - I think it's a great sign that you're open to improving. I think you have a ton of knowledge, it just helps if you can explain it to us!
@@ShawnHaupageAh, I hear you and see what you mean! The reason I didn't include a lot of these points is that these are more basic Django concepts that someone would know if they went through Django's official tutorial on their website. This video focused more on the specific parts to make a Django + Heroku project, because this part is hard at first and most of the tutorials across the internet typically miss some important part of the process, even heroku's docs are weird, choppy, and in some places outdated lol, so this info is pretty hard to find.
Also to answer your questions: First, I'd recommend going through the Django official tutorial at least once to understand the general concepts, as you'll learn (and should learn, in my opinion) the general concepts here: docs.djangoproject.com/en/4.0/intro/tutorial01/ 1. models.py is where you define your database tables (called Models in Django). So if we want blog posts, users, ecom products, etc., those are models, and models.py is where yo uput them :) 2. views.py is where you actually render your django-templates (which is another way of saying html files with Django's special tags built-in) and pass data into them to be loaded in your html files. Data that you pass in is called context data, and it's also typically where you'll add Python code from other projects you might use. 3. makemigrations creates a migrations file based on changes you made in models.py. migrate applies what makemigrations defines in the migration files that makemigrations generates when you make changes to your models.py file. You run it everytime you update your models.py (yeah I know, it's a bit confusing at first lol) 4. the first argument in the path function is the path from the base URL of your site (aka, www.mysite.com/) to the page you're wanting to go. So if it's empty like in "path('', views.home), that's telling your django project that you want to render the home view on the root url of your site. If you say (path('about/', views.about), then that would go to www.mysite.com/about/. include just imports all of the urlpatterns (generated by path functions) in another urls.py file and adds it to your root urls.py file, so you can have app specific urls better organized with other apps and urls. 5. Django projects have 2 main pieces: The main project (with the settings.py file) and apps. The main urls.py file includes whatever urls you add to it, and it can also include the urls from your apps. 6. Not sure what you mean, I just added my views to my urls.py file in the blog app haha. Again, I STRONGLY recommend to go through the official django docs first so you can understand what's going on more when you get to these more advanced tutorials.
i get this error trying to generate the secret key: STATIC_ROOT = BASE_DIR / 'staticfiles' TypeError: unsupported operand type(s) for /: 'str' and 'str' please help
Are you using Pathlib for building your file paths (like BASE_DIR = Path(__file__).resolve().parent.parent.parent) in your settings.py or base.py file? If not, that's probably why 🙂
any idea about this error? File "/app/.heroku/python/lib/python3.10/asyncio/windows_events.py", line 6, in raise ImportError('win32 only') ImportError: win32 only
It sounds like you didn't set the a default database lol. You can checkout my repo here and compare settings 🙂: www.github.com/zackplauche/django-heroku-s3-template
Was not able to get this tutorial to work. Facccccccccccck. I see that others were , so that's cool. My project setup is slightly different than yours (different virtual environment, some of the tricks you used didn't work for me), so I was not able to adjust it to make it work.
The f*&king joy of deploying Django... I'll try again tomorrow 😁 Cheers Thanks for your time and effort putting this together.
You can compare your setup with my GitHub repo: www.github.com/zackplauche/django-heroku-s3-template
Thank you for this great tutorial
Glad it was helpful 🙂
great work sir. YOU SOLVED MY ONE NIGHT PROBLEM!!!!!Thanks to YOU
😊😊
I'm glad it only took you one night 😅 took me a lot longer the first time.
Thanks Mr.@@zackplauche for burning your midnight candle and making this a success.
Thanks Zach, it does work well~ hope more videos coming out~
They will be! In the capital of Ukraine right now, so might be a while unfortunately 😅
@@zackplauche Noooooo way! Keep safe! God bless Ukraine and you
@@danhao7833 thanks Dan! 🙏🇺🇦
Thank you, I was stuck with Django 3, failing to deploy to heroku with an Import Default file storage Error. now its all fixed
🥳 Nice! Glad I could help 🙂
thank you very much! for the amount of effort you put on this....hope you do something on django series
Hey adeyinja! What do you mean by Django series?
Want me to do a course? 😏
Great, GREAT!!!!!! It 100% worked! Thank you very much!
42:22 Where was this 'LOGGING' section pasted from? Saw you paste it but not where you copied it from.
Tbh I got it from either stack overflow or the Django discord server lol. I don't fully understand it myself, but I asked the person who showed it to me how to display the errors in herokus logs haha.
Do you know how to add the data in my local default django sqlite3 db into the database on heroku? Thanks for this tutorial
I do! You use Django's dumpdata command and the heroku bash terminal.
1.on local: python manage.py dumpdata app otherApp.YourModel > data.json
2. git add . && git commit -m "Add dumped data" && git push heroku master
3. heroku run bash
4. python manage.py loaddata data.json
That was great! Really interesting, a lot of fun, I learned a lot, and most importantly, it all worked! Thank you so much!
out of all django heroku deployments videos ive seen this is the best fastest simplest one too .
Man, thank you very much! I needed to create Django site for my school project about IT professions and you helped me very much!
I understand explaining every single line of code is way
Hey Lydia! It sounded like you might've meant to type more but got cut off 😅
Great!!! Hope you can make React and Django videos aside from the monolithic Django which is kinda boring. hehe
Maybe one day, but I'm more of a Vue kind of guy 😉
My Django DB settings were not added automatically to Heroku Config Vars like yours were, not sure what I did wrong -- any ideas on how to connect that manually or fix it? Thx
Did you create the heroku postgres database manually?
great! Really interesting, but i am having Internal Server Error. please how can i fix it
You mean a 500 error? Are you experiencing this on Heroku?
@@zackplauche No
I keep getting a "Import "django_on_heroku" could not be resolved" error both when I followed your instructions and when I follow the Python Crash Course book's instructions for django_heroku.....any idea what coult cause this? when I import django_heroku/django_on_heroku it just gives me this error with a yellow squiqly line.
Hey Symbolic Meta! Hmm, it could be a number things.
Firstly, I'd recommend not using django_heroku because it's not maintained anymore (or wasn't last time I checked).
Then, I'd recommend checking the following:
1. Are you getting your error on Heroku or locally? (I'd assume on Heroku, but I could be wrong).
2. Were you able to pip install django-on-heroku in general?
3. Did you create virtual environment via pipenv (or anything else) with a python version above 3.6? (this is where I started, so moreso just a curiousity)
4. Did you set your VSCode environment for that folder to that virtual environment? This is likely the cause of the yellow squiggly line.
5. Did you run `pip install django-on-heroku` or `pip install django_on_heroku` inside of your virtual environment?
6. When you ran `python manage.py runserver`, was your virtualenvironmnt activated?
7. Did you update your requirements.txt file after installing django-on-heroku and .gitignore your Pipfile?
I believe it'll likely be one of those above.
@@zackplauche
Thank you for your detailed reply!
Seems to be none of these.
1. I got this error both locally and on heroku. (the site still runs fine in browser though)
2. Yes, I just check and I could install it in general(you mean globally outside the VE right?)
3. My python version is 3.10.0
4. I think so, but 10% unsure what that entails. I changed directory to where manage.py is and used the source myprogram/bin/activate command before doing runserver if that's what you mean. (so my commandline starts with (SE_env) now.
5. I used the version with underscores, and yes, my virtual environment was activated.
6. yes
7. yes
This is driving my crazy >_
you know what, nenvermind, I will just try aws
@@symbolicmeta1942 Hm, if you'd like, we can do a free session where I can look at your environment and see if I can fix it 🙂. You can message me on Codementor and we'll hop on a zoom call.
You can reach me at codementor.io/@zackknowspython
Sheeeeee
I suggest replacing all pip commands with pipenv, otherwise it is not configured in Pipfile
I actually don't use the Pipfile in builds.
I .gitignore the Pipfile so Heroku knows to use requirements.txt instead.
Because not everyone uses pipenv, but requirements.txt is universal.
But maybe that's a good idea if someone wants to use Pipfiles 🙂 but I'm not sure because I haven't tried it and don't see a reason to yet.
Do you prefer to use Pipfiles?
@@zackplauche the main point is to avoid update the requirements.txt every time you install something new. In solo projects work great but when working in a team someone awayls forget to update requirements.txt....😁... And discovery what is the correct version of the library is a nightmare. With fbprophet (for Data Science) we spend a week to figure out all the versions.
@@HaderAzzini ahhhh wow I didn't know that lol.
What's the command you're recommending to use pipenv instead of pip with?
Also, are you doing this inside of or outside of the virtual environment?
@@zackplauche just replace pip for pipenv when you are installing. After that you can use pip freeze >requirements.txt as usual or just use the Pipfile if you prefer. But I think that for this specific case, for deploy in heroku, pip freeze is the way
Please zack any solution for internal server error , 500
Checkout the www.github.com/zackplauche/django-heroku-s3-template repo and BE SURE TO ADD THE LOGGING PART TO YOUR PROJECT so you can see what is causing the 500 error on your project in production when you use "heroku logs --tail"
I got an error that said “App Crashed” code=H10… any ideas ?
Did you add the logging in your prod.py file so you can look at what Python errors you're getting in your heroku logs?
Same problem, did you fixed it?
It would be more helpful if you explained 'why' you were doing certain things, similar to how Corey Shafer explains the why in his tutorials. This tutorial is blowing through key parts without explaining why you're doing it, with the assumption that the watcher already knows or understands it. This prevents us from actually learning for our own future use, and rather limits us to simply copying the code that you're writing. Not chastising, just advice for future tutorials. I understand explaining every single line of code is way too time consuming, so it would help to layer on more 'whys' in the fundamental parts so we can go on to coding our own things. Otherwise, thank you for helping me on my journey into learning Python and deploying my own app.
Hey Shawn!
Thanks for the feedback!
I'm curious, which parts specifically did you feel I could've gone more in depth on?
Also if you're confused as to why I did something, please ask away and I will reply 🙂.
@@zackplauche For sure, I'll list out examples that I think some further elaboration could help. I think a big thing here is that people looking up these sorts of tutorials are probably beginners like myself who have a very limited understanding for Python as a whole along with heroku and django. Otherwise I assume they wouldn't need a tutorial on how to do this!
3:29 - What is the purpose of models.py? Why are you inputting the code here?
4:26 - Why are you putting this code in views.py instead of other files? What is the significance of this file? Continuing this question for all other files you access (like admin.py)
7:53 - What is 'make migrations'? Why is this necessary? Do I need to do this every time I set up a new page?
8:31 - Why is this path to nothing? What is the purpose of adding 'include' after import path?
8:43 - I'd like to better understand the directories you're using. Why does something like urls.py go in the blog folder? Why do you have a urls.py file in config as well?
8:56 - What was the purpose of all this code you did here? Why do we need it?
These are just some examples watching the early part of the video - it's the most important section to me to learn since I already set up a heroku project using heroku's written tutorial.
I gauge how useful a tutorial is based on if I'm able to go out and code my own project afterwards. After watching this, I can easily copy everything you wrote and did, but I don't feel like I can go out and set up my own project without hand holding. I bring up Corey Shaffer's channel because when I watch his tutorials, he elaborates every step of the way with the assumption that the viewer doesn't understand why he's doing something. Might also explain why he has the most subscribers out of any channels I've seen. Hope this helps for your future tutorials - I think it's a great sign that you're open to improving. I think you have a ton of knowledge, it just helps if you can explain it to us!
@@ShawnHaupageAh, I hear you and see what you mean!
The reason I didn't include a lot of these points is that these are more basic Django concepts that someone would know if they went through Django's official tutorial on their website.
This video focused more on the specific parts to make a Django + Heroku project, because this part is hard at first and most of the tutorials across the internet typically miss some important part of the process, even heroku's docs are weird, choppy, and in some places outdated lol, so this info is pretty hard to find.
Also to answer your questions:
First, I'd recommend going through the Django official tutorial at least once to understand the general concepts, as you'll learn (and should learn, in my opinion) the general concepts here: docs.djangoproject.com/en/4.0/intro/tutorial01/
1. models.py is where you define your database tables (called Models in Django). So if we want blog posts, users, ecom products, etc., those are models, and models.py is where yo uput them :)
2. views.py is where you actually render your django-templates (which is another way of saying html files with Django's special tags built-in) and pass data into them to be loaded in your html files. Data that you pass in is called context data, and it's also typically where you'll add Python code from other projects you might use.
3. makemigrations creates a migrations file based on changes you made in models.py. migrate applies what makemigrations defines in the migration files that makemigrations generates when you make changes to your models.py file. You run it everytime you update your models.py (yeah I know, it's a bit confusing at first lol)
4. the first argument in the path function is the path from the base URL of your site (aka, www.mysite.com/) to the page you're wanting to go. So if it's empty like in "path('', views.home), that's telling your django project that you want to render the home view on the root url of your site. If you say (path('about/', views.about), then that would go to www.mysite.com/about/. include just imports all of the urlpatterns (generated by path functions) in another urls.py file and adds it to your root urls.py file, so you can have app specific urls better organized with other apps and urls.
5. Django projects have 2 main pieces: The main project (with the settings.py file) and apps. The main urls.py file includes whatever urls you add to it, and it can also include the urls from your apps.
6. Not sure what you mean, I just added my views to my urls.py file in the blog app haha.
Again, I STRONGLY recommend to go through the official django docs first so you can understand what's going on more when you get to these more advanced tutorials.
bro, this is very complex and not simple
You're not wrong. It's the simplest guide I've seen. Once you learn how to do it, you can easily set this up in 30 minutes.
If you find a better guide please share it here 🙂 I'll even pin the comment and point people to it.
It was really great , but i need some doubts where could i contact you?
Hey suman!
You can contact me at www.codementor.io/@zackknowspython
i get this error trying to generate the secret key:
STATIC_ROOT = BASE_DIR / 'staticfiles'
TypeError: unsupported operand type(s) for /: 'str' and 'str'
please help
Are you using Pathlib for building your file paths (like BASE_DIR = Path(__file__).resolve().parent.parent.parent) in your settings.py or base.py file? If not, that's probably why 🙂
@@zackplauche thank you! im not using it, im going to check it out
any idea about this error?
File "/app/.heroku/python/lib/python3.10/asyncio/windows_events.py", line 6, in
raise ImportError('win32 only')
ImportError: win32 only
I haven't seen this one before
django.core.exceptions.ImproperlyConfigured: You must define a 'default' database., can you help with this error
It sounds like you didn't set the a default database lol.
You can checkout my repo here and compare settings 🙂: www.github.com/zackplauche/django-heroku-s3-template