No changes detected while running python manage.py makemigrations

Issues:

I want to recreate the migrations, so I deleted files under migrations folder, and drop the database. And try this python manage.py makemigrations, it reponse No changes detected.

Fix:

Create the database again, and clear files and folders under migrations, then try the following:
1. python manage.py makemigrations --empty appname
2. python manage.py makemigrations
3. python manage.py migrate

It works!

阅读全文 ~

ld: library not found for -lssl - Install mysqlclient for Django 2, macos

Background

mysql server was installed by brew install mysql

Issues like this:

ERROR: Failed building wheel for mysqlclient

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?

阅读全文 ~

也谈华为鸿蒙系统 - Thinks About Huawei Hongmeng

linux_android_huawei.jpg

自从华为被ARM和Android"封锁令"一系列负面消息来袭之后,关于华为的鸿蒙系统新闻层出不穷。
另据国家知识产权局商标查询显示,华为今年5月份和6月份申请了商标名称为"鸿蒙"的多个类目商标。这个时间前后也有许多公司和个人开始抢注"鸿蒙"为关键字的不同类目的商标。
其实按照以往的营销策略,一开始大V如华为高管在微博散布消息,之后开始让媒体热炒,再加上用户的跟风等一系列炒作之后,基本上就可以看到具体上线时间了。不过对于研发一款多平台支持的OS来说并不是易事。

阅读全文 ~

Django root url point to app root

In the Django's tutorial, I created an app name front, and its urls.py definition like this:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('front/', include('front.urls')),
    path('admin/', admin.site.urls),
]

So, if the app's url in web browser is http://127.0.0.1:8000/front/
In fact, most website the home page won't have subdirectory. So, the solutions is here:

from django.contrib import admin
from django.urls import path, include, re_path

urlpatterns = [
    re_path(r'^', include('front.urls')),
    path('front/', include('front.urls')),
    path('admin/', admin.site.urls),
]

Now, you can visit the app root url in the home page. http://127.0.0.1:8000/

阅读全文 ~

rsync 用法

sync命令是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。

rsync [OPTION]... SRC DEST
rsync [OPTION]... SRC [USER@]host:DEST
rsync [OPTION]... [USER@]HOST:SRC DEST
rsync [OPTION]... [USER@]HOST::SRC DEST
rsync [OPTION]... SRC [USER@]HOST::DEST
rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
阅读全文 ~

Regex url route in Flask

class RegexConverter(BaseConverter):
    def __init__(self, map, *args):
        BaseConverter.__init__(self, map)
        self.map = map
        self.regex = args[0]


app.url_map.converters['regex'] = RegexConverter

Define a regex route

@app.route('/go/<regex("[a-zA-Z0-9]+"):url>')
def go(url):
    real_url = redis.get(url)
    return redirect(real_url)

阅读全文 ~

Uninstall mongodb in CentOS

1.Stop Mongo DB using -

sudo service mongod stop

or for CentOS7

systemctl stop mongod

2.Remove Packages using -

sudo yum erase $(rpm -qa | grep mongodb-org)

3.Remove Data Directories using -

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo

From: https://stackoverflow.com/questions/8766579/uninstalling-mongo

阅读全文 ~

用ADB删除android系统预装的app (华为EMUI示例)

首先要打开开发者调试。
华为EMUI就是连续按下关于中的版本号。

连线后或者无线状态下adb连上设备。进入adb shell

手机上打开当前需要卸载的应用如华为音乐,在adb shell下执行 dumpsys window | grep mCurrentFocus

再使用命令卸载pm uninstall -k --user 0 com.android.mediacenter

-k 表示保存数据,如不需要,可去掉 -k。
--user 指定用户 id,Android 系统支持多个用户,默认用户只有一个,id=0

其它华为EMUI预装的APP如
com.huawei.himovie 华为视频
com.huawei.phoneservice 用户服务
com.huawei.browser 浏览器

其它可以参考这里https://club.huawei.com/thread-16472503-1-1.html

阅读全文 ~

Using mongodb service in docker-compose.yml

version: '3.1'

services:

  web:
    build: .
    restart: always
    ports:
      - 8080:80
    environment:      
      MONGODB_HOST: mongodb
      MONGODB_USER: root
      MONGODB_PWD: 123456
    depends_on:
      - mongodb

  mongodb:
    image: mongo:4.1
    restart: on-failure
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: 123456
    volumes:
      - ./data/mongo:/data/db
      - ./data/mongo-entrypoint/:/docker-entrypoint-initdb.d/

阅读全文 ~