From 4fbeec56313e4171e864b8c62f5548f82b8249f1 Mon Sep 17 00:00:00 2001
From: twidi <s.angel@twidi.com>
Date: Sat, 15 Nov 2014 15:52:35 +0100
Subject: [PATCH] [1.7.x] Reordered condition to avoid calling allow_migrate()
 if unneeded.

Backport of 82aca216e130973d142473ebb4b22d1eae146ec7 from master
---
 django/db/migrations/operations/base.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/django/db/migrations/operations/base.py b/django/db/migrations/operations/base.py
index d3af9c5903..8d2c491add 100644
--- a/django/db/migrations/operations/base.py
+++ b/django/db/migrations/operations/base.py
@@ -104,10 +104,10 @@ class Operation(object):
         if it's a proxy, if it's managed, and if it's swapped out.
         """
         return (
-            router.allow_migrate(connection_alias, model) and
             not model._meta.proxy and
             not model._meta.swapped and
-            model._meta.managed
+            model._meta.managed and
+            router.allow_migrate(connection_alias, model)
         )
 
     def __repr__(self):