пятница, 25 декабря 2020 г.

Django rest first application, Show Post RetrieveAPIView. Part 4



github
https://github.com/manas-anarov/django_3_ninja/tree/4_part



blog/views.py
from .serializers import (
    ListSerializer,
    AddSerializer,
    ShowSerializer,
)


from rest_framework.generics import (
    ListAPIView,
    CreateAPIView,
    RetrieveAPIView,
)

from blog.models import Post

class ShowPost(RetrieveAPIView):
    queryset = Post.objects.all()
    serializer_class = ShowSerializer
    lookup_field = 'id'



blog/serializers.py
class ShowSerializer(ModelSerializer):
    class Meta:
        model = Post
        fields = [
            'id',
            'title',
            'text',
        ]




blog/urls.py
urlpatterns = [
    path('list/', views.PostListAPIView.as_view(), name='blog-list'),
    path('add/', views.AddPost.as_view(), name='blog-add'),
    path('<id>/', views.ShowPost.as_view(), name='blog-show'),
]


open link
http://localhost:8000/api/v1/post/list

show one post
http://localhost:8000/api/v1/post/1

Upload files to django rest framework using react native

Uploading file using api in django rest framework. PythonAnywhere
https://youtu.be/BLN3EPjxQ_E



App.js
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Button,
} from 'react-native';
 
export default class MyApp extends Component {
 
 
  upload_image_to_django (){
 
    PicturePath = "file:///storage/emulated/0/Download/myfoto.jpg";
    URLpath = "http://manas93.pythonanywhere.com/file/upload/";
 
    var formData = new FormData();
    formData.append("file", {uri: PicturePath, name: 'myfoto.jpg', type: 'image/jpg'});
    formData.append("remark", "Hello");
 
    fetch( URLpath, {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'multipart/form-data',
      },
      body: formData
     })
    .then((responseJson) => {
      console.log(responseJson);
    })
    .catch(error => {
      console.log(error);
    })
 
  }
 
  render() {
    return (
      <View style={styles.content}>
      <Button       
        title="My Button"
        onPress={this.upload_image_to_django}
      />
      </View>
    );
  }
 
}
 
var styles = StyleSheet.create({
    content:{
        flex:1,
        flexDirection:'row',
        alignItems:'center',
        justifyContent:'center'
    }
});

Django rest first application, Create Post CreateAPIView. Part 3




github
https://github.com/manas-anarov/django_3_ninja/tree/3_part



blog/views.py
from .serializers import (
    ListSerializer,
    AddSerializer,
)

from rest_framework.generics import (
    ListAPIView,
    CreateAPIView,
)

from blog.models import Post


class AddPost(CreateAPIView):
    serializer_class = AddSerializer
    queryset = Post.objects.all()




blog/serializers.py
lass AddSerializer(ModelSerializer):
    class Meta:
        model = Post
        fields = [
            'title',
            'text',
        ]



blog/urls.py
urlpatterns = [
    path('list/', views.PostListAPIView.as_view(), name='blog-list'),
    path('add/', views.AddPost.as_view(), name='blog-add'),
]

open link
http://localhost:8000/api/v1/post/list

create post
http://localhost:8000/api/v1/post/add

понедельник, 21 декабря 2020 г.

Django rest first application, Show All Posts ListApiView. Part 2



open project folder
cd django_3_ninja


activate
pipenv shell


open folder
cd ninja_django


create app
python manage.py startapp blog


settings.py
INSTALLED_APPS = [
    'blog',
]



blog/models.py
from django.db import models

class Post(models.Model):
    timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)
    title = models.CharField(max_length=200)
    text = models.CharField(max_length=500)

    def __str__(self):
        return self.title



blog/views.py
from .serializers import (
    ListSerializer,
)

from rest_framework.generics import (
    ListAPIView,
)

from blog.models import Post

class PostListAPIView(ListAPIView):
    serializer_class = ListSerializer
    queryset = Post.objects.all()



blog/serializers.py
from rest_framework.serializers import (
    ModelSerializer,
)
from blog.models import Post

class ListSerializer(ModelSerializer):
    class Meta:
        model = Post
        fields = [
            'id',
            'title',
            'text',
        ]



ninja_django/urls.py
from django.contrib import admin
from django.urls import path
from django.conf.urls import include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/post/', include(('blog.urls', 'blog'), namespace='blog')),
]


blog/urls.py
from blog import views
from django.urls import path

urlpatterns = [
    path('list/', views.PostListAPIView.as_view(), name='blog-list'),
]


install djangorestframework
pipenv install djangorestframework


settings.py
INSTALLED_APPS = [
    'rest_framework',
]


blog/admin.py
from django.contrib import admin
from blog.models import Post

admin.site.register(Post)


create db
python manage.py makemigrations;
python manage.py migrate;


start server
python manage.py runserver;

create admin user
python manage.py createsuperuser

create post
http://localhost:8000/admin

open link
http://localhost:8000/api/v1/post/list

github
https://github.com/manas-anarov/django_3_ninja/tree/2_part

вторник, 15 декабря 2020 г.

Django rest first application, install Django3. Part 1






install virtual envoirment
pip3 install pipenv

create  folder
mkdir django_3_ninja;
cd django_3_ninja
;

install env for project
pipenv install

activate
pipenv shell

install django

pipenv install django~=3.1.4


start django project
django-admin startproject ninja_django;

cd ninja_django;



start server
python manage.py runserver;

 

open next link

http://127.0.0.1:8000/


github

https://github.com/manas-anarov/django_3_ninja/tree/1_part







суббота, 12 декабря 2020 г.

Python Developers (Mid/Senior). Location: Wroclaw

 























We are looking for Python Developers (Mid/Senior).
Ulam Labs (https://ulam.io) is a software house located in Wroclaw and Warsaw. We deliver top software for customers in various industries (blockchain & fintech, telco, production, etc.) mainly in Western Europe and North America.
Currently, we are more than 20 great people strong and specialize in web applications, mostly written in Python and Javascript.
👉 Who: Software House
🌍 Location: Wroclaw
✍️ Employment Type: B2B/UoP
💰 Salary: 7-19k PLN
🤓 Requirements:
➡️ 2+ years of experience in developing web applications using Python 2 or 3
➡️ Experience in at least one modern Javascript framework (Angular, React, or Vue)
➡️ Fluent in English with great communication skills

(c) Barbara Trybulińska(Denisiuk)

Python Team Lead Location: Cyprus, Limassol (Remote/Relocate)

 


На изображении может находиться: океан, небо, пляж, на улице, природа и вода, текст «Python Pytoneaeadjob Team Lead job relocation to Cyprus ©Franco Franco Cappellari» 

Python Team Lead

A product fintech company is looking for Python Team Lead who will lead the Product Development Team and manage the team performance.
Salary: 4000-6000 euro net + bonus
Location: Cyprus, Limassol (Remote/Relocate)
Fulltime/ office
Responsibility:
Full management of the Product Development Team:hiring, onboarding, analyzing, planning, developing, cooperating with a product owner
Qualifications:
⁃5-6 ears of experience in software development (from 2 years Python)
⁃Experience in people management from 1+ years
⁃Experience with Django or others frameworks
⁃Good knowledge of the full-cycle of software development. (Experience in big enterprise companies as a plus).
⁃Fluent written and spoken English and Russian.
We offer:
⁃Relocation package (visa, tickets ant etc.) for a candidate and his/her family
⁃Work permit support
⁃Medical insurance for employees, and family
⁃Different relocation connected costs compensations
Contacts:
@Marina_Pelikh
m.chetverikova@clever-recruiting.com