File tree 1 file changed +2
-14
lines changed
1 file changed +2
-14
lines changed Original file line number Diff line number Diff line change 9
9
from django .utils .translation import gettext_lazy as _
10
10
from django .utils .translation import pgettext_lazy
11
11
12
+ from taggit .managers import NaturalKeyManager
13
+
12
14
try :
13
15
from unidecode import unidecode
14
16
except ImportError :
@@ -17,20 +19,6 @@ def unidecode(tag):
17
19
return tag
18
20
19
21
20
- class NaturalKeyManager (models .Manager ):
21
- def __init__ (self , natural_key_fields : List [str ], * args , ** kwargs ):
22
- super ().__init__ (* args , ** kwargs )
23
- self .natural_key_fields = natural_key_fields
24
-
25
- def get_by_natural_key (self , * args ):
26
- if len (args ) != len (self .model .natural_key_fields ):
27
- raise ValueError (
28
- "Number of arguments does not match number of natural key fields."
29
- )
30
- lookup_kwargs = dict (zip (self .model .natural_key_fields , args ))
31
- return self .get (** lookup_kwargs )
32
-
33
-
34
22
class NaturalKeyModel (models .Model ):
35
23
def natural_key (self ):
36
24
return (getattr (self , field ) for field in self .natural_key_fields )
You can’t perform that action at this time.
0 commit comments