Skip to main content

Posts

Showing posts from July 16, 2018

How to write test cases for Your Serializers

Lets consider an example. Here is the model setup we are going to use for this example: from django.db import models class Bike ( models . Model ): COLOR_OPTIONS = (( 'yellow' , 'Yellow' ), ( 'red' , 'Red' ), ( 'black' , 'Black' )) color = models . CharField ( max_length = 255 , null = True , blank = True , choices = COLOR_OPTIONS ) size = models . DecimalField ( max_digits = 4 , decimal_places = 2 , null = True , blank = True ) And this is the serializer I'm are going to test: from rest_framework import serializers from bikes.models import Bike class BikeSerializer ( serializers . ModelSerializer ): COLOR_OPTIONS = ( 'yellow' , 'black' ) color = serializers . ChoiceField ( choices = COLOR_OPTIONS ) size = serializers . FloatField ( min_value = 30.0 , max_value = 60.0 ) class Meta : model = B

Artificial Intelligence vs Machine Learning vs Data Science

What is Artificial Intelligence (AI)? Artificial intelligence refers to the simulation of a human brain function by machines. This is achieved by creating an artificial neural network that can show human intelligence. T he primary human functions that an AI machine performs include logical reasoning, learning and self-c 1 orrection. Artificial intelligence is a wide field with many applications but it also one of the most complicated technology to work on. Machines inherently are not smart and to make them so, we need a lot of computing power and data to empower them to simulate human thinking. Artificial intelligence is classified into two parts, general AI and Narrow AI. General AI refers to making machines intelligent in a wide array of activities that involve thinking and reasoning. Narrow AI, on the other hand, involves the use of artificial intelligence for a very specific task. For instance, general AI would mean an algorithm that is capable of playing all kinds of board

How to Assembling a Continuous Integration Service for a Django project on Jenkins

Project installation First of all, let’s clone the project: git clone https://bitbucket.org/suporte_concrete/cs-django-jenkins.git Afterward, create a new Virtualenv* for our project: virtualenv ~/projetos/virtualenvs/blog Activate the Virtualenv: source ~/projetos/virtualenvs/blog/bin/activate *But what is a Virtualenv? It is a tool used to create python isolated environments. That allows us to install the project’s dependencies without interfering on the dependencies from the OS’s global scope. To know more,  visit this site . Install the project’s dependencies:: pip install -r requirements.txt Now that we have our Virtualenv with the needed packages installed, let’s run a command to run our database migrations: python manage.py migrate Once this is done, we can now run our project. Running the project locally To run the project, execute: python manage.py runserver Warning: this command should only be executed in a development environment. If you wish to