2013-03-03 45 views
8

के साथ ठीक से लॉगिन नहीं करता है। मैंने Django 1.4.5 पर Django 1.5 पर एक ऐप अपग्रेड किया और बस एक कस्टम उपयोगकर्ता मॉडल पर माइग्रेट करना समाप्त कर दिया। जब मैं अपने ऐप में लॉगिन करता हूं, तो अपने सुपरस्युज़र क्रेडेंशियल्स के साथ अपने स्वयं के प्रमाणीकरण फॉर्म का उपयोग करके (manage.py syncdb करते समय बनाया गया) सब कुछ ठीक काम करता है।Django व्यवस्थापक कस्टम उपयोगकर्ता मॉडल

मैं प्रमाणीकृत होने में सक्षम हूं और यदि मैं /admin पर जाता हूं, तो मैं पहले ही लॉग इन हूं, जैसा कि अपेक्षित है। मैं नेविगेट करने और व्यवस्थापक पैनल का पूरी तरह से उपयोग करने में सक्षम हूं। हालांकि, अगर मैं /admin से व्यवस्थापक पैनल के लिए लॉग इन करने के लिए, Django व्यवस्थापक लॉगिन प्रपत्र का उपयोग करके देखें, मैं त्रुटि मिलती है:

Please enter the correct email and password for a staff account. Note that both fields may be case-sensitive.

मैं कुछ की जांच कर रही थी और सोचा था कि यह ModelAdmin के साथ कुछ हो सकता था, इसलिए मैं दस्तावेज़ों से this example का पालन किया और एक कस्टम ModelAdmin बनाया। हालांकि, समस्या अभी भी बनी हुई है।

कोई विचार यह क्या हो सकता है?

+0

आप AUTH_USER_MODEL settings.py में निर्धारित किया है, सही: पर

class CustomUserManager(BaseUserManager): def create_user(self, username, email, password=None): if not username: raise ValueError('Dude you need a username.') if not email: raise ValueError( 'type an e-mail..') new_user = self.model( username=username, email=CustomUserManager.normalize_email(email)) new_user.set_password(password) new_user.save(using=self._db) return new_user def create_superuser(self, username, email, password): new = self.create_user( username, email, password=password ) new.is_active = True new.is_staff = True new.is_superuser = True new.save(using=self._db) return new 

फोकस? –

+0

हाँ, मुझे वह सेट मिल गया है। –

+0

क्या आपने अपने उपयोगकर्ता मॉडल एक्सटेंशन के लिए 'AbstractUser' या' AbstractBaseUser' का उपयोग किया था? –

उत्तर

4

क्या आपने फ़ंक्शन में निम्न पंक्तियां जोड़ दी हैं जो BaseUserManager के अंतर्गत है? यह इस प्रकार दिखाई देंगे:

new.is_active = True 
    new.is_staff = True 
    new.is_superuser = True 
+2

में लॉगिन नहीं कर सकते हैं django के व्यवस्थापक 'request.user.is_active' और 'request.user.is_staff' के लिए उपयोगकर्ताओं को लॉग इन करने के लिए चेक करता है, इसलिए मुझे लगता है कि उसे जोड़ना चाहिए उस सूची में 'new.is_active = True' "पर ध्यान केंद्रित करें। – AJJ

संबंधित मुद्दे