\(\displaystyle \mathbf{E}= \frac{1} {4\pi\epsilon_0} \frac{q}{r^2} \hat r\)

\(\displaystyle \mathbf{\nabla} \cdot \mathbf{E} = \frac{1}{r^2} ~ \frac{\partial (r^2E_r)}{\partial r} + \frac{1}{rsin\theta} ~ \frac{\partial (E_{\theta}sin\theta)}{\partial{\theta}} + \frac{1}{rsin\theta} \frac{\partial E_{\phi}}{\partial{\phi}}\)

\(\displaystyle E_{\theta} ~and~ E_{\phi}\) will be zero and \(\displaystyle r^2 E_r = \frac{1}{4\pi\epsilon_0}q\)

\(\displaystyle \mathbf{\nabla} \cdot \mathbf{E} = \frac{1}{r^2} \frac{\partial kq}{\partial r}~~~~~~~~~~~~~~~~~~~~~~~~~~~, k= \frac{1}{4\pi\epsilon_0} \)

The derivative of a constant is zero and therefore

\(\displaystyle \mathbf{\nabla} \cdot \mathbf{E} = 0\)

But I have studied that \(\displaystyle \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}\). Why there is a discrepancy? I have worked out the divergence from the it's very definition.