Example #1
0
def brandname():
    phone = Phone.objects()
    brand_name_list = []
    brand_name = ""
    for item in phone:
        if brand_name != item.phone_brand_name:
            brand_name = item.phone_brand_name
            brand_name_list.append(brand_name)
    return (brand_name_list)
Example #2
0
def chi_tiet_hang_dien_thoai(brand_name):
    brand_name_list = brandname()
    phone = Phone.objects()
    phone_list = []
    phone_data = []
    for item in phone:
        if item.phone_brand_name == brand_name:
            phone_data.append(item)
    return render_template('dien-thoai-cua-hang.html',
                           phone=phone_data,
                           brand_name=brand_name,
                           brand_name_list=brand_name_list)
Example #3
0
def result():
    if request.method == "GET":
        SP_ordered = Phone.objects()
        phone_li1 = SP_ordered[0:3]
        phone_li2 = SP_ordered[4:7]
        print(phone_li1[0].product_name)
        print(phone_li2[0].product_name)
        return render_template('result.html', phone_li1=phone_li1, phone_li2=phone_li2)
    elif request.method == "POST":
        form = request.form
        name = form["name"]
        # name1 = form["name2"]
        # regex1 = re.compile(name1)
        # regex2 = re.compile(name2)
        # phone_li1 = Phone.objects(product_name=regex1)
        # phone_li2 = Phone.objects(product_name=regex2)
        return "a"
def index():
    phone_list = Phone.objects()
    return render_template('index.html', phone_list=phone_list)
Example #5
0
import mlab
from models.phone import Phone

mlab.connect()

phone_list = Phone.objects()  #product_name="samsung"
first_phone = phone_list[0]

print(first_phone.to_mongo())