boyutu 1 byte den küçük olanları sil
find . -size -1b -exec rm -rf {} \;
tarihi bugünden eski planları sil
find . -daystart -type f -mtime 1 -exec rm -f {} \;
find . -size -1b -exec rm -rf {} \;
find . -daystart -type f -mtime 1 -exec rm -f {} \;
SELECT datname,procpid,current_query FROM pg_stat_activity;
SELECT pg_cancel_backend(pid of the postgres process);
class RoomInline(admin.TabularInline):
model = Room
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
field = super(RoomInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
if db_field.name == 'inside_room':
if request._obj_ is not None:
field.queryset = field.queryset.filter(building__exact = request._obj_)
else:
field.queryset = field.queryset.none()
return field
class BuildingAdmin(admin.ModelAdmin):
inlines = (RoomInline,)
def get_form(self, request, obj=None, **kwargs):
# just save obj reference for future processing in Inline
request._obj_ = obj
return super(BuildingAdmin, self).get_form(request, obj, **kwargs)