def Discover_Process(request): count = settings.PAGE_LOAD_NUM if request.method == 'GET': pp = restful.get_address_by_138ip(request=request) print(pp) discover = Discover.objects.all().select_related('author') context = {'discover': discover} return render(request, 'news/discover.html', context) else: form = DiscoverForm(request.POST) if form.is_valid(): content = form.cleaned_data.get('content') if str(request.user) != 'AnonymousUser': author = request.user else: exist = User.objects.filter(username='******').exists() if exist: author = User.objects.get(username='******') else: author = User.objects.create_user(username='******', password=12341234, telephone=13005611199, is_staff=0) disc = Discover.objects.create(content=content, author=author) disc.save() return restful.ok() else: return restful.params_error('内容或标题不能为空')
def index(request): newses = News.objects.all()[0:settings.PAGE_LOAD_NUM] banners = Banner.objects.all() context = {'newses': newses, 'banners': banners} restful.get_address_by_138ip(request=request, content='进入到主页') return render(request, 'news/index.html', context)
def lover_mumu(request): restful.get_address_by_138ip(request, '慕慕blog访问') return render(request, 'cms/banner/mumu.html')