models.Articles.objects.get(pk = pk) giving error

article = models.Articles.objects.get(pk = pk) isnt working
article = models.Articles.objects.all()[pk] but this is working
I didn’t understand what could be the problem
ERROR int the first case:
main.models.Articles.DoesNotExist: Articles matching query does not exist.

Hello @sumit31415, can you pls share your code or the file.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.