Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Next Steps: Make a Blog

In this course, you built a Django portfolio, learned a lot about how Django functions, and made friends with a lot of error messages!

If you’d like to keep building this project, you can check out the article this course is based on to add a blog to your site. A blog is a great way to share your technical knowledge and writing skills with the world.

Download

Sample Project (.zip)

411.3 KB
Download

Course Slides (PDF)

1.7 MB

00:00 Hey, for the final video! In this video course, we built out a pretty cool Django portfolio. We learned a lot about how Django functions and what to take care of.

00:11 Most of all, we made friends with a lot of error messages and made sure that these things are not actually scary, but helpful tips for us to know how to develop forward.

00:20 Now, you might be wondering what’s a possible next step from here, and I have a good tip for you. In the original Real Python written tutorial, there’s a section on how to also create a second app for this project that’s going to be a blog.

00:35 So, a blog is a great way of showing your technical writing skills—and some knowledge, also—with the world, additionally to the projects that you built. Therefore, adding a blog app to your Django project—to your portfolio project—can be a great way to move forward from here.

00:50 I’ll show you how this can look like. So up here, we have another tab now that says Blog. If you click on here, it takes us to a different app inside of our Django project that has different models, it has different views.

01:06 So, all of this stuff that we built inside of the projects app is going to be different inside of the blog app. In here, you can see, we have categories, so we can filter by categories: only show the Django-related posts, or show all of them.

01:20 You can click on the title of a post to, again, get to a details view, similar to in our projects app. Here, you can have all the texts for your blog, and we also have the functionality to leave a comment. So, I can type in here my name, “this is great!”,

01:40 Submit a comment. So users that come and visit your page could also leave a comment on the article that you wrote.

01:50 This nicely integrates together with our portfolio app. Here we have the projects. Again, we can go to the details, et cetera. Up top, in our navigation bar, we can switch to the blog and then take a look at the awesome stuff that you can write about your Python and web development knowledge.

02:09 We have the models registered inside of our admin interface, so you can easily create new categories here, as well as create new posts—same way that we did for our projects.

02:25 In this case, you will have to associate it with a Category object, and then that’s what allows us to do this filtering that I showed you before—let’s take another look at it…

02:38 filtering so that we would, for example, only see the crickets-related posts up here. Sweet! So, this could be a great next step to make your portfolio page even better.

02:50 Make sure to head over to the associated Real Python tutorial and build out your blog for your portfolio app and share all the interesting knowledge that you have inside of your personal blog. That’s it for now.

03:06 Keep learning, keep working on things, keep building stuff—that’s really where all the magic lies. Thanks for being part of this tutorial and I hope to see you around! Bye-bye.

Amitesh Sinha on Oct. 15, 2019

A little bit long.. but a great course !

Martin Breuss RP Team on Oct. 16, 2019

Thanks :) It’s a big topic! Congrats for getting all the way through it @Amitesh Sinha

Rahul Saxena on Oct. 16, 2019

Great course Martin. I just completed it.

Pygator on Oct. 20, 2019

Awesome tutorial Martin! Where is your accent from?

Martin Breuss RP Team on Oct. 21, 2019

I’m originally from Austria 🇦🇹 : )

Gascowin on Oct. 22, 2019

This was very well taught Martin. Many thanks.

So i was thinking; “why not add a simple landing page with links to the ‘Projects’ page”. This is what I did:

  1. Created an app called “pages” :
python manage.py startapp pages
  1. add url pattern in portfolio/urls.py:
path('',include('pages.urls')),
  1. Create a urls.py file in pages folder with the following content:
from....#usual imports

urlpatterns = [
    path('',views.index),
    ]
  1. Create a ‘index’ function in pages/views.py:
def index(request):
    return render(request,'pages/index.html')
  1. Create an index.html welcome page in pages/templates/pages.

…I run the server and I end up with a “TemplateDoesNotExist at / error” message! Any ideas?

Gascowin on Oct. 22, 2019

…found the issue.

I forgot to add ‘pages’ to the installed apps in portfolio/settings.py

Aside from your advice, which of the Django resources on this platform would you recommend as a natural next step?

Thanks once again.

Martin Breuss RP Team on Oct. 22, 2019

Nice work going through the whole process again and creating an additional app 👏! And well done realizing that you’ll also have to register the new app in settings.py. :)

As for next steps:

Hope this helps, and keep up the great work :)

Lee RP Team on Oct. 31, 2019

wooo! that was a great course. my team at work uses django, so this is going to help clarify a lot of things. also, now i know how i can build a site fairly quickly :)

simon on Nov. 6, 2019

Thanks for putting this course together! it was very informative and a good introduction to Django!

brechtv6 on Nov. 24, 2019

Hey Martin, great course!

Real good introduction to get to know the basics of django. Feel like I’ve something to build further upon!

Cheers!

Martin Breuss RP Team on Nov. 26, 2019

Thanks @Lee, @simon and @brechtv6 :)

Glad you enjoyed the course and found it helpful!

eclaudio on Dec. 4, 2019

@MartinBreuss Great Work!! Great Job!!

Deeply appreciated

eclaudio on Dec. 6, 2019

@realpython @martinbreuss any recomendations with to concerns to where would be a great place to deploy this having a hard time. because of a anaconda-client==1.7.2 issue on heroku and render

Martin Breuss RP Team on Dec. 7, 2019

You could try to use https://www.pythonanywhere.com/ or DigitalOcean’s Django droplet for +/- easy deploys. Heroku should work as well. Did you remove the venv from your GitHub repo? There shouldn’t be any need to have anaconda-client up there when running it on Heroku.

pierrelaurent62 on Dec. 9, 2019

Awesome job Martin ! You didactic methods are really cool ! I’m now prepared to build my own site in Django. What would you suggest for a next step ?

Indeed, in admin part, i’ve registered my own models as per your course. But, when clicking on it, i do have Project object (1) .. Project object (n) instead of having something more readable. I’ve tried to create a class within admin.py and pass it to the register function but without success atm.

pierrelaurent62 on Dec. 9, 2019

I have it ! In models.py, i’ve added a str function which return self.title. It works with f’{self.title} - {self.description}’

Martin Breuss RP Team on Dec. 9, 2019

Thanks @pierrelaurent62 and awesome job for figuring this out!

Just for improve the clarity of what you wrote with some formatting: you can make the admin interface return better readable representations of your model objects by adding a __str__() (“dunder str”) method to each class, like so:

class Project(models.Model):

    title = models.CharField(max_length=100)
    # snip

    def __str__():
        return self.title  # or any string combo you'd like :)

Keep up the learning!

eclaudio on Dec. 11, 2019

@martinbreuss Ya I have been changing a bunch of things with this project. I removed the anaconda stuff as I have very little luck with deploying this project. I am trying render now and I might go back pythonanywhere again.

Gaurav yadav on Dec. 11, 2019

I have used a DetailView for blog_detail:****

class PostDetailView(DetailView):
   model = Post
   template_name = 'blog/post_detail.html'

and now i want populate the comment database is there any way using the same Detailview or how can i populate comment database( considering comment model have post as a foreign key) in another class?

eclaudio on Dec. 11, 2019

@martinbreuss I am currently attempting my first deploy with the hosting platform Render. My error is in the portfolio/urls.py file.When I attempt my deployment, Render will be able to produce a (this is just an example) www.mywebsite.com/projects and a www.mywebsite.com/admin page but not at www.mywebiste.com page, and this lack of urlpattern is forcing me not to be able to deploy.  Any advice on how to resolve this is deeply appreciated.

github.com/ErinClaudio/musical-octo-funicular

Martin Breuss RP Team on Dec. 13, 2019

@eclaudio if a missing page at the base URL is really the issue, I think the simplest way to go is to add a redirect() to the base URL, and point it to e.g. /projects/. Check out The Ultimate Guide to Django Redirects and implement the smallest example mentioned at first.

eclaudio on Dec. 19, 2019

@martinBreuss that was super useful, thank you.

So things are going well with the page. But the images for the projects no longer appear on the deployed site. They work just fine locally. I looked through stack overflow and found no solution, any advice?

Martin Breuss RP Team on Dec. 25, 2019

Glad it helped :)

Django can be a bit tricky for getting static files (e.g. images) served correctly in production. Did you run collectstatic and set your STATIC_ROOT directory? Check out Django’s guide on Deploying Static Files.

raymie1986 on Dec. 28, 2019

Thanks, this has got me really started with Django now :)

tsusadivyago on Jan. 2, 2020

I wanted to learn django from a long time, this just got me started. Nice Intro :)

Lokman on Jan. 9, 2020

Thanks @Martin really happy with this course! at least all my self taught python gonna have product out. Will start build something here. Gonna digging more in Django documentation there.

sumazmail on Feb. 2, 2020

Hello Martin, Thank you and your team who worked on this course! This course was really wonderful, I subscribed due to this course. I have one request. Could you cover some details on following items as part of future courses or articles? 1. How are Django front end and back end components deployed in actual production? As a single app or two separate components? 2. This sample app was developed from a development perspective. How about things to be taken care in production application?

Thanks, Suma

Martin Breuss RP Team on Feb. 2, 2020

Hello @sumazmail! Thanks for your post, and glad the course was helpful for you :)

As for your questions, let me attempt to answer as best as I can:

1. Django Deployment

I’m not entirely sure that I understand what you mean with the front-end and back-end components of Django. Django is a back-end framework, the “front-end” part of this app would maybe be the Bootstrap CSS.

You can use JavaScript front-end frameworks together with Django, but I don’t think that is what you’re asking here.

The app as you built it here can be deployed in one piece. Deployment, however, is a whole other world that can get quite complex. Not without reason there are many companies that try to take that work away from you (and let you pay for it instead :)

Heroku

When you want to try to deploy your app, I would suggest to go with Heroku first. They have a great walkthrough on Deploying Python And Django Apps On Heroku.

We also have a written guide on Migrating Your Django Project To Heroku here on Real Python that you can check out.

And MDN has also written a great guide on getting a Django app up on to Heroku in the Deployment chapter of their Django tutorial.

Digital Ocean

Another option is to set up your cloud server from the ground up and deploy your app there. This is more complex and I would suggest it only if you’re up for diving into devops and working with servers.

At the same time it will help you to better understand all the work that is involved with getting an app live on the internet and shed some light on processes that a PaaS such as Heroku takes care of for you.

Digital Ocean has a great guide on How to set up Django with Postgres and gunicorn on Ubuntu.

AWS

Same as Digital Ocean, AWS allows you to build your cloud server yourself and customize whatever you want to deploy your webapp.

If you managed to deploy your app on Digital Ocean and want to try another cloud ecosystem, or if you already have some experience using AWS, then this can be an interesting next step.

We have written guides on Deploying a Django App to AWS Elastic Beanstalk and Deploying Django + Python 3 + PostgreSQL to AWS Elastic Beanstalk that could be helpful to get you started.

Again: deployment is not easy and might take some time and a couple of tries to get more familiar with it. If you just want to get your webapp live on the internet, I’d suggest you to stick with using Heroku.

2. Django in Production

Glad you asked! :) There are indeed a couple of things you will need to take care of when working with a Django app in a production environment.

The first and foremost one is to turn DEBUGGING to False. You will also likely have to run collectstatic to get your static files ready for production.

Read over Django’s official Deployment Checklist and I’d again suggest to check out MDN’s Deployment section in their Django tutorial.

I hope these links can help you get your app deployed. Expect some frustration working through this process. That’s normal and you can do it if you stick with it and keep trying :)

sumazmail on Feb. 3, 2020

Thank you for the detailed response and reference links; I will refer these links.

On front end and back end part of the question - I got your point, it answered my question. As I worked earlier using MEAN stack, where-in front-end website can be hosted on AWS S3 and backend (NodeJS/ MongoDB) on AWS Elastic Beanstalk, I got similar doubts on Django whether the entire app needs to be deployed as a single application.

Martin Breuss RP Team on Feb. 3, 2020

Great! Glad to hear it helped :)

Yes, if you’re combining a Django back-end with a JavaScript front-end framework (such as Angular from MEAN) you could host them on different services. But you can also have them running on the same server.

I’m sure there are good reasons for splitting the delivery up like that, but keep in mind that it’s not necessary. In the end, whatever you (cloud) server architecture you choose to use, they are just a bunch of computers. You can split up services and gain some advantages, but likely also complexity.

As a rule of thumb: as long as you are working for a personal project you don’t have to deal with any of these performance optimizations. Keeping it simple when you’re getting started is the way to go IMO. Django is a great framework that can handle tons of requests just out-of-the-box, and any personal site will be well served without any further adjustments.

If you work for a company that really needs additional tweaks, they will surely know about what and why, and let you know. :)

That said, there’s nothing wrong with exploring how to optimize and prep for that job where they really need you to do it. Just as long as it’s interesting and not overwhelming, and as long as you keep in mind that it’s not necessary in order to get a solid web app up and running.

sumazmail on Feb. 3, 2020

Thank you for the clear explanation! :)

Dion Johnson on Feb. 4, 2020

Martin, thanks for a great course! Much learned and much still to learn and practice. This was my first Real Python course and I’m looking forward to the next one!!

koutsellisthemistoklis on March 4, 2020

Excelent! Just excelent! Well done Martin. Keep up the good job! I have a question, though. Is it possible to get a certification that I did this learning-path so that I can post it on my Linkedin account? (When a registered, the offer indicated that there are certifications). thank in advance! :)

Dan Bader RP Team on March 4, 2020

@koutsellisthemistoklis Yep, you can get a completion certificate for this course and all others here on Real Python. Please check out this article in our support base: Where do I find my Completion Certificates?

Nishith Singhai on April 1, 2020

This tutorial shows how to view single project. How does one view multiple projects in a single view then navigate into the projects.

Martin Breuss RP Team on April 1, 2020

Hi @Nishith Singhai. The fourth part Showcase Your Projects is all about building out an overview page that displays all projects.

sidonio on April 3, 2020

Hi everyone!

I have finally manage to get my portfolio up and running yesterday but now I have a problem loading the page.

When I open the project in PyCharm and run the server, here is what I find:

The default interactive shell is now zsh. To update your account to use zsh, please run chsh -s /bin/zsh. For more details, please visit support.apple.com/kb/HT208050.

(.env) Sidonios-MacBook-Pro:django-portfolio sidoniodossantos$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/contrib/admin/apps.py", line 24, in ready
    self.module.autodiscover()
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/Users/sidoniodossantos/django-portfolio/.env/lib/python3.8/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 779, in exec_module
  File "<frozen importlib._bootstrap_external>", line 916, in get_code
  File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/sidoniodossantos/django-portfolio/projects/admin.py", line 5
    admin.site.register(Project)pwd
                                ^
SyntaxError: invalid syntax

I cant seem to see what the problem migth be. Any ideas?

Best wishes, Sidonio.

Martin Breuss RP Team on April 3, 2020

Hi @Sidonio, double check your error message friend 🤗, it’s got some good tips for you here:

“/Users/sidoniodossantos/django-portfolio/projects/admin.py”, line 5 admin.site.register(Project)pwd ^ SyntaxError: invalid syntax

This gives you two essential pieces of information:

  1. Location: The file where the error occurred: projects/admin.py - and there’s even more info about which line to check out
  2. Type: The type of error, in this case a SyntaxError

Looks like some characters may have accidentally snuck their way into that file : )

sidonio on April 3, 2020

Hi @martin than you very much for the tips. I have finally managed to fix it. the problem was that I accidentally typed pwd in the admin.py but after removing it, it seems to be working fine.

Yes… i did it.

I am completely new to Web development but with this tutorial I have finally learn something valuable and this motivates me to learn even more about python web development.

Again many thanks!!!

Andrew E on April 7, 2020

Brilliant course, thanks again =)

zufrizalfatma on April 9, 2020

thank you for your course

dzhuliana on April 16, 2020

Hello!

Thank you for this amazing course - you are teaching so so well - I am really impressed by your approach! I want to continue with building the Blog but I cannot find a link to the video course. It will be super helpful if you could refer me to this course! Thank you again and never stop doing what you are doing - it’s awesome!

Martin Breuss RP Team on April 17, 2020

Hello @dzhuliana, and thanks for the nice words :)

As to your question: we don’t currently have a Part 2 for the video tutorial, but you can read more about building the Blog in the accompanying written tutorial. Hope that helps to keep you advancing in your learning :)

okorobright13 on April 21, 2020

@Martin thanks alot

Phil M on April 29, 2020

Hi @martin, thank you for a very well done and in depth mini Django course. I really did make a lot of Friends - this was something that I really need to do! :)

The light bulbs kept going on and on again, with each new section through out the course. This really helped me fill in the Django pot holes, from various other Django readings.

Younseo Roh on May 4, 2020

Hi, Martin, thank you for a great course. I’ve just finished this course and I learned a lot from here. I feel more comfortable to create a web application of my own, and would definitely like to extend this one to include blogs!

Martin Breuss RP Team on May 4, 2020

Awesome, that’s great to hear :) Go right ahead and add your blog following the written tutorial.

BlackJesus on May 6, 2020

I started 10:00 yesterday and I just finished it. On to the next one.

Vikash Prasad on May 25, 2020

Thanks Martin!! Great tutorial and i would love to see more tutorials like this.

I am back-end developer but this awesome tutorial gave to very good confident to try front end development as well :)

dec21raj on June 1, 2020

Awesome Tutorial!

Bill Sanderson on June 8, 2020

thanks for the overview…

mwong068 on June 17, 2020

Thanks so much for this tutorial Martin! You’re an amazing teacher and I do feel like error messages can be my friends now. 😊 This truly helped build on my knowledge of Python. Cheers!

himanipargaien on June 19, 2020

Great tutorial.

Mushiri on June 20, 2020

Hey there Martin! I have just completed your course, and I really liked it. I have a project to do for uni, and I had this idea but I wanted to take your suggestion if it was efficient or not. I want to create a Django project which has three apps. I want to have an Blog app, CV app, and a TO-DO app. The issue is, each will have a different HTML, so is that an efficient method?

aerojoe on June 21, 2020

Thanks Martin. Nice Course!

Martin Breuss RP Team on June 22, 2020

Thanks everyone for the nice words and glad you liked the course :)

@Mushiri: That’s definitely a good idea. You will want to have 1 Django project with 3 Django apps. They could each have their own base templates, or you could have them all inherit from a shared one. Read the comments in this discussion on more thoughts regarding that. Keep learning!

Mushiri on June 23, 2020

Thank you very much!

KoJans on June 30, 2020

Hi Martin,

Great tutorial! I just completed it;I think I’ll have to go over some parts again. But I can always use it as a reference.

Thanks!

jamescole2015 on June 30, 2020

Thanks Martin! I enjoyed the course!

richardacairns on July 15, 2020

Hi Martin, just finished the course. Thank you - I really enjoyed it.

Enrique Pelaez on July 18, 2020

I just finished the course, I was able to successfully create my portfolio! What I really liked was the debugging approach, at the beginning I have to confess that it was a little hard to grab for me, but as I made progress on the different modules it started not just to make sense, but to be very effective on quickly finding errors, actually the last 4 or 5 modules I tried first to find the error without watching the video and I can say that most of the time I did it :) … Thanks for the great experience Martin!

Martin Breuss RP Team on July 21, 2020

Hi @everyone, thanks for the nice words and glad the course had been helpful for you! 😄

It helps to go over the concepts again and again, it’ll take practice to make things really stick. I’ve worked with Django for a while and there’s still a lot of stuff I go and look up. So just keep at it and keep building out your ideas, and learn more on the way.

Think of it as going on some more trips with your error friends ;)

stephenwhite597 on July 24, 2020

Brilliant Introductory Course

After many years of been “The Server Guy” or running teams or companies that developed server based software I felt it was time, or rather I had the time to see how far the software world has progressed in Web Development and find out what exists in the Dark Side of the User Interface world.

Martins approach to this is brilliant, a clean , step by step approach reinforcing the learning all the way through the course to the very end when you have your own fully functional project that could easily be changed into many useful solutions.

No buzz words, I don’t remember the term MVC been referenced even once, I don’t even remember an If statement, so no logic either. This means that a non programmer could easily get through this course or even take this class right at the beginning of the learning path, some python syntax knowledge would be helpful but not essential.

As its summer time and I have been working hard I fancied doing an easy not too demanding course progressively throughout the week, this was perfect, kept coming back for half an hour here and there, sometimes rewinding because I had forgot exactly where I was but I enjoyed it thoroughly and may well fire off a couple of little mini projects every now and again to keep my hands in I can see me writing some nice debugging tools for some of the server side technology that I will no doubt continue to produce, I will certainly take the next course now and probably even move on and have a look at flask too.

I would say I have absorbed 99% of it a couple of places I may come back for reference as I thought at the time thats unusual but its a django thing not Martin, so don’t worry man!!

Keep up the brilliant Work!

Steve

Martin Breuss RP Team on July 24, 2020

😁 Thank you @stephenwhite597 for the kind words and great job getting through the course and planning to work on those side projects!

John Kinder on Sept. 8, 2020

While I am not new to Django, it has been a while since I worked with it, so this was excellent for refreshing my memory. It wasn’t too long and well worth the time. Thanks, Martin

Yvonne Wilmot on Sept. 15, 2020

Thanks Martin. Really enjoyed the course. Very clear and easy to understand. Love the ‘debugging’ mode as I know that’s where a lot of the time will be spent so good to know where to look.

Given me a bit of insight into web development as I’ve spent 30+ years developing on the mainframe and now need to re-skill and move on.

Going to look for the next course that I think will be helpful in getting ready for my new job of being the Python developer but more on the back-end side. :)

pavel0 on Sept. 20, 2020

Hi Martin, thank you, I really enjoy this course :)

Justice Pelteir on Sept. 20, 2020

Thank you so much for constructing this course. There were certainly some learning curves, but I can now confidently put together a Django project. Really happy I stumbled across Real Python when my Python journey first began.

iwatts on Sept. 24, 2020

Hi Martin

That was an awesome tutorial - I really feel like I have learned a lot - about to start on the blog and build that out now. So much still to learn but feel confident now.

I have just one question that I hoped would be answered (and reading the comments above it might have been but would just like clarity) - at the moment if I go to the root of the site (127.0.0.1:8000) I get a page not displayed (which I understand, as we haven’t developed a url or template for it). My question though is do we develop a seperate app for that or would we create a views.py in the management app (portfolio) for a home page.

Thanks again

Ian

Martin Breuss RP Team on Sept. 24, 2020

Hi @ianwatts. Good question. It really depends and there’s no hard and clear answer to that. You can build a whole Django project only inside your management app, and many people do.

I prefer using separate apps because it makes the code more compartmentalized and potentially easier to share among different projects.

You could create a new app for your landing page, you could create a new view in your existing app that points to the empty path, or you could add the view and template right in your management app. It really depends on how you want to develop your project.

My Suggestions

  • App-Specific: If the landing page is part of the Django app you’re building, e.g., if your whole project is just about your portfolio, then add it into that specific app.
  • Signpost: If the landing page is a first hello that then allows visitors to choose to go to different pages that live in different apps of your project, then I would add it right in the management app.
  • Feature-Rich: And finally, if it is a large and involved landing page with different functionality that goes beyond just allowing visitors to find their way to different parts of your webapp, then I’d create a separate app for it.

Martin Breuss RP Team on Sept. 24, 2020

Thanks for all the nice feedback! Really glad you’re finding value in the course @John Kinder, @Yvonne Wilmot, @pavel0, @Justice Douglas and @ianwatts! :)

niloct on Nov. 12, 2020

Really enjoyable and simple! Thanks for this, couldn’t point anything bad about it.

Now for the next installments :)

alcuinog on Dec. 3, 2020

Hi Martin, Your Course is awesome. Your course helped me in getting my head around understand the routing in Django so beautifully explained. Thank you for taking the pains.

I have deployed the project to Heroku and am getting an error. Its working fine on my machine. shrouded-beach-81556.herokuapp.com/ Could you please help me to resolve the error?

Thanks Alcuino

Martin Breuss RP Team on Dec. 3, 2020

Glad you’re liking the course :D

@alcuinog make sure you have run makemigrations locally and that you committed your migrations/ folder to version control.

Then try running the migrate command on Heroku:

heroku run bash
python manage.py migrate
exit

You can read more in this StackOverflow post.

Also, you can make sure you went through all the necessary steps described in Heroku’s Django Deployment Tutorial.

Hope that helps!

alcuinog on Dec. 4, 2020

Hi Martin, Thanks for the help. That solved the problem of the error. Now the images are not getting displayed. I have tried googling for solution, and have tried some online solutions, but nothing have worked out. here is the link. shrouded-beach-81556.herokuapp.com/ FYI, I have made the all_projects.html as the home page Would appreciate your help again. Thanks Alcuino

Martin Breuss RP Team on Dec. 4, 2020

Good work fixing the error @alcuinog.

Adding Data in Production

For displaying projects and images: did you add any projects yet? It looks like there aren’t any elements showing up when I inspect your HTML:

<div class="container">
    <h1>Projects</h1>
    <div class="row">

    </div>
</div>

You will have to add the projects, description, and images again when hosting it on Heroku, since you are not automatically adding the data from your SQLite database that you used in local development.

Static File Hosting

Additionally, hosting static files, such as images, online using Django can be a bit tricky when you are starting out. Make sure to read over Heroku’s resource Django Assets and follow their suggestions, namely using whitenoise to handle static assets for you, in order to make your life easier.

Deployment

Deployment is hard, and a whole other story that goes beyond this tutorial, which is focused on getting started with Django development locally. Check out the following resources that might help along the way of getting your app online:

Hope that helps, and keep trying!

alcuinog on Dec. 7, 2020

Hi Martin,

Thank you for the response. The elements are visible on the page source of the page served locally. The screenshot is visible at this link drive.google.com/file/d/1Cm8Tynq-kTfxlhpQLL4S0o4KS5MufweX/view?usp=sharing

I amd sorry, did not understand your advise “You will have to add the projects, description, and images again when hosting it on Heroku, since you are not automatically adding the data from your SQLite database that you used in local development.”

I have also updated the settings.py file as per heroku help file from the following link. devcenter.heroku.com/articles/django-assets

below are the links to the screenshot of the settings.py file drive.google.com/file/d/1IIObNUQ9aRFkh4-H78wPeRBBP7bT1z-F/view?usp=sharing drive.google.com/file/d/1lqGEA4mEmDgZ88-tPLeLUwChaWf7mGwU/view?usp=sharing

Thanks again for helping me out.

Alcuino

Martin Breuss RP Team on Dec. 7, 2020

Hi @alcuinog, what I meant to say is that any data that you add in your local database will not be present in your deployed app.

Heroku starts your app off with a brand new empty database. It even uses a different type of database, namely PostgreSQL. However, you don’t have to worry about the type of database, since Django takes care of this for you.

Add Data

You will need to add new data to your empty production database. You can do that through the Django Shell, but you need to do it on Heroku:

heroku run bash
python manage.py shell

Then you can add your data there. If you choose to do this, you will also first need to find a place to host your images and then add the appropriate URL as a database entry. You could host them on Google Drive, as you did with the screenshots, but you’ll have to dig into how to make them publicly accessible so your app could display them without a problem.

Another option is to use the Django Admin Interface of your deployed web app to add the data to your empty production database.

Either way, you’ll have to add the data, because on Heroku you are starting off with an empty database, and none of the data you added locally will be accessible there.

Hope that clarifies it!

alcuinog on Dec. 7, 2020

Hi Martin,

That worked. Thank you so much.

I appreciate that deployment was not in the scope of this course, but you still you took your time and effort to guide me. You are the best teacher !!! Thank you and God bless you.

Alcuino

Martin Breuss RP Team on Dec. 9, 2020

Awesome! Great job for getting it to work @alcuinog! 😃

APPU RAJ on Dec. 26, 2020

Hey Martin! Thank you so much… This is really a great course and great explanation… I struggled a lot understanding the basic links between files and you did a great job clearing the air, I learnt a lot… Thank you so much for this… Now I can confidently build my own website… 🤩

I’ve one request, I’ve few blogs in medium which I would like to import under blogs section of this app, but each of those blogs have a lot of images in it… If I move it to my website do I need to link every single image as we do it in the course? Any suggestions how can I go about?

Martin Breuss RP Team on Dec. 29, 2020

Hi @APPU RAJ, glad the course is helpful and cool that you’re on your way to building your own website! :D

Hosting Images Yourself

If you want to host your images together with your app, you’ll have to download them from your Medium articles and then add them. You can use the Django Admin Interface to make adding images easier.

Hosting Images Anywhere Else

You don’t need to add the image files to your own server. Instead, you could use a HTML <img> element to point to the URL of your image. You can do this wherever the image is hosted, as long as it is publicly accessible.

If you right-click on your image in your Medium article and select Copy Image Address you’ll be able to fetch that image’s URL.

Then you can add it to your database just like you added the local file URLs to images in this course. For example, I fetched one image URL from one of my Medium articles and it has this URL:

https://miro.medium.com/max/2400/1*VgjNhohCLk56CtIq3Ru0Rg.png

You could go ahead and add that URL as a string to your Django database. However, since you don’t just want it as a featured image on a project, like in this course, you’d need to have a different model for your blog app that allows more than one image per blog post.

If you go down that road, you could then add it in your article like so:

<img src="{{ image.src }}" alt=" {{ image.alt }} ">

What might be even easier, is to hard-code the URL with the rest of the HTML that you’ll probably pull over from Medium, like so:

<img src="https://miro.medium.com/max/2400/1*VgjNhohCLk56CtIq3Ru0Rg.png" alt="your alt text">

Hope this helps! In general it helps to remember that you don’t need to host the image yourself, you just need to be able to link to it somewhere on the Internet. :)

RSS Feed

Another thing you could try is to work with Medium’s RSS feed. I haven’t done this myself and it’s just an idea that might develop into a rabbit hole 🕳🐇 …

But you could try to use this so you don’t actually need to copy your content over, but instead use the HTML of Medium’s RSS feed to set up your blog post on your own site.

You’ll be able to access yours by typing the following in your browser:

medium.com/feed/@yourusername

Replace @yourusername with your Medium user name. This will show your personal RSS feed.

Might be a fun thing to try out, and you might learn a ton on the way. But it could also end up being a dead end, so try this with caution :)

APPU RAJ on Dec. 29, 2020

Hi Martin… Thanks again for the neat explanation, surely will dive into it .. even if it leads to rabbit hole ;p The RSS feed part is what I was actually looking to ask and you explained it …!

Martin Breuss RP Team on Dec. 30, 2020

Glad to hear! Report back when you’re at the bottom of the rabbit hole, I’m interested to hear where it will lead you :D

muruhk on Jan. 3, 2021

Martin, thank you for this amazing course. I am a somewhat beginner to Python, and a complete beginner to Django, and your simple explanations really helped. I actually bought the subscription because of how clear this course was in the first 2 sections.

I took this course to learn how to build a set of APIs that could be accessed by an external website or mobile application. The idea would be that an external front-end application would provide several inputs, such as name, date of birth, etc. and then send that to my python code, which would then provide an output based on some calculations that are done with that data. I have a couple of questions:

  1. Under the project in urls.py, we have the ability to accept the primary key as a parameter. Can we accept multiple parameters, and send that to views.py for processing? How would I accept those parameters as variables in views.py so that I can use them in my code?
  2. I assume most of the python coding logic will be done in views.py, including pulling in all the coding logic I’ve done in other .py files. I also assume I would output the results of that calculation and logic in the views.py return render statement. How can I send the output back to the original requestor vs back to a static webpage (detail.html in our project example)

Essentially I want to use Django to make my Python code API accessible from other external applications. Any thoughts on where I could go to learn more about that?

Once again, great course, and thank you for all your help!

Martin Breuss RP Team on Jan. 7, 2021

Hi @muruhk! Glad you liked the course :)

From what you’re describing, I think the best approach would be to build a REST API on top of your Django app.

Check out the course on Building With Django REST Framework that covers this topic. Hope that’s what you’re looking for!

chuckcoggins on Jan. 13, 2021

Hello Martin, Just wanted to say Thank you for the course. I finished it last night at around midnight. I am planning on turning this into an actual portfolio and resume page I will put onto my resume for when I apply to jobs.

Here is to hoping 2021 allows me to change careers and become a developer!

nathank on Jan. 26, 2021

Thanks Martin for the great course! Really well explained and made the learning process amazing.

KatMac on July 28, 2021

Hi Martin Do you have a course on how I can add a blog to my existing Django site. I would like to continue updating my site. Thank you.

Martin Breuss RP Team on July 29, 2021

Yay @chuckcoggins, I wish you all the best on your path to becoming a developer 🤞✨😄 and glad you liked the course @nathank.

@KatMac, there’s no video course on adding the blog part to your web app, but you can read how to do it in the linked tutorial in the section share your knowledge with a blog.

The concepts are the same, so in case you get stuck when working alongside of it, you can check back to this course to get you unstuck. It’s a great practice that’ll help you train and better understand what you’re doing if you’re following the same concepts, but in a slightly different form. Hope that helps! Leave a comment in the tutorial comments if you need any support : )

Nerdfins on July 29, 2021

Fantastic video series! I will now be seeing all error messages I get in my coding journey as my friends.

Martin Breuss RP Team on July 30, 2021

@Nerdfins 😄 ✅ 🤗

juehuil on Oct. 31, 2021

Thank you so much! Really learned a lot from this course and it also helped me to understand my team’s codebase which is written in Django!

Martin Breuss RP Team on Nov. 2, 2021

Glad it’s proving useful for you @juehuil :)

ssharick8 on Nov. 9, 2021

i wish this had a section for adding content to a project page. An image and description is nice, and the admin section has blocks specifically for that, but what about adding anything else? you have some random images, but are those intended to be screen shots of something real, like a jupyter notebook? Also, this is all still on my local server. That’s cool, but how does this get published so someone else can actually see it? maybe those are in other videos? the end of this course seems a bit abrupt with several loose ends.

ssharick8 on Nov. 9, 2021

i guess the publishing part is what is really left out here. the other stuff is just adding to the model.

Martin Breuss RP Team on Nov. 9, 2021

@ssharick8 like you mentioned, the Django admin interface only reflects what you wrote in your models, so you’ll have to edit your model if you want the option to add something else to your database.

As for the screenshots, these are meant as example photos. You could make your own screenshots of your own projects and add them in the same way so you can showcase your own projects.

Hosting a Django App

Hosting an app on the Internet is its own story and can be quite complex depending on what hosting you choose. It doesn’t have much to do with learning Django, but of course it has everything to do with building a web app from scratch and showing it to other people.

We have a great tutorial on Hosting a Django project on Heroku that you can go through next to get it deployed and live on the Internet.

Hope that helps, and all the best : )

Hugh Tipping on Feb. 13, 2022

Incredible course. It was logical and concise. It gives everything needed to be proficient at Django without overwhelming.

Bravo. And thank you.

Michel on Aug. 16, 2022

Hi Martin!

Thanks for this great introduction to Django. I think I now have a good grasp of where you can go with Django and how to use it.

It still is a bit overwhelming, but having a course likes this with a clear outcome makes it easier to understand the logic all the possibilities. I’m sure all will become clearer once I did a few Django projects. Next up: the blog!

Will you do a follow up with using Python scripts and writing user input to a database?

Nick M on Aug. 28, 2022

This was a superb course. I really enjoyed it! The quality of the content on RP is always good but this was a cut above. This one course was worth the membership price all on its own. Bravo to Martin and all concerned.

A comment on the part 3 (More styling) lesson was that it was a bit ‘messy’ is valid. It certainly didn’t flow as logically as ALL the other lessons but I’m not sure how it could be made better given that this is a course on Django, not Bootstrap. Maybe adding some of the bootstrap content into the course notes so you can cut and paste it more easily maybe? I ended up just copying the files over from the completed project zip file and making sure I knew what all the Django bits were doing.

This is a super minor comment though. I thought the course was brilliant and I have a ton of ideas already for how to use Django at work and at home. Super Job!

Nick.

richardfox on Dec. 3, 2022

Nice, logically ordered and thorough introduction. I’ve previously worked through the PythonAnywhere tutorial and have a site up and running already, but this was a great refresher. I really like how you relate the error messages to what has to be done next.

Martin Breuss RP Team on Dec. 7, 2022

Thanks everyone, and glad to hear that you’re finding the course content helpful :D

melissac on April 11, 2023

Thank you for this wonderful course. Your approach is so thorough and well-explained. I recently jumped into the deep end with a team working on a Django project, and have been trying to learn as I go. This course gave me so much more confidence and has already proven useful as I’ve seen various errors pop up. I’m sure I will be returning to these videos multiple times.

Allen Floyd on Sept. 30, 2023

Thank you for this tutorial Martin, it was very informative, now I just need to learn how to create a Blog app from scratch to go with this project, one that allows user comments.

alnah on Oct. 4, 2023

Hi Martin! I enjoyed the course. I took out a pen to jot down the key points from the videos. After each section, I revisited my notes and applied what I had learned. It took me roughly 15 hours to go through everything and get it all working with a good understanding. I feel a bit frustrated that I haven’t mastered Bootstrap for the frontend yet, but I understand that the primary focus of the course was to introduce the basics of Django and ORM. The materials and feedback were helpful for styling the project. I’m eager to learn more advanced topics in the future. Thanks!

Martin Breuss RP Team on Oct. 5, 2023

@alnah glad you enjoyed it and found it useful, and thanks for sharing how long it took you to go through the course thoroughly. I think that’s very valuable also for other learners to hear about—it’s not just about watching a course, but if you want to understand the contents, it takes a lot more time and work. Great that you put the time and work into it 🙌

And yes… unfortunately the front end is a whole other story :P

Also thanks to @melissac and @Allen Floyd for the nice words :D

We’ll have a dedicated written tutorial about how to add the blog to an app like this coming out soon!

Mercy Orangi on Feb. 3, 2024

I just finished the course, thank you Martin for explaining Django so well! I’ve been coding in Python, and most courses I’ve gone through give an already set-up Django app boiler plate to build upon, so it was refreshing to understand the principles behind most of what I couldn’t before. Definitely going to challenge myself this month to complete the blog part, and host it on Heroku.

Martin Breuss RP Team on Feb. 5, 2024

@Mercy Orangi yay, glad you liked it and found the course helpful! :D

Also, if you want some guidelines for the blog, then you can check out the tutorial on how to build a blog from scratch in Django and the tutorial on hosting a Django project on Heroku.

Become a Member to join the conversation.