[linux]编译 aria2c 时,出现 C compiler cannot create executables 错误

Date Category linux Tags linux

编译安装 aria2c 时,出现了如下错误:

[root@dev aria2-1.17.1]# ./configure
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/root/temp/aria2-1.17.1':
configure: error: C compiler cannot create executables
See `config.log' for more details

解决办法: 清空 LIBS 及 CFLAGS 变量的值 ...

more ...



[django]让后台新增用户的表单包含 email 字段

默认情况下,后台新增用户的表单不包含 email 字段。 每次新增用户后都需求再次修改新增的用户来添加 email 地址。

本文将实现在新增用户的同时将 email 地址也加上,一次完成用户添加,省去一个步骤。

默认情况下:

before

本文将实现:

after

在应用目录下修改/新建 admin.py:

from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin


class MyUserAdmin(UserAdmin):
    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('username', 'email', 'password1', 'password2')
        }),
    )

admin.site.unregister(User)
admin.site ...
more ...

[django]list_display 中包含外键内的字段

本文将实现 list_display 中包含外键内的字段,同样适用于自定义要显示的列。

比如包含 User 中的 email 地址。

image

admin.py:

class HelloAdmin(admin.ModelAdmin):
    list_display = ('user', 'user_email', 'role')
    # ...

    # 显示用户邮箱地址
    def user_email(self, obj):
        return u'%s' % obj.user.email
    user_email.short_description = u'邮箱'

admin.site.register(Hello, HelloAdmin)

参考

more ...