def feed(request): logging_format = ('%(asctime)s - %(levelname)s - ' '%(filename)s:%(lineno)d - %(message)s') logging.basicConfig(level=logging.DEBUG, format=logging_format) error = False if not request.POST['update'].strip( ) == "" and request.POST['update'] is not None: logging.debug(request.POST) user = request.user update = request.POST["update"] date = datetime.datetime.now() feedsave = Feed(username=user, date=date, message=update) feedsave.save() feed = Feed.objects.order_by('-date') # feeds_list = [feed.message for feed in feeds] return render(request, 'results.html', { "feed": feed, "user": user, "date": date, "message": update }) else: error = True feed = Feed.objects.order_by('-date') return render(request, 'results.html', {"error": error, "feed": feed})
def feed(request): logging_format = ( '%(asctime)s - %(levelname)s - ' '%(filename)s:%(lineno)d - %(message)s' ) logging.basicConfig(level=logging.DEBUG, format=logging_format) error= False if not request.POST['update'] == "" and request.POST['update'] is not None: logging.debug(request.POST) user = request.user update = request.POST["update"] date = datetime.datetime.now() feedsave = Feed(username = user, date = date, message = update) feedsave.save() feed = Feed.objects.order_by('-date') # feeds_list = [feed.message for feed in feeds] return render(request, 'results.html', {"feed":feed, "user":user, "date":date, "message":update }) else: error = True feed = Feed.objects.order_by('-date') return render(request, 'results.html', {"error":error, "feed":feed})
def feed(request): logging_format = ('%(asctime)s - %(levelname)s - ' '%(filename)s:%(lineno)d - %(message)s') logging.basicConfig(level=logging.DEBUG, format=logging_format) if not request.POST['message'] == "": submit = Feed() submitform = SubmitForm(request.POST, instance=submit) logging.debug(request.POST) user = request.user update = request.POST["message"] date = datetime.datetime.now() feedsave = Feed(username=user, date=date, message=update) feedsave.save() feed = Feed.objects.order_by('-date') # feeds_list = [feed.message for feed in feeds] return render(request, 'results.html', { "feed": feed, "submitform": submitform }) else: submit = Feed() submitform = SubmitForm(request.POST, instance=submit) feed = Feed.objects.order_by('-date') return render(request, 'results.html', { "submitform": submitform, "feed": feed })
def feed(request): logging_format = ( '%(asctime)s - %(levelname)s - ' '%(filename)s:%(lineno)d - %(message)s' ) logging.basicConfig(level=logging.DEBUG, format=logging_format) if not request.POST['message'] == "": submit = Feed() submitform = SubmitForm(request.POST, instance = submit) logging.debug(request.POST) user = request.user update = request.POST["message"] date = datetime.datetime.now() feedsave = Feed(username = user, date = date, message = update) feedsave.save() feed = Feed.objects.order_by('-date') # feeds_list = [feed.message for feed in feeds] return render(request, 'results.html', {"feed":feed, "submitform":submitform}) else: submit = Feed() submitform = SubmitForm(request.POST, instance = submit) feed = Feed.objects.order_by('-date') return render(request, 'results.html', {"submitform":submitform, "feed":feed})