Fixed #23616 - AttrbuteError in BaseModelAdmin.lookup_allowed() fix

Added check if hasattr(), else, param is set to None to avoid AttributeError.
See https://code.djangoproject.com/ticket/23616