Beginning with django tutorials to python3
I heard of this great Chipy mentorship program after attending several local meet-ups on coding including the Braintree location, which I really enjoy. I am fortunate and grateful for having the opportunity to advance in learning python so I can develop more websites and hopefully make a career change into developing.
A simple way to book a last minute reservation for your next dinner or appointment knowing your wait time. I began by completing the django tutorial online. When I hit difficult sections, I wrote down some questions I had with refrences as to where they were but continued to work on it. I completed the tutorial “It all worked” and got the final product with the polls app running. When I went back to my questions, I found answering them was easier after seeing the final result and at times I would answer my own questions later on.
Next, I met with my helpful mentor Adam. He patiently explains everything pertaining to my questions. Sometimes we have to learn from people that have had similar questions; however, He also covers adjacent themes to the question making it better to learn. Being a teacher myself, I see this trait as an asset in anyone helping others. We have met a couple of times so far and each time I have come into the meeting with several goals and left with excellent progress. I put in time each day on my own to learn python/django and progress on my booking project.
Goal: Discuss project and the sky view of how django files work with python
We met and worked on setting up the urls.py, views.py, template directory, and index.html. This was a lot in a hour and half meeting, but we did it. Later, I was able to review this and replicate it on my own. For any beginner this is a bit confusing as we are not used to this structure, but I will try to explain it in a different analogy:
Urls.py in the main root location is a file that tells someone where to look next, almost like a router that routes traffic to the right place. It is similar in function to an information desk at the mall but rather that desk is located at the front door.
Next, usually, urls.py will direct traffic to another urls.py. Why? Well, it narrows it down. So if you have multiple projects (directories or folders), this is useful. Similarly to the mall, the information service desk sends you to a store and that store has it’s own customer service desk showing you your product more specifically. So the root urls.py may forward you to the second urls.py in the new directory for information. Yes, the customer service desk for example at the mall can be given information to tell you where to get your exact product from a shoe store on shelf 3; but, a more organized efficient mall will send you to the shoe store and have the shoe store help you find it.
Goal: Search using two fields and display the results on a different page
We met and went over searching on the index.html and displaying the results of two fields in a form properly on a different post_view.html page. We were able to search using two fields (a drop down menu and a search) and display the results on another page. What took me a couple of hours took only minutes to setup with my mentor which is one reason why this program is so valuable for us mentees. Towards the end as the meeting closed, I decided to take a couple of minutes and review what I had learned by quickly summing up all the steps. We also talked about possibly meeting an additional day to increase our progress so after our third meeting we will hopefully have an additional day added.
Goal: Create models.py and connection to PostgreSQL database
Prior to this third meeting my assignment was to go over the Models tutorial from the djangogirls, and django websites. I completed these and am attempting to make a connection to my database using what I have learned. So I’ve learned that within models.py I can create the object and properties that will be entered into the database. A class is a special keyword that indicates we are defining an object like a car or house. Typically you want to start a class name with an uppercase letter (class Car). Django knows that it should be saved in the database eventually. Then, I was able to make the fields necessary and upon meeting with my mentor we went on to migrate this into the database. I chose to create a users table which would serve as a method of storing usernames, first names, last names and so on.. So just as I went to make my table in the database, Adam said, “there is a magical fast way” and of course I want to know that! We opened the terminal window and typed in this command which I remember seeing in my django tutorials before, “makemigrations” and then “migrate”. After explaining how this creates a directory within our app and how it automatically creates the table columns for us, it was then that I saw how it worked together and made things more automated which I also like. The funny part is that I created a users table and this entire time Adam knew there already was one provided by Django but being a knowledgable mentor he let me find out after I had the experience of creating it myself which would still benefit me because I would need to create more tables the same way later on my own. Furthermore, we looked into the database and I noticed there are tables in django that I hadn’t thought of, such as groups, permissions and so on. So I asked, then what do we have to make? We both laughed. My assignment after today’s meeting is to continue making the other tables and try to create views and queries to display the database results on another webpage.