[Answer]-How to bypass custom ModelManager in Django models

1๐Ÿ‘

โœ…

You can do it two ways, first. Raw sql

business = Business.objects.raw("Select * from business where id={0}".format(pk))

or if you want to call your managers super class, assuming your custom manager is called BusinessManager

business = super(BusinessManager, Business.objects).get(pk=id)

But as a good practice you should never overwrite the normal objects attribute, that should be kept as is.

0๐Ÿ‘

You can write RAW SQL queries without using django ORM. Just install a library to perform SQL queries directly on your database.

You can also try by writing Raw SQL in Django, but it may not solve your problem : https://docs.djangoproject.com/en/1.6/topics/db/sql/

EDIT : Well it seems I was wrong, it can actually solve your issue : https://docs.djangoproject.com/en/1.6/topics/db/sql/#executing-custom-sql-directly

๐Ÿ‘คRaphael Laurent

Leave a comment