`hasattr(user, 'location_id')` might be cleaner.