Picking up where we left off

Moving online with Heroku:

Well heroku is a great cloud platform and most importantly it’s free 😉 So I decided to move our django code to the heroku cloud. I had to make some adjustments to get this done. So I thought it’d be best if I made this one post as a “How to” blog for people who are willing to move their applications to heroku. Please note that I would be talking about only the steps that I followed and this is not a generic guide.

Since I use Ubuntu 18.04  for my development I installed heroku cli using snap

sudo apt update
sudo apt install snap
sudo snap install --classic heroku

Once finished installing, it is time to login into heroku. This opens a browser window for you to login, make sure that you have already signed up for heroku account.

heroku login

Once logged in, now we can create a heroku app and add its git remote to our existing django project.

cd into_project_root/ 
heroku create suggestmovie #use some other name
heroku git:remote -a suggestmovie 

Now, the heroku is ready to deploy your code but your code is not ready to be deployed. We need to make some changes in order to get there.
1) The first thing to add is a Procfile. Create a file named Procfile and copy-paste the following in it.

web: gunicorn movierecommend.wsgi --log-file -

Here, movierecommend is the name of my project.
2) Add the requirements.txt. This file tells heroku what dependencies it needs to install to run the Django app. Now if you are using any virtual environment then pip freeze should suffice. But if you are like me and install and use all the python code directly then pip freeze adds some unnecessary files to requirements.txt. There is a software called pipreqs that helps in this scenario. But for this project specifically, these 3 lines in the requirements.txt file is enough

Django==2.2.2
gunicorn
django-heroku

3) Disabling collectstatic: Now, this is a very project specific requirement. For all the UI related imports like mdl and bootstrap I am using CDN and all the content related imports will also be done using URLs. Since now or in near future there is no intention of using static files like images, js, css, I am putting collectstatic to a hold. This can be changed if used later

heroku config:set DISABLE_COLLECTSTATIC=1

4) Using heroku settings: This is code related change in the settings.py of the project root application folder. One the first line import django_heroku and on the last line add

django_heroku.settings(locals())

This code change solves an important problem: The Database. We are currently using SQLite3 as our DBMS. In heroku, what this does is it creates a file whenever it runs migrate. But those files don’t persist which makes the application absolutely useless.

Now it is time to commit these changes (same git commands) and then push them using

git push heroku master

This should be enough to load the application. Now you can navigate to your app URL to see the homepage. We are hosting our project at https://suggestmovie.herokuapp.com/. The UI is crappy and we hope to bring some presentable stuff in the next few weeks.

So this was my progress from Day 2 – Day 5.

I signed up for #100daysofcode challenge on LinkedIn and Surya did the same for #100daysofmlcode. But truth be told, I disappeared after the first day and my partner after day 6. But now we have resumed our journey and we are determined towards finishing our target. We have decided to do the ML coding and the server side logic interchangeably so we both can learn the basics of some other technologies. Will keep you posted.

Day 1: The Uncomfortable Comfort Zone

For my final project in engineering, I had developed a web app for the very first time. We called it “Endorseme”, it was a union of the concept of LinkedIn, eLitmus and Codility. The back end of that web app was written in Django and the front end was written in Bootstrap. I should duly note here that although I was leading that project, I was oblivious to the development of the front end, which turned out to be amazing; thanks to the team: Shubham Darda, Ashish Gaikwad, and Shivam Chanage who delivered better than what I could ever imagine.

Fast forward 3 years, yesterday I set a goal for myself as I took up the #100daysofcode challenge. The goal was to learn ReactJS and other concepts of web development such as browser optimization,  supporting multiple devices, internationalization etc. in greater detail. To save some time I decided to stick with Django as the back end since I already knew my way around that software. Having the backend made in Python also ensured that Surya, building the AI could directly write his code in the back end. This fact reassured my choice of back end as Django.

But boy was I wrong! Little did I knew that with 3 years of gap my comfort zone had become the uncomfortable comfort zone.  The Django API seemed like I am seeing it for the very first time and trivial tasks like account management – which included login and sign up – took a lot longer to figure out. As I mentioned earlier, the front end was never my area of expertise so I chose whatever could help me build two static web pages with least effort. Material design lite swooped in and saved the day. Finally, I was able to put together a basic login and sign up for the movie review web app. I am attaching a screenshot of the webpage here and any web developers/UI/UX designers can recommend any improvements or any trendy designs which I don’t know of.

screenshot from 2019-01-29 18-05-35

 

Finally, from today’s experience, I urge my readers to practice their skills often. It is very easy to get lost in the monotonous humdrum of professional life and let your skills – which you once strived to master – become your uncomfortable comfort zone.

Links of the day: 

  1. Material Design Lite
  2. Django
  3. ReactJS
  4. Movie Recommender

Challenge Accepted

I have signed up for #100daysOfCode challenge, and I have decided to build a website which would recommend movies based on the movies user has previously rated. I am handling everything regarding the website design and my good friend and colleague Surya is helping with the brains of the software, the AI. I will be developing the web for next 100 days but he might finish his work in a month or two. We hope to build something meaningful during this period.

I am optimistic that we will benefit from this exercise and learn something truly meaningful in the domain we chose to work in. I will keep posting the challenges that I face everyday and the solutions I used. I urge the readers of this blog to recommend any solutions or ideas that would help us build a better software. Meanwhile, I also recommend you to go through Surya’s blog to get the remaining picture of the application.

Links of the day:

Abhishek Bera
Suryavamsi Tenneti
Surya’s 100 days ML challenge
Movie Recommendation codebase