예제 #1
0
	def test_valid_sellerprofile_creation(self):
		data = {
			'seller_name': 'testname','location': 'Heaven',
			'phone_number': 12312352,'payment_type': [self.cash.pk],
			'home_delivery': 'ALL','meetup': True,
			'details': 'Blahblah',
			}
		form = SellerProfileForm(data=data)
		print form.errors
		self.assertTrue(form.is_valid())
		response = self.c.post(reverse('shop:create_sellerprofile'),data=data)
		self.assertEqual(response.status_code, 302)
		self.assertEqual(SellerProfile.objects.count(), 1)
예제 #2
0
def create_sellerprofile(request):
	if request.method=='POST':
		form = SellerProfileForm(request.POST, request.FILES)
		if form.is_valid():
			sellerprofile = form.save(commit=False)
			sellerprofile.user = request.user
			if 'image' in request.FILES:
				sellerprofile.image = request.FILES['image']

			sellerprofile.save()
			form.save_m2m()
			return redirect('index')
		else:
			print form.errors
	else:
		form = SellerProfileForm()
	return render(request, 'shop/create_sellerprofile.html', {'form': form})