Posts

Showing posts from July, 2020

how to pass data from One component to other component

https://www.smashingmagazine.com/2020/01/data-components-vue-js/#propos-share-data-parent-child

How to integrate google Custom Marker Map with Vue Js Project

vuejs setup -  https://medium.com/@xon5/vue-google-maps-c16da293c71 javascrip setup -  https://developers.google.com/maps/documentation/javascript/custom-markers Custom icons link -  http://kml4earth.appspot.com/icons.html

how to Check if value already exists or not within list of dictionaries?

Example; a = [{ 'main_color' : 'red' , 'second_color' : 'blue' }, { 'main_color' : 'yellow' , 'second_color' : 'green' }, { 'main_color' : 'yellow' , 'second_color' : 'blue' }] if any ( d . get ( 'main_color' ) == 'red' for d in a ) : //if value is exit returns true else: //false

How to Dump CSV File Into Influxdb Using Python Code.

from influxdb import InfluxDBClient  import pandas as pd client = InfluxDBClient('localhost', 8086, 'root', 'root', 'dbname') file_name=open("local system file path") csv_reader=pd.read_csv(file_name) for y in csv_reader.iterrows():         sid = y [1][0]         name=         node=         nodeid = y[1][1]         sensorid = y [1][2]         status = y[1][3] json_body = [             {                 "measurement": "feeddata",                 "tags": {                         # 'name':name,                         # 'node': node,                   ...

how to write Query Parameters In Django

This is for freshers like me, Those who are strugle with how send data based on Request query params in django. TYPE-1: http://localhost:8000/api/abscs/?id=2 userid = request.query_params.get("userid") result is saved on userid= "2" TYEP-2: http://127.0.0.1:8000/aAF/?status=omn&status=aad which will correctly give you ['omn','aad'] when you use request.GET.getlist('status')

How to Add Random Password Generate In Python

import random  import string # pwd = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(8))

queryset values into list

Django values_list vs values Article.objects.values_list('id', flat=True) # flat=True will remove the tuples and return the list [1, 2, 3, 4, 5, 6] Article.objects.values('id') [{'id':1}, {'id':2}, {'id':3}, {'id':4}, {'id':5}, {'id':6}] how to convert queryset into list of values Nodes.objects.filter(id=data_id[x]['portal_node'] ).values_list('sensors', flat=True)

OperationalError, no such column. Django

Step 1: Delete the db.sqlite3 file. Step 2 : $ python manage.py migrate Step 3 : $ python manage.py makemigrations Step 4: Create the super user using $ python manage.py createsuperuser new db.sqlite3 will generates automatically

Design Django Admin For Specific Model

Using Django auth UserAdmin for a custom user model from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.utils.translation import gettext_lazy as _ from .models import * class PortalAdmin(UserAdmin):     fieldsets = (         (None, {'fields': ('username', 'password')}),         (_('Personal info'), {'fields': ('first_name', 'last_name', 'email', 'mobile_number', 'portal_site',                                          'portal_node')}),         (_('Permissions'), {'fields': ('is_active', )}),         (_("Role"), {'fields': ('is_superuser', 'is_site_user', 'is_portal_user')}),         (_('Important dates'), {'fields': ('last_login', 'date_joined')}),     )     add_fieldsets = (       ...