Posts

Showing posts from 2020

Raspberry PI USB mount as external drive

I choose NTFS USB Drive as an external storage for my raspberry pi for this you need to install ntfs-3g library if it's not installed sudo apt install ntfs-3g to auto mount usb at boot stage you can add entry to fstab it's always to good to verify your entry before reboot sudo findmnt --verify --verbose run command to get info about your usb lsblk -fp and save UUID for to use in fstab and add following line to your fstab replace XXX with UUID that you saved earlier, and uid is user, and group id that directory will be mounted with ownership of this user and group that you can get from /etc/passwd UUID=XXX /mnt/FOLDERNAME ntfs defaults,auto,uid=1001,gid=1001,rw,nofail,umask=000 0 0

django tagging

django update string value with using existing value

it's possible to use F queries to make updates with using existing values in database, it's quite easy if value is number but when you want to do updates on string values things are getting complicated  a bit Here below I am replacing empty char coming after comma in location field such as London, UK We need to use django's special functions for this purpose F Value and Func from django.db.models import F, Func, Value Developer.objects.filter(location__contains=", ").update(location=Func(         F('location'),         Value(', '), Value(','),         function='replace',     )) Result will be London,UK which is our intended solution