Admin page on django is broken

前端 未结 5 1043
你的背包
你的背包 2020-12-31 00:48

I\'ve set up a django project with an admin page. It worked perfectly for the first couple weeks of development, didn\'t use the admin page for a while, and when I came bac

5条回答
  •  情歌与酒
    2020-12-31 01:34

    Try this; in tests.py:

    from django.contrib import auth
    
    class AuthTestCase(TestCase):
        def setUp(self):
            self.u = User.objects.create_user('test@dom.com', 'test@dom.com', 'pass')
            self.u.is_staff = True
            self.u.is_superuser = True
            self.u.is_active = True
            self.u.save()
    
        def testLogin(self):
            self.client.login(username='test@dom.com', password='pass')
    

    Then run the test with python manage.py test .AuthTestCase. If this passes, the system is working, maybe look at the username and password to make sure they are acceptable.

提交回复
热议问题