Sunday, April 5, 2020

Opinion: Rails vs. Django

 Opinion: Rails vs. Django


Disclaimer: This is an ongoing piece. I'm probably going to be adding to it as time goes on.

So I spent 9 weeks at LeWagon Coding Boot Camp learning Rails. It's a wonderful framework that is easy to learn on. However, prior to my time at LeWagon my experience in coding has all been from a mathematical perspective. Because of that I'm much more comfortable writing in Python, not because of the language syntax (though I do like Python syntax better), but because there are a lot of math abilities built into Python that don't exist in Ruby. Anyway, this is my breakdown of the differences between Rails and Django, even though I might be a novice in both.

Ruby on Rails and Python + Django are very similar. They both pretty much have an MVC model (Django is technically Model - View - Template, but not much different there), and both Python and Ruby are high level, dynamically typed, scripting languages that share a lot of common syntax.

MUCH faster to get started. I only need one terminal command to get started. This one command sets up the database, installs webpacker, and installs all the gems I might need. For this I like to use Le Wagon's boiler plate.

Django is much slower at getting started. It took me a good long while to figure out how to get my databases set up.

Django is also much more "segmented" than Rails. When you start a project you also need to create Apps. In most smaller projects you probably only use one app, but bigger projects should be using multiple apps. These apps are simply ways to organize your code better.

While Django may be more complicated to start off with, one thing that really impresses me is the Admin site. If you go to [your url]/admin you get a nice pre-made site to take care of the administration of the website. Here you can manage users, create posts, and other administrative tasks (not related to coding).

These are just my preliminary thoughts, I'll be adding more soon.

Tuesday, March 31, 2020

Django Quickstart Guide

django


It may seem like I’m writing this for you, but I’m actually writing it for myself. I’m writing this so that I can better understand what I’m doing and digest the material by explaining it. Also, when I write this down it serves as notes. I’ve often written material that looks like technical writing, but is in fact a tutorial for me to look back at later.

Getting Started


First thing is to create a virtual environment. We do this so that our Python packages are localized instead of installed system wide. We do this to reduce the risk of conflicting packages, it’s easier to release, and it’s easier to switch to another Python interpreter.

First install virtualenv (on Linux):
$ sudo apt install python3-venv


Create your virtualenv:
$ python3 -m venv .env



You can name your virtualenv whatever you’d like. I prefer to call mine .env because it’s simple and hidden. This is also the naming convention from RealPython. Others prefer to call it the same name as their project.


Activate your virtualenv:
$ source .env/bin/activate



Install Django:
$ pip3 install django



Create Project:
$ django-admin startproject ‘PROJECT NAME’ .



Create a project app:
$ python3 manage.py startapp ‘APP NAME’



Run your Django server:
$ python3 manage.py runserver



In the browser navigate to http://localhost:8000 and you will see the django is up and running. Open your favorite IDE. The barebones project has been created for you. This would also be a great time time make your initial push to Github (or Gitlab or whatever you prefer).


Register the App



Navigate to ‘PROJECT NAME’/settings.py in your editor. You should see an array called INSTALLED_APPS. Add to the end of the array your app, APP NAME.











The app I’m adding in this case is called ‘blog’

Build Routes



Navigate to ‘PROJECT NAME’/urls. You can see how Django is directing traffic within the urlpatterns array. We want to create new paths that will direct to our new app(s).





If you go to http://localhost:8000/’PROJECT NAME’ you will see that nothing shows up, even though you registered your app in the previous step. In order to get this to work we need to build routes.





Django tells us how to do this:
if I’m adding a blog it’s going to look like this:




However, if you try to navigate to your project it still won’t work. If you check your terminal where your Django server is running you will see an error that says:

ModuleNotFoundError: No module named ‘blog.urls’



This is because we don’t have a file named blog/urls. So we need to create it.


This by itself isn’t enough to solve the problem. We need to configure it!

The new urls.py file looks very similar to ‘PROJECT NAME’/urls.py, but it’s going to be a little different.
remember that my app name is ‘blog’, yours might be called something different.



Right now I’m still getting an error in the terminal saying
AttributeError: module 'blog.views' has no attribute 'blog'

So I’m going to navigate to blog/views.py where I’ll need to create the blog_list function


Now this still doesn’t work because we don’t have any templates, meaning there’s no HTML for the browser to read. So if we go to localhost:8000/blog we will get an error that says:

Creating a Template



First thing to do is to add some functionality to our function blog_list.


This will still render a ValueError at /blog/ error as shown above. This is because we don’t have any HTML/CSS yet!





Inside of the blog directory I will make 2 new folders with a file inside:templates/blog/index.html


At this point we can go into index.html and start doing some HTML formatting. However, we’re going to wait on that.

Models



If you want to make a website that’s more than just static pages you’ll want to use a database. Models are how Django interacts with a database. Each database table has its own model. Sometimes tables need to reference each other. This tutorial doesn’t get into that, but will be discussed at another time.

Basically, a model is a class object that converts into SQL language. Different projects will require different types of models. For more information see Django Docs.

Different projects will require different types of models. This topic will be discussed in another post.

Wednesday, January 16, 2019

PiCademy

This article is taken from my other website wolf-math.com, while that website is about to be overhauled. Originally Posted July 29, 2017. 

PiCademy


This last weekend I had the wonderful opportunity of attending Picademy in Ann Arbor, Michigan. Picademy is a two day professional development workshop that teaches teachers how to unlock the capabilities of the Raspberry Pi single board computer.

While I’ve been using the Raspberry Pi for quite a while now, I’ve never been able to make the leap to physical computing. I’ve always wanted to be able to make robots and play with sensors and other gadgets that I knew the Pi was capable of doing, but I never knew how. In the past I taught programming in a very dry way. I expect my teaching to be very different this year from previous years. Students will be more focused on what they can make with programming instead of doing assignments in programming.
I’m really looking forward to this year and seeing what my students will accomplish.

If you’re in the giving mood, please help make sure my students have the materials they need to succeed. Donations of any size will help my students, and right now any contribution you make will be doubled by Tom’s of Maine. https://www.donorschoose.org/project/stem-physical-computing-with-raspberry-p/2664110/

What is Standardization?

This article is taken from my other website wolf-math.com, while that website is about to be overhauled. Originally Posted January 4, 2017.

What is Standardization?


During my break I’ve been thinking about the nature of school. I’ve read a lot of articles and I see a lot of posts on social media about the nature of education. The basic gist is that everybody is unique, therefore standardization is bad. This is a bit of an oversimplification, but, generally speaking, I think it’s a true statement.

Before the 1800’s Education was not free. Only elite families were able to pay for their children to attend schooling. So, in centuries past if you were a farmer, then your children were certainly also going to be farmers. The occupation of the parent was the future occupation of the child. Education was the job of the parents to impart onto their children, and only education pertinent to the occupation was going to be transmitted. Now this was not a very good system because it removed a great deal of free choice from the children since they could not choose their own occupation.
Enter public schooling:

Education was now something that was accessible (and required) to everyone; not just the elites. It’s true that students in those early public classrooms were not worried about Common Core but there was still a standardization in the classroom. There was a basic 3rd grade curriculum which differed from the basic 4th grade curriculum. Even in the workplace, when you get a new job there are certain policies and procedures that you’re expected to conform to. Even in the days prior to public schooling, the child who was destined to be a farmer was taught the “right way” to farm by his parents. Basically what I’m getting at is that everywhere there is some sort of standardization whether it be in school or home or the workplace.
So I’ll leave off with some open questions. Where do we draw the line? At what point is education too standardized? What is considered the right amount of standardization?
Leave a comment below.

Standardization

This article is taken from my other website wolf-math.com, while that website is about to be overhauled. Originally Posted February 22, 2016.

Standardization

I’ve had a lot on my mind to post about. I’ve just been too busy to actually post anything. A lot of exciting things are happening right now. However, I wanted to discuss a little bit of the opposite of that.

I just finished the Resident Educator Summative Assessment, or RESA for short (I love how this stupid buzzword “summative” still gets caught by my spell check).  In Ohio newly licensed teachers are required to go through a residency program. During this time the “resident educator” is paired up with a mentor teacher who helps guide the new and inexperienced teacher.

It’s a great idea… except it doesn’t work. The Ohio Department of Education is a bureaucracy. Therefore, in place of having a guiding figure to help and support new teachers, they get a standardized “test”. While it’s not a test per se, it’s the closest equivalent there is to having a teacher take a Common Core test. We’re required to record our classrooms, reflect on the lessons taught in the recording, submit evidence about our marking, and submit evidence that we communicate with parents, among other things. This, of course, is without any sort of feedback– which is quite hypocritical to say the least.

There is no evidence submitted, however, that a mentor has actually helped me out. In fact, in the 3 years I’ve been doing this, I’ve met my 3 different mentors only a handful of times (one of them I don’t want to ever meet again).
I’m not really complaining about all the work that I have to do (well I am, but it’s not the main point), I’m complaining about the system. This “system” that has been plaguing students and parents since NCLB was passed- the system which is only getting worse with Common Core- is now creeping its way up to assessing the teachers too. This “Summative Assessment” (seriously try spell checking it!) is just another hoop to jump through that doesn’t truly assess the quality of the educator.

Going through this process has made me wonder what’s next. Will something else come up in the future that will require even more of me and my peers? I don’t know, but I’ve seen people get dissuaded from the profession because of RESA, and although I don’t see myself actually leaving the profession anytime soon, I can’t deny that RESA has made me think about it.

Critical Thinking

This article is taken from my other website wolf-math.com, while that website is about to be overhauled. Originally Posted January 25, 2016.

Critical Thinking

Well here I am, still waiting for my computer lab pieces to come in. I’ve been having meetings with a lot of different people who are all giving me really great ideas on how to create this custom class exactly the way I want, but alas, here I am still teaching pencil to paper.
Perhaps it’s my own impatience, but my students’ questions have started to become my own, and I’m beginning to ask myself “what is the point of this.”
For most of us, the way that we do mathematics in the classroom is not the way we use mathematics in the real world. It’s cool how we can create an equation for pretty much anything, but that’s not how most of us approach it in real life. As a commenter correctly pointed out in a recent post, logarithms are used in every day life when we say things like “I make six figures.” While that may be true, I can’t legitimized a whole unit on logarithms– the meaning, properties, change of base, logarithmic equations– based on the fact that “I make six figures”.

The truth is that I’ve had misconception about my job, as I think a lot of educators do. I’m not a math teacher so that I can teach mathematics; I’m a math teacher to teach critical thinking skills. Actually, no teacher teaches in order to impart random facts onto students that the government deems important for them to know. All teachers, no matter their content, teach for the sake of imparting critical thinking, a love for learning, and method for communicating what they’ve learned. After all remembering is the lowest rank of Bloom’s Taxonomy.

As a math teacher I think my job is made difficult because mathematics is so hard to relate to the real world in meaningful ways, as opposed to some contrived word problem. Even if math is taught in a pure math type of way, many students don’t have the type of minds to be able to appreciate that.
This is why I’ve been obsessing over computer science lately. I think I’ve finally found a way to engage students the logical problem solving. We’ll see how it goes!

Performing Vs. Learning

This article is taken from my other website wolf-math.com, while that website is about to be overhauled. Originally Posted January 7, 2016.

Performing vs. Learning

I’ve been thinking a lot about the difference between performing versus learning. This seems to come up more in math than other subjects due to the obscure nature of mathematics– we always need to legitimize why students need to learn it. That’s its own conversation.


Performing is students completing a task correctly in a timely manner. Performing makes “teaching” easier. Tests and homework can be graded– we can score the student on how she has performed by giving her a letter grade. This is a metric that we have been using for decades to show what a student knows. However, everybody has had their easy teachers and their hard teachers, whether in math or in some other subject. Because of this there is an inherent problem with assessing students with this metric. Different students may have different grades for doing the same work.

Posing an equal and opposite problem is standardized testing. Students are taught to perform tasks, mathematical or otherwise, and get the correct answers. It is, for the most part, procedural thinking. The Common Core was intended to do away with this procedural method of thinking and have students actually learn instead of doing meaningless procedures. Due to the nature of The Common Core being standardized and the requirement to assess millions of students on their progress, students now need to jump through hoops by doing procedures that are more meaningless than they were in the first place.
Learning is much different than performing, especially with mathematics. We teach math that it’s about getting the correct answers, but it really shouldn’t be. The end goal should be that students get the correct answers, but the correct answers should be based on a learning experience that expands their thinking– there are a lot of methods of obtaining the correct answers.
What methods do we use to make sure that students are learning instead of just performing? I’ve got some ideas, but I’ll save them for later. Make sure you’ve seen my previous post: Thoughts from Winter Break.

Opinion: Rails vs. Django

 Opinion: Rails vs. Django Disclaimer: This is an ongoing piece. I'm probably going to be adding to it as time goes on. So I spent ...