If the idea here is that the name may be empty, a nicer way to say it is 

app_name = app.name or ''

getattr is 'scary' and 'dangerous' and should be avoided unless absolutely necessary.