def setUp(self): self.testfiles = ["test.png", "test2.png"] self.testdires = ["중국에서"], ["베이징"] self.username = "******" user = User.objects.create(username=self.username) user.set_password("1234") user.save() f = Family() f.user = user f.motto = "Live is short, you need python" f.save() self.user = user fm = FamilyMember.objects.create(family=f, position="관리자", name="관리자") fm.save() from shutil import rmtree Album.objects.create(title=self.username, parent_album=None, family=f) """ try: except FileNotFoundError: pass """ self.f = RequestFactory()
def register(request): if request.method == 'POST': data = request.POST try: user = User.objects.create_user(username=data['username'], password=data['password']) except: return render(request, 'register.html', {"message": u"회원가입에 실패했습니다. 다른 아이디로 시도해 주세요."}) f = Family() f.user = user f.motto = data['motto'] f.save() Album.objects.create(title=data['username'], parent_album=None, family=f, memo=f.motto) return render(request, 'login.html', {"message":u"회원가입 성공"}) else: return render(request, 'register.html')
def register(request): if request.method == 'POST': data = request.POST try: user = User.objects.create_user(username=data['username'], password=data['password']) except: return render(request, 'register.html', {"message": u"회원가입에 실패했습니다. 다른 아이디로 시도해 주세요."}) f = Family() f.user = user f.motto = data['motto'] f.save() Album.objects.create(title=data['username'], parent_album=None, family=f, memo=f.motto) return render(request, 'login.html', {"message": u"회원가입 성공"}) else: return render(request, 'register.html')
def setUp(self): self.testfiles = ['test.png', 'test2.png'] self.testdires = ['중국에서'], ['베이징'] self.username = '******' user = User.objects.create(username=self.username) user.set_password('1234') user.save() f = Family() f.user = user f.motto = 'Live is short, you need python' f.save() self.user = user fm = FamilyMember.objects.create(family=f, position="관리자", name="관리자") fm.save() from shutil import rmtree Album.objects.create(title=self.username, parent_album=None, family=f) """ try: except FileNotFoundError: pass """ self.f = RequestFactory()