Polymorphism is the ability of an object to take on many forms.
A polymorphic model is used when a single entity requires different functionality or information.
Simply put, abstract instances do not exist. An abstract class is just a way of generalizing information for future children classes. Therefore, the only objects you’ll be able to relate are the children instances, never the parent abstract class.
If you want to relate to the parent abstract class, this is where polymorphic classes come in handy in Django.
I’m currently working on a project where I need classes related with a OneToMany relationship…
Today I want to write about dockerizing a python app, for instance, a python script.
Let’s imagine we want to run this script in different machines and we can’t control what python version they have, or even worse, we don’t know if python is installed or not, and what dependencies they have installed.
Docker helps us separate the code from the infrastructure so this blog post will be about this.
Let’s create a simple python script. We’ll call the file script.py inside a src folder of the project.
#DockerfileFROM python:3.6RUN mkdir /application
Today we’re going to create a Symfony 4 API web app from scratch — I’ll walk you through all the steps, so by the end of this tutorial, you should be able to create, configure and run a web app with API endpoints and protected with JWT authentication.
Also, I’ve uploaded all the source code here so you can follow through the tutorial or you can download the code and play with it while you read.
To set our development environment, we’ll use Docker — you probably already know by now how much I love Docker 🙂
Let’s start by…
In this blog post I’ll talk about Django folders structure inside a project.
After developing a few projects with Django 1.11 and Django 2.0, I’ve stumbled with somewhat an issue that’s been bothering me. When you create projects and apps in Django, as the tutorial shows you, apps will be created inside the main project folder, at the same level of the project’s settings folder (usually it’s the folder that has the same name as your project).
So basically, what you end up with is a container folder and inside has the project config folder, and many other folders with…
Today I’ve had to install Gedmo Translations into a Symfony 4 app and I had some trouble, so after fixing them problems I thought of writing them down in case someone else can benefit from it :)
Let’s start fromt he begginig.
Please use docker! :) More info here in the Docker for Symfony 4 post.
Here’s what my docker.compose.yml looks like
It’s been a while since I wrote anything in the blog.
Today on this short tutorial I’ll explain the steps on how to build an api app with Django, using the JWT (JSON Web Token) as a way to identify users.
Libraries we’ll use are:
So let’s start by creating a Django project with Docker. If you still don’t know how to do that, more info on how to do create a django project with docker here.
Our requirements.txt would something like this:
“Great, I’ve just finished this new feature and it works perfectly, let’s merge it with the rest of the code so the team can now benefit from it..”
git add .
git commit -m "-blablabla"
git flow feature finish "blabla-feature-name"
git push origin develop
“Oops, I forgot to pass tests after closing the feature branch…”
Tests:4... Failures: 1
We’ve all done it before, pushed code that didn’t pass tests…
On this blog post I’ll show you how to set a pre-push script, so every time you push code to your remote repository (develop or master only for…
This blog post is a small guide for getting started with your Django environment with Docker. Since I got very positive feedback from the blog post about Docker and Symfony4, I decided to do the same with Docker and Django.
In this example we’re going to work with Django 1.11 (LTS), Python3 and MySql 5.6
Before we start, you’ll need to install Docker in your machine. You can download it from the official website.
So the other day I was talking to one of our interns on the topic why it’s important to think about security and permissions when writing a backend app, and so I thought, why not write a blog post talking about it.
If you’ve coded a little bit with Symfony, you probably already know that the security component is very useful to secure your app in many ways. There’s different concepts we need to understand before we can talk about voters.
The first part to think of when coding a backend app is authentication.
Wether it’s through a login page…
Hey guys, this post is a follow up from my last phpunit in Symfony2 post. This time I’ve had to install a test environment in a Symfony 3.4 project and I’ve had some weird problems, so I thought of writing this blog post once I solved them all, it may be helpful to someone out there :)
In your symfony project, run the composer require
symfony new my_project 3.4
Now run the phpunit command to run tests.
# if you have the phpunit phar installed globally
# if you use the phar file directly
php phpunit.phar tests/…