More succinct to do...

```python
status_code = 200
if not user_data:
    user_data =  {
        'status': 'error',
        'desc': 'No such user'
    }
    status_code = 404
elif user_data['status'] == 'error':
    status_code = 400

return HttpResponseJSON(user_data, status_code)
```

But if you like your way better I'll not argue.