Example #1
0
    def perform_update(self, serializer):
        print(self.request.data)
        instance = self.get_object()
        if self.request.data.get('categories', None):
            categories = self.request.data.copy().pop('categories')
            if categories:
                instance.categories.clear()
                for category in categories:
                    instance.categories.add(category)

        # todo update (create if not available) address [city, pincode, street, lat, lng]
        city = self.request.data.get('city', None)
        pincode = self.request.data.get('pincode', None)
        street = self.request.data.get('street', None)

        # todo PROBLEM : Address is not saving.
        if city or pincode or street:
            print('hi')
            if instance.address:
                address = instance.address
                print('hii2')
            else:
                address = Address(city=city, pincode=pincode, street=street)
                address.save()
                instance.address = address
        instance.save()
        print(instance.address)

        serializer.save()
Example #2
0
def index(request):
    if request.method == "POST":
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        email = request.POST['email']
        dob = request.POST["dob"]
        phone = request.POST["Phone"]
        age = request.POST["Age"]
        gender = request.POST["gender"]
        father_name = request.POST["fathername"]
        mother_name = request.POST["mothername"]
        husband_name = request.POST["husbandname"]
        grandfather_name = request.POST["Grandfathername"]
        father_citizen_number = request.POST["fathercitizennumber"]
        mother_citizen_number = request.POST["mothercitizenshipnumber"]
        husband_citizen_number = request.POST["husbandcitizenshipnumber"]
        birth_certificate_photo = request.POST["birthcerificatephoto"]
        father_citizenship_photo = request.POST["fathercitizenship"]
        mother_citizenship_photo = request.POST["mothercitizenship"]
        husband_citizenship_photo = request.POST["husbandcitizenship"]
        zone = request.POST["Zone"]
        district = request.POST["District"]
        village = request.POST["Village/Municipality"]
        ward = request.POST["Ward no"]
        tole = request.POST["Tole"]
        house_no = request.POST["House no."]
        address_type = request.POST['address_type']

        citizen = Citizen(first_name=user.first_name,
                          last_name=user.last_name,
                          email=user.email,
                          dob=dob,
                          phone=phone,
                          age=age,
                          gender=gender,
                          father_name=father_name,
                          mother_name=mother_name,
                          husband_name=husband_name,
                          grandfather_name=grandfather_name,
                          father_citizen_number=father_citizen_number,
                          mother_citizen_number=mother_citizen_number,
                          husband_citizen_number=husband_citizen_number,
                          father_citizenship_photo=father_citizenship_photo,
                          mother_citizenship_photo=mother_citizenship_photo,
                          husband_citizenship_photo=husband_citizenship_photo)
        address = Address(zone=zone,
                          district=district,
                          village=village,
                          ward=ward,
                          tole=tole,
                          house_no=house_no,
                          address_type=address_type)
        citizen.save()
        address.save()
        message.success(request, "Your form has been submitted to the admin")
        return redirect('index')

    else:

        return render(request, 'pages/index.html')
Example #3
0
def update(request):
    id = request.POST["idx"]
    #수정 처리
    addr = Address(idx=id,
                   name=request.POST['name'],
                   tel=request.POST['tel'],
                   email=request.POST['email'],
                   address=request.POST['address'])
    addr.save()
    return redirect('/address')
Example #4
0
def insert(request):
    # Post 방식을 request.POST('파라미터'), request.GET('파라미터')
    addr = Address(name=request.POST['name'],
                   tel=request.POST['tel'],
                   email=request.POST['email'],
                   address=request.POST['address'])

    #입력 처리
    addr.save()
    return redirect(
        '/address')  #import 하겠냐고 나온다 (왼쪽에 빨간 전구모양 나오면 Alt+Entr 눌러서 import 해주기)
Example #5
0
 def update_address(self, address, prefix):
     if address is None:
         address = Address()
     address.update_address(
         address1=self.cleaned_data[prefix + 'address1'],
         address2=self.cleaned_data[prefix + 'address2'],
         city=self.cleaned_data[prefix + 'city'],
         post_code=self.cleaned_data[prefix + 'post_code'],
         state_code=self.cleaned_data[prefix + 'state'],
         country=self.cleaned_data[prefix + 'country']
     )
     return address
Example #6
0
def addresssubmit(request):
    if request.method == "POST":
        if request.POST['address-submit']:
            user_id=request.user.id
            fullname=request.POST['fullname']
            mobile=request.POST['mobile']
            town=request.POST['town']
            pincode=request.POST['pincode']
            state=request.POST['state']
            house=request.POST['house']
            area=request.POST['area']
            landmark=request.POST['landmark']
            p=Address(user_id=user_id,fullname=fullname,mobile=mobile,pincode=pincode,town=town,state=state,house=house,area=area,landmark=landmark)
            p.save()
        return redirect('orders:order_create')
Example #7
0
    def feed_from_csv(self, csv_file):
        csv_reader = csv.DictReader(csv_file, delimiter=',')
        for csv_row in csv_reader:
            feed_fields = map_keys_object(IB_ACCOUNT_FEEDS_MAPPING, csv_row)
            # account_id is unique field, it should always return a single row.
            ib_account_feeds = self.filter(
                account_id=feed_fields['account_id'])

            if feed_fields['type'] != 'D':
                continue
            try:
                feed_fields['date_opened'] = datetime.strptime(
                    feed_fields['date_opened'], '%Y%m%d')
            except ValueError:
                feed_fields['date_opened'] = None
            try:
                feed_fields['date_closed'] = datetime.strptime(
                    feed_fields['date_closed'], '%Y%m%d')
            except ValueError:
                feed_fields['date_closed'] = None

            address_fields = map_keys_object(IB_ADDRESS_FIELD_MAPPING, csv_row)
            address_fields['country'] = get_country_code_from_name(
                address_fields['country'])
            address = ib_account_feeds[0].address if ib_account_feeds.count(
            ) > 0 else Address()
            address.update_address(**address_fields)
            feed_fields['address'] = address

            if ib_account_feeds.count() > 0:
                ib_account_feeds.update(**feed_fields)
            else:
                self.create(**feed_fields)
Example #8
0
File: views.py Project: scotfu/M
def save(request, address_id=None):
    user=request.user
    if request.method =='POST':
        form=AddressForm(request.POST)
        if form.is_valid():
            if form.cleaned_data['address_id']:
                address=Address.objects.get(pk=form.cleaned_data['address_id'])
            else:
                address=Address()
            address.name=form.cleaned_data['name']
            address.address=form.cleaned_data['address']
            address.postal_code=form.cleaned_data['postal_code']
            address.user=user
            address.save()
            return HttpResponseRedirect('/address/')
    else:
        if address_id:
            address=Address.objects.get(pk=address_id)
            if address.user==request.user:
                form=AddressForm(initial={'address_id': address.id,
                    'name': address.name, 'address': address.address,
                    'postal_code': address.postal_code})
        else:
            form=AddressForm()
    return render_to_response('address_form.html', {
            'form': form},
             context_instance=RequestContext(request))
Example #9
0
def update(request):
    id = request.POST['idx']
    name = request.POST['name']
    email = request.POST['email']
    address = request.POST['address']
    print('id number: ', id, '\nname: ', name, '\nemail: ', email,
          '\naddress: ', address)

    # 수정할 내용을 편집
    addr = Address(idx=id,
                   name=request.POST['name'],
                   tel=request.POST['tel'],
                   email=request.POST['email'],
                   address=request.POST['address'])
    # 레코드가 수정됨
    addr.save()
    # 수정 후 리다이렉트로 목록으로 이동
    return redirect('/address/')
Example #10
0
    def save(self, *args, **kwargs):
        if self.instance.address_id:
            addr = self.instance.address
        else:
            addr = Address()
        addr.address = self.cleaned_data['address']
        addr.zipcode = self.cleaned_data['zipcode']
        addr.city = self.cleaned_data['city']
        addr.country = self.cleaned_data['country']
        addr.province_code = self.cleaned_data['province_code']
        addr.save()

        self.instance.address = addr
        brand = super(SABrandForm, self).save(*args, **kwargs)
        return brand
Example #11
0
 def post(self):
     try:
         postaddress = simplejson.load(self.request.body_file) 
     except (ValueError, TypeError, IndexError):
         self.response.set_status(400)
         return
     addressName = postaddress["name"]
     logging.info("posting address[%s]" % addressName)
      
     address = Address(name = addressName)
     address.put()
     
     address = Address.getByName(addressName)
     logging.info("address name %s is posting" % address.name)
     logging.info("address time %s is posting" % address.time)
     if address:
         self.response.set_status(201)
     else:
         self.response.set_status(204)
Example #12
0
    def post(self):
        try:
            postaddress = simplejson.load(self.request.body_file)
        except (ValueError, TypeError, IndexError):
            self.response.set_status(400)
            return
        addressName = postaddress["name"]
        logging.info("posting address[%s]" % addressName)

        address = Address(name=addressName)
        address.put()

        address = Address.getByName(addressName)
        logging.info("address name %s is posting" % address.name)
        logging.info("address time %s is posting" % address.time)
        if address:
            self.response.set_status(201)
        else:
            self.response.set_status(204)
Example #13
0
def key_address(request, pk, n):
    try:
        privatekey: PrivateKey = PrivateKey.objects.get(pk=pk)
    except PrivateKey.DoesNotExist:
        return HttpResponse(status=404)

    if request.method == 'POST':
        currency_factory = CurrencyModelFactory()
        currency_model = currency_factory.get_currency_model(
            privatekey.asset.symbol, privatekey.network_type)
        address = currency_model.get_addr_from_pub(privatekey.public_key, n)
        address_model = Address.objects.filter(private_key=privatekey,
                                               address=address).first()
        if not address_model:
            address_model = Address(private_key=privatekey,
                                    address=address,
                                    n=n)
            address_model.save()
        return JsonResponse({"address": address})
Example #14
0
def insert(request):
    # POST 방식으로 전달된 파라미터값
    # name = request.POST['name']
    # tel = request.POST['tel']
    # email = request.POST['email']
    # address = request.POST['address']
    #
    # print('name: ', name)
    # print('tel: ', tel)
    # print('email: ', email)
    # print('address: ', address)

    addr = Address(name=request.POST['name'],
                   tel=request.POST['tel'],
                   email=request.POST['email'],
                   address=request.POST['address'])
    # DB에 insert 처리
    addr.save()
    return redirect('/address/write')
Example #15
0
def load_test_addresses(addresses, wallet_id, is_change=False):
    address_index = 0
    for index, address_to_load in enumerate(addresses):
        if is_change:
            label = 'test change address, index {}'.format(index)
        else:
            label = 'test address, index {}'.format(index)
        Address(label=label,
                p2pkh=address_to_load,
                wallet_id=wallet_id,
                index=index,
                is_change=is_change).save()
Example #16
0
    def test_str_empty_apartment(self):
        """
        An address without apartment is represented as a string in the
        form of 'вул. Городоцька 17'.
        """
        city = City(name='Львів')
        street = Street(city=city, name='Городоцька', type='Street')
        house = House(number=17)
        address = Address(city=city, street=street, house=house)

        result = str(address)

        self.assertEquals('вул. Городоцька 17', result)
    def handle(self, *args, **options):
        if len(args) == 0:
            raise CommandError('You must specify a CSV file')

        filename = args[0]

        if not os.access(filename, os.R_OK):
            raise CommandError('CSV file could not be read')

        with open(filename, 'rb') as csvfile:
            for row in csv.reader(csvfile):
                print 'Importing UPRN %s' % row[self.headers.index('uprn')]

                try:
                    a = Address.objects.get(
                        uprn=row[self.headers.index('uprn')])
                except Address.DoesNotExist:
                    a = Address()

                for f in self.char_fields:
                    setattr(a, f, row[self.headers.index(f)])

                for f in self.integer_fields:
                    if row[self.headers.index(f)] != '':
                        setattr(a, f, int(row[self.headers.index(f)]))

                for f in self.decimal_fields:
                    if row[self.headers.index(f)] != '':
                        setattr(a, f, Decimal(row[self.headers.index(f)]))

                for f in self.date_fields:
                    if row[self.headers.index(f)] != '':
                        setattr(a, f, parsedate(row[self.headers.index(f)]))

                a.postcode_index = row[self.headers.index('postcode')].\
                    replace(' ', '').lower()

                a.save()
Example #18
0
    def handle(self, *args, **options):
        if len(args) == 0:
            raise CommandError('You must specify a CSV file')

        filename = args[0]

        if not os.access(filename, os.R_OK):
            raise CommandError('CSV file could not be read')

        with open(filename, 'rb') as csvfile:
            for row in csv.reader(csvfile):
                print 'Importing UPRN %s' % row[self.headers.index('uprn')]

                try:
                    a = Address.objects.get(
                        uprn=row[self.headers.index('uprn')])
                except Address.DoesNotExist:
                    a = Address()

                for f in self.char_fields:
                    setattr(a, f, row[self.headers.index(f)])

                for f in self.integer_fields:
                    if row[self.headers.index(f)] != '':
                        setattr(a, f, int(row[self.headers.index(f)]))

                for f in self.decimal_fields:
                    if row[self.headers.index(f)] != '':
                        setattr(a, f, Decimal(row[self.headers.index(f)]))

                for f in self.date_fields:
                    if row[self.headers.index(f)] != '':
                        setattr(a, f, parsedate(row[self.headers.index(f)]))

                a.postcode_index = row[self.headers.index('postcode')].\
                    replace(' ', '').lower()

                a.save()
Example #19
0
def addresssubmit(request):
    if request.method == "POST":
        if request.POST['address-submit']:
            user_id = request.user.id
            fullname = request.POST['fullname']
            mobile = request.POST['mobile']
            town = request.POST['town']
            pincode = request.POST['pincode']
            state = request.POST['state']
            house = request.POST['house']
            area = request.POST['area']
            landmark = request.POST['landmark']
            p = Address(user_id=user_id,
                        fullname=fullname,
                        mobile=mobile,
                        pincode=pincode,
                        town=town,
                        state=state,
                        house=house,
                        area=area,
                        landmark=landmark)
            p.save()
        return redirect('orders:order_create')
Example #20
0
def saveRoute(request):
    points = []
    if request.POST.has_key("points"):
        points = request.POST.getlist("points")
        routeName = request.POST.get("routeName")
        route = Route(name=routeName)
        route.save()

        for point in points:
            print "KURWA TU"
            print point
            address = getAddress(point).split(" ")[1:]
            saveAddress = Address(
                street=getStreet(address), number=getNumber(address), postCode=getCode(address), city=getCity(address)
            )
            saveAddress.save()
            savePoint = Point(
                route=route, address=saveAddress, longitude=getLongitude(point), latitude=getLatitude(point)
            )
            savePoint.save()
        return HttpResponse("Trasa zapisana")

    return HttpResponse("Wybierz conajmniej jeden punkt")
Example #21
0
    def update_address(self, address, prefix):
        if address is None:
            address = Address()
        address.address = '\n'.join([
            self.cleaned_data[prefix + 'address1'],
            self.cleaned_data[prefix + 'address2'],
            self.cleaned_data[prefix + 'city']
        ])
        address.post_code = self.cleaned_data[prefix + 'post_code']

        address_region_ser = RegionSerializer(
            data={
                'country': self.cleaned_data[prefix + 'country'],
                'name': self.cleaned_data[prefix + 'state'],
                'code': self.cleaned_data[prefix + 'state']
            })
        address_region_ser.is_valid(raise_exception=True)
        address_region = address_region_ser.save()
        address.region = address_region
        address.save()
        return address
Example #22
0
  
        apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', urlfetch_stub.URLFetchServiceStub())   
        apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub())        
        apiproxy_stub_map.apiproxy.RegisterStub('memcache', memcache_stub.MemcacheServiceStub())   
        apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', datastore_file_stub.DatastoreFileStub(u'myTemporaryDataStorage', '/dev/null', '/dev/null'))    
        apiproxy_stub_map.apiproxy.RegisterStub('user', user_service_stub.UserServiceStub())  

        os.environ['AUTH_DOMAIN'] = 'gmail.com'  
        os.environ['USER_EMAIL'] = '*****@*****.**' 
        os.environ['SERVER_NAME'] = 'fakeserver.com'   
        os.environ['SERVER_PORT'] = '9999'    

areas = [Area(code = u"100000", alias = [u"浙江"], name = u"浙江省", hasChild = True, alphaCode="AA"), 
     Area(code = u"101000" , alias = [u"杭州"], name = u"杭州市", parentArea = "100000", hasChild = False, alphaCode="AB"),
     Area(code = u"200000", alias = [u"江西"], name = u"江西省", hasChild = True, alphaCode="BA"), 
     Area(code = u"201000" , alias = [u"南昌"], name = u"南昌市", parentArea = "200000", hasChild = True, alphaCode="BB"),
     Area(code = u"201010" , alias = [u"南昌西北"], name=u"南昌西北区", parentArea = "201000", hasChild = False, alphaCode="BC"),
     Area(code = u"202000" , alias = [u"南"], name=u"南市", parentArea = "200000", hasChild = False, alphaCode="BD"),
     Area(code = u"300000", alias = [u"江苏"], name = u"江苏省", hasChild = True, alphaCode="CA"), 
     Area(code = u"301000" , alias = [u"南京"], name = u"南京市", parentArea = "300000", hasChild = True, alphaCode="CB"),
     Area(code = u"301010" , alias = [u"南京西"], name = u"南京西区", parentArea = "301000", hasChild = False, alphaCode="CC"),
     Area(code = u"400000", alias = [u"湖南"], name = u"湖南省", hasChild = True, alphaCode="DA"), 
     Area(code = u"401000" , alias = [u"南京"], name = u"南京市", parentArea = "400000", hasChild = False, alphaCode="DB"),
     Area(code = u"500000", alias = [u"吉林"], name = u"吉林省", hasChild = True, alphaCode="EA"), 
     Area(code = u"501000" , alias = [u"吉林"], name = u"吉林市", parentArea = "500000", hasChild = True, alphaCode="EB"),
     Area(code = u"502000" , alias = [u"长春"], name = u"长春市", parentArea = "500000", hasChild = False, postCode = "330000", alphaCode="EC")]

address = Address(name = u"上海市天山路600号")

excludeWords = [u"路", u"中路", u"中路", u"西路", u"中街", u"西街路口"]
 def testRecodeUnparesedAddress(self):
     AreaParser.parse(u"上海市天山路600号")
     upparsedAddress = Address.getByName(u"上海市天山路600号")
     self.assertEquals(address, upparsedAddress)
 def testRecodeUnparesedAddress(self):
     AreaParser.parse(u"上海市天山路600号")
     upparsedAddress = Address.getByName(u"上海市天山路600号")
     self.assertEquals(address, upparsedAddress)
Example #25
0
def import_client_from_csv(csvfile, firm):
    decoded_file = csvfile.read().decode('utf-8').splitlines()
    reader = csv.DictReader(decoded_file)
    for row in reader:
        client_user_dict = {
            key: row[key]
            for key in CLIENT_USER_IMPORT_FIELDS
            if row[key] is not None and row[key] is not ''
        }
        client_address_dict = {
            key: row[key]
            for key in CLIENT_ADDRESS_IMPORT_FIELDS
            if row[key] is not None and row[key] is not ''
        }
        client_dict = {
            key: row[key]
            for key in CLIENT_IMPORT_FIELDS
            if row[key] is not None and row[key] is not ''
        }

        advisor_user_dict = {
            key: row['advisor_' + key]
            for key in ADVISOR_USER_IMPORT_FIELDS
            if row['advisor_' + key] is not None and row['advisor_' +
                                                         key] is not ''
        }
        advisor_address_dict = {
            key: row['advisor_' + key]
            for key in ADVISOR_ADDRESS_IMPORT_FIELDS
            if row['advisor_' + key] is not None and row['advisor_' +
                                                         key] is not ''
        }
        advisor_dict = {
            key: row['advisor_' + key]
            for key in ADVISOR_IMPORT_FIELDS
            if row['advisor_' + key] is not None and row['advisor_' +
                                                         key] is not ''
        }

        try:
            User.objects \
                .filter(email=advisor_user_dict['email']) \
                .update(**advisor_user_dict)
            advisor_user = User.objects.get(email=advisor_user_dict['email'])
        except Exception as e:
            advisor_user = User.objects.create(**advisor_user_dict)

        advisor_address = Address()
        advisor_address.update_address(**advisor_address_dict)
        advisor_address.save()

        try:
            advisor = Advisor.objects.get(
                user__email=advisor_user_dict['email'])
            Advisor.objects \
                .filter(user__email=advisor_user_dict['email']) \
                .update(residential_address = advisor_address, **advisor_dict)
        except:
            advisor = Advisor(**advisor_dict)
            advisor.user = advisor_user
            advisor.residential_address = advisor_address

            advisor.firm = firm
            advisor.betasmartz_agreement = True
            advisor.default_portfolio_set = firm.default_portfolio_set
            advisor.is_accepted = True

            advisor.save()

        try:
            User.objects \
                .filter(email=client_user_dict['email']) \
                .update(**client_user_dict)
            client_user = User.objects.get(email=client_user_dict['email'])
        except Exception as e:
            client_user = User.objects.create(**client_user_dict)

        client_address = Address()
        client_address.update_address(**client_address_dict)
        client_address.save()

        try:
            Client.objects \
                .filter(user__email=client_user_dict['email']) \
                .update(residential_address = client_address, advisor=advisor, **client_dict)
            client = Client.objects.get(user__email=client_user_dict['email'])
        except:
            client = Client(**client_dict)
            client.user = client_user
            client.residential_address = client_address
            client.advisor = advisor

            client.betasmartz_agreement = True
            client.default_portfolio_set = firm.default_portfolio_set
            client.is_accepted = True

            client.save()
Example #26
0
def create_address():
    address = Address(raw='11 rue du Vert Buisson')
    clean_and_save(address)
    return address
Example #27
0
 def save(self, *args, **kwargs):
     if not self.id:
         address = Address()
         address.save()
         self.address = address
     super(Donation, self).save(*args, **kwargs)
Example #28
0
from accountant.models import Accountant
from address.models import Address

adr = Address(name="LG",
              street="Avenue Reine Marie Henriette",
              number="29",
              zipcode="1190",
              city="Bruxelles")
adr.save()
c = Accountant(name="Renaud",
               email="*****@*****.**",
               telephone="+32478811988",
               default=True,
               address=adr)
c.save()
Example #29
0
from address.models import Address
import json

with open("addresses.json") as addresses_file:
    addresses_json = json.load(addresses_file)

for address in addresses_json:
    address = Address(
        street=address['street'],
        neighborhood=address['neighborhood'],
        city=address['city'],
        description=address['description'],
        complement=address['complement'],
        cep=address['cep'],
        number=address['number'],
        uf=address['uf'],
    )
    address.save()
Example #30
0
def registerPage(request):
    form = CreateUserForm()
    form_customer = Create_customer(request.POST)
    form_address = Create_address(request.POST)
    form_city = Create_city(request.POST)
    sports = Sport.objects.all()
    if request.method == 'POST':
        form = CreateUserForm(request.POST)
        if form.is_valid() and form_customer.is_valid(
        ) and form_address.is_valid() and form_city.is_valid():
            usuario = form.save()
            username = form.cleaned_data.get('username')
            messages.success(request, F"Bienvenid@ {username}")
            login(request, usuario)

            user = request.user

            first_name1 = form_customer.cleaned_data.get('first_name')
            last_name1 = form_customer.cleaned_data.get('last_name')
            birthdate1 = form_customer.cleaned_data.get('birthdate')
            phone_number1 = form_customer.cleaned_data.get('phone_number')
            address1 = form_address.cleaned_data.get('address')
            city1 = form_city.cleaned_data.get('city_name')
            country1 = form_city.cleaned_data.get('country')

            city_created = City.objects.get(city_name=city1)

            lista = Address.objects.all()
            m = 0

            for q in lista:
                m += 1

            address_created = Address(address_id=m + 1,
                                      address=address1,
                                      city_id=city_created)
            address_created.save()

            customer_created = Customer(customer_id=user.id,
                                        first_name=first_name1,
                                        last_name=last_name1,
                                        birthdate=birthdate1,
                                        phone_number=phone_number1,
                                        address_id=address_created,
                                        auth_user_id=user)
            customer_created.save()

            lista_shop = Shopping_cart.objects.all()
            count = 0
            for i in lista_shop:
                count += 1

            day = date.today()
            dt = day.strftime("%Y-%m-%d")
            shopping_cart_crated = Shopping_cart(cart_id=count + 1,
                                                 effective_date=dt,
                                                 total=0,
                                                 customer_id=customer_created)
            shopping_cart_crated.save()
            return redirect('Home')
        else:
            for msg in form.error_messages:
                messages.error(request, form.error_messages[msg])
            context = {
                'form': form,
                'form_customer': form_customer,
                'form_address': form_address,
                'form_city': form_city,
                'sport': sports
            }
            return render(request, 'Home/Sign_up.html', context)

    context = {
        'form': form,
        'form_customer': form_customer,
        'form_address': form_address,
        'form_city': form_city,
        'sport': sports
    }
    return render(request, 'Home/Sign_up.html', context)
Example #31
0
def insert(request):
    addr = Address(name=request.POST['name'], tel=request.POST['tel'],\
                   email=request.POST['email'], address=request.POST['address'])
    addr.save()
    return redirect("/address")
Example #32
0
def update(request):
    id = request.POST['idx']
    addr = Address(idx=id, name=request.POST['name'], tel=request.POST['tel'],\
                   email=request.POST['email'], address=request.POST['address'])
    addr.save()
    return redirect("/address")
Example #33
0
 def save(self, *args, **kwargs):
     if not self.id:
         address = Address()
         address.save()
         self.address = address
     super(Customuser, self).save(*args, **kwargs)