Exemplo n.º 1
0
    def create_user(self, mobile, password, open_id):
        # if not re.match(r'[^_][_0-9a-zA-Z]{6,12}$', password):
        #     raise serializers.ValidationError('密码格式不正确,由数字、字母、下划线组成,首字符不能为下划线')


        try:
            user = User()
            user.username = mobile
            user.set_password(password)
            user.mobile = mobile
            user.save()
        except:
            raise serializers.ValidationError('数据库操作失败')

        return user
Exemplo n.º 2
0
def createUser(request):

	if request.method == 'POST':		
		
		form = UserForm(request.POST)		
							
		if form.is_valid():

			user = User()
			
			user.birth_date = form.cleaned_data.get('birth_date')
			user.randomId = form.cleaned_data.get('randomId')	
			user.username = form.cleaned_data.get('username')		
			user.password = form.cleaned_data.get('password')							
			user.save()		
			#import pdb; pdb.set_trace()		
			# messages.success(request, 'Form submission successful')
			return redirect('list')
		else:
			form = UserForm(request.POST)
		
		return redirect('add')	
# import os
import random

from Dishes.models import Dish
from Tables.models import Table
from Users.models import User

user = User()
user.username = '******'
user.is_superuser = True
user.is_staff = True
user.set_password("123456")
user.save()

for i in range(10):
    table = Table(
        table_category=random.randint(0, 2),
        table_state=random.randint(0, 1),
    )
    table.save()

dishes = ['蒸羊羔',
          '蒸熊掌',
          '蒸鹿尾儿',
          '烧花鸭',
          '烧雏鸡',
          '烧子鹅',
          '卤猪',
          '卤鸭',
          '酱鸡',
          '腊肉',