Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Set testing options while django doctesting
Following these posts, I have managed to run my doctest within django with: # myapp/tests.py import doctest def load_tests(loader, tests, ignore): tests.addTests(doctest.DocTestSuite()) return tests Then running: python manage.py tests However, since I am used to test my (non-django) scripts with the simple command: py.test --doctest-modules -x I am now quite confused about: testing procedure not stopping after first failure (my good'ol -x) (so I get flooded with results and I need to scroll back all the way up to the first problem each time) option # doctest: +ELLIPSIS not being set by default. How do I set this kind of options from this django load_tests() hook? -
Want to have django-two-factor-auth skip token if user logged in during the last 30 days
First, if anyone has done this, please advise :) Right now, I am thinking of subclassing WizardView's method render_next_step() (from the formtools package). the 1st line of the new method would be: if self.steps.next == 'token': (pseudo code) if user_agent == current user_agent and last_activity < 30 days ago (from table user_sessions_session): return # skip the token step Comments, suggestions welcome -
Django user.is_staff not working
i am in trouble with my django projet. I would like to do that only staff user can see a link (href) in a template. The template in which is the code bellow is the template base.html that I take in my other templates. here is the header of base.html <header class="header"> <img src="{% static 'img/headerWAI.jpg' %}" alt="HeaderWai jpg" class="headerimg" /> <h1 class="headerText">Waste Annotation Image</h1> <p class="usermenu"> {% block loginuser %} {% if user.is_authenticated %} Hello {{ user.username }}! <p><a class="loginlink" href="{% url 'logout' %}">logout</a> {% if user.is_staff %} <a href="{% url 'newimage' %}">manage image</a></p> {% endif %} {% else %} <p>You are not logged in : <a href="{% url 'login' %}">login</a></p> {% endif %} {% endblock %} </p> user.if_authenticatted work correctly but 3 lines bellow, user.is_staff not work. Out of 5 test users, only 2 have the boolean at True as staff. But when I am connect with a non-staff user, he has the link. I don't understand why? Maybe i have forgot an import or something in the settings.py Any suggestion ? PS: i am a beginner in django -
How to save user id to inline models in Django admin?
I have these Django models (minimal data for brewity): # models.py class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): title = models.CharField(max_length=200) author = models.ForeignKey(Author) class AuditLog(models.Model): user = models.ForeignKey(User) # standard User model info = JSONField(default=dict) I know how to create inline admin for Books in AuthorAdmin but the problem is, I need to save AuditLog with information about who added each of the inline objects. I know I can make something like this to get the user upon saving Author: # admin.py @admin.register(Author) class AuthorAdmin(admin.ModelAdmin): inlines = [BookInline] def save_model(self, request, obj, form, change): AuditLog.objects.create(user=request.user, info={'blah': 'blahblah'}) super().save_model(request, obj, form, change) But what should I do to save the info about the user that added a new Book (eg. after some time) using the inline formset? BaseInlineFormSet methods don't support this. -
How to post data of logged in user with a form in Django?
I am creating a form for users to book times on my web app. Currently I have the following files. see forms.py: class BookingForm(forms.ModelForm): usname = User.username daterequired = forms.CharField(max_length=60, required=True) students = forms.CharField(max_length=60, required=True) length = forms.CharField(max_length=60, required=True) class Meta: model = Booking fields = "__all__" see models.py: class Booking(models.Model): usname = User.username daterequired = models.DateField(_("Date"), default=datetime.date.today) students = models.CharField(max_length=200) length = models.CharField(max_length=40, blank=True) see views.py: @login_required def choose(request): if request.method == 'POST': form = BookingForm(request.POST) if form.is_valid(): form = form.save(commit=False) form.save() return redirect('index') else: form = BookingForm() return render(request, 'choose.html', {'form': form}) What I am trying to achieve is that when a user clicks submit on the form that their user data automatically gets logged in the bookings table on the database. At the minute the only data getting logged in the table is the date field, students and length. I need to know which user is posting this data. Can anyone help? -
Django field extending UserCreationForm not showing up in view
What I'm trying to accomplish is to extend UserCreationForm to add an e-mail field for each user when they sign- up. Currently I have a form from UserCreationForm with username and password but no e-mail. I extend it with the forms.py file and implement it in my views.py. But when I run tests and look at the signup page the e-mail field is not found. views.py: from django.shortcuts import render, redirect from django.contrib.auth.forms import UserCreationForm from django.contrib.auth import login as auth_login from .forms import SignUpForm # Create your views here. def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() auth_login(request, user) return redirect('index') else: form = SignUpForm() return render(request, 'signup.html', {'form': form}) forms.py: from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class SignUpForm(UserCreationForm): email = forms.CharField(max_length = 254, required = True, widget = forms.EmailInput()) class Meta: model = User fields = ('username', 'email', 'password1', 'password2') form.html: {% load widget_tweaks %} {% for field in form %} <div class="form-group"> {{ field.label_tag }} {% if form.is_bound %} {% if field.errors %} {% render_field field class="form-control is-invalid" %} {% for error in field.errors %} <div class="invalid-feedback"> {{ error }} </div> {% endfor %} {% … -
Saving image/file uploads using react-redux to Django Rest Api Fails
I have been trying to submit and save form contents to django backend API. My project's frontend is done in reactjs. To connect the data flow i'm using React-Redux, to django rest framework. I'm using fetch function in redux action.(We can't use ajax or other 'react-less things'.). The form submission is working fine when upload field is removed. but the image upload fails. after submission, on console, i can see the image also reached till action. but saving it to API is not working. It is causing error: Django REST API, it shows the error "the submitted data was not a file. Check the encoding type on the form." Please help me. Please see the demo here -
routeParams keep returning empty dictionary
i'm using django/angular and trying to retrieve the 1234 parameter in url in http://localhost:8000/dashboard/1234. So far i've created a config file with the routing and a controller where i try to retrieve the id. however i keep getting {} in the console.log and then this error Error: $compile:tpload Error Loading Template var app = angular.module("App", ["ngRoute", "ngCookies"]); app.config(function ($routeProvider, $locationProvider) { $routeProvider.when('/dashboard/:id', { templateUrl: '/dashboard/', controller: 'DashboardController' }).otherwise({ redirectTo: '/' }); $locationProvider.html5Mode({ enabled: true, requireBase: false }); }); and in my controller i'm trying to output the routeParams (function () { 'use strict'; angular .module('App') .controller('DashboardController', DashboardController); DashboardController.$inject = ['$location', '$scope', '$routeParams', 'Dashboard']; function DashboardController($location, $scope, $routeParams, Dashboard) { var vm = this; console.log($routeParams) } }); -
Showing current user instance in edit profile form
So I have this view which displays my UserProfileForm. As far as I can tell the logic of what's going on makes sense. It should (1) automatically pull the profile info from the currently logged in user and (2) save it when submitted. The only problem is that it does neither of those two things. I have looked around SO for how to do this as well as some other tutorials but it still won't do the trick. The view: def editProfileView(request): if request.method == 'POST': form = UserProfileForm(request.POST, instance=request.user) if form.is_valid(): form.save() return redirect('users:explore') else: form = UserProfileForm(instance=request.user) args = {'form':form} return render(request, 'users/userprofile_edit_form.html', args) Not sure how relevant seeing the form itself is but this is what it looks like: class UserProfileForm(forms.ModelForm): first_name = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) profile_pic = forms.ImageField(widget=forms.FileInput(attrs={'class':'form-control mb-3'}), required=False) location = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) title = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) user_type = forms.ChoiceField(choices=USER_TYPE_CHOICES) website = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) about = forms.CharField(widget=forms.Textarea(attrs={'class':'form-control mb-3'})) twitter = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) dribbble = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) github = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control mb-3'})) class Meta: model = UserProfile fields = ( 'first_name', 'profile_pic', 'location', 'title', 'user_type', 'website', 'about', 'twitter', 'dribbble', 'github' ) -
Django filter queryset optimization
I'm using django-filter and i have 40k+ record that comes from filter. def index(request): cleaned_objects = Mymodel.objects.filter(is_deleted=False) my_objects = ReportFilter(request.GET,queryset=cleaned_objects) and i'm giving some filter for example created_at__gte = 01.01.2011 and this query retrieve 40k records i also using django pagination but i'm getting timeout error. So how can i fix that timeout error and which optimization should i use. -
Connection Pooling across several processes in Pymongo
I'm a rather new to Pymongo and Mongodb itself and right now i'm working on a Django based project that uses a process to perform some cruds on a Mongodb instance we are using PyMongo and since this is web application many instances might be running at the same time so my questions is about the connection pool setup. what's the best practice to use the Pymongo keeping in mind performance for this specific case: connection pool? At the beginning we had a new instace of Pymongo created: MongoClient(host, port, maxPoolSize=200) every time the endPoint was called. i understand that every instance is using it's own connection Pool but when you have many instances running..do you have multiple connections pool per Mongodb instance? So we came with a modification and now instead creating new instances we just use static method which actually serves the connection method and this is shared across all of the PyMongo instances being invoked is this a good solution or is it better the first one (instance per call) or is there another option that i should follow?? I would appreciate the comments or suggestions from other guys more experienced in this matter. Thanks in advanced … -
Error - Rebuild search index with django-oscar
I'm following the django documentation to integrate solr with django-Oscar.I'm getting the following error when trying to rebuild the index.How can I fix this issue? $python3 manage.py rebuild_index --noinput Removing all documents from your index because you said so. Failed to clear Solr index: Solr responded with an error (HTTP 500): [Reason: Error 500 {msg=SolrCore 'collection1' is not available due to init failure: Schema Parsing Failed: unknown field 'id'. Schema file is /home/asanka/Music/devBranch/dailyDeal_v3/main_app/solr-4.7.2/example/solr/collection1/schema.xml,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Schema Parsing Failed: unknown field 'id'. Schema file is /home/asanka/Music/devBranch/dailyDeal_v3/main_app/solr-4.7.2/example/solr/collection1/schema.xml at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:827) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:305) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:368) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72) at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.solr.common.SolrException: Schema Parsing Failed: unknown field 'id'. Schema file is /home/asanka/Music/devBranch/dailyDeal_v3/main_app/solr-4.7.2/example/solr/collection1/schema.xml at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:618) at org.apache.solr.schema.IndexSchema.(IndexSchema.java:166) at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55) at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69) at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:559) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:597) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:258) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:250) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ... 1 more Caused by: java.lang.RuntimeException: unknown field 'id' at org.apache.solr.schema.IndexSchema.getIndexedField(IndexSchema.java:340) at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:536) … -
getting error: 'Each option setting in configuration file must be a map ' while deploying django app in EBS
I am trying to deploy a django application in EBS. I am following the aws tutorial but I'm unable to deploy. The error says: 'ERROR: Each option setting in configuration file reclutapp_project/.ebextensions/django.config in application version app-db14-180308_133135 must be a map. Update each option setting in the configuration file.' This is my config file: option_settings: aws:elasticbeanstalk:container:python: WSGIPath: reclutapp_project/reclutapp_project/wsgi.py And my file structure: reclutapp/ .ebextensions/ django.config reclutapp_project/ manage.py reclutapp_project/ urls.py wsgi.py I've ssh my ebs application and the wsgi.py path is correct. I've also tried this with no success. I've also checked indentation and format. I've also tried with json format getting the same error. I've deleted elastickbeanstalk config file and created a new environment, but nothing seems to work. I assume the problem relies on the config file format, but I'm using both yalm and json compatible formats. I am using Django 2.0 and Python 3.6 environment. Any suggestions? -
why it shows error that from . views can't be imported
music/urls.py from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^(?P<album_id>[0-9)+$', views.detail, name='detail'), ] followed by views.py code from django.http import HttpResponse def index(request): return HttpResponse("this is something") def detail(request, album_id): return HttpResponse(" details of album " + str(album_id)+"") the main url website is built correctly.. -
How to save custom User model in Django during user's navigation
Hy guys, I have a custom User model in Django 2.0 containing various user data. class User(models.Model): username = = models.CharField(max_length=30) _isLogged = False # ... other custom data Once the user is logged (_isLogged = True)~ in the login page, how can I save this object so I can verify in another page, say home, that the same user has already logged in? N.B. I tried to store all the object in a session variable but it is not serializable. Many thanks. -
Django Rest Api - Get and Post Request in One Go - Post Request based on the Get Result
I have this below requirement to achive using Django Rest Framework. I need to handle POST request to Model 2 within the Get request of Model 3 I have two models, Kept only few columns models.py class Customers(models.Model): #original customers data are stored here customer_id = models.BigIntegerField(db_column='customer_id', primary_key=True) customer_name = models.CharField(db_column='Customer_name', blank=True, null=True, max_length=50) class Customers_In_Use(models.Model): #where we will track the locking of customers data once they get used customer_id = models.OneToOneField(Customers_Master, to_field='customer_id', on_delete=models.DO_NOTHING, related_name='rel_customer') comments = models.TextField(blank=True,null=True) one database view. Customers_View(models.Model): customer_id = models.BigIntegerField() customer_name = models.CharField() in_use = models.CharField(blank=True) class Meta: managed = False This view is built at backend as below Select C.customer_id, C.customer_name, CASE WHEN U.customer_id_id IS NULL THEN 'No' ELSE 'Yes' END AS In_Use, from Customers C left join Customers_In_Use U on C.customer_id=U.customer_id_id On my Django Rest Api I am exposing data based on Customers_View (GET request) I have a POST request to Customers_In_Use which will receive customer_id and comments in a json format. Example Data on Customers_View: customer_id,Customer_name,in_use 123,John,No 456,Smith,No 789,John,No 987,Tom,Yes #Yes means this customer data is already in use 567,Tom,No now on api if i run this get request 127.0.0.1:8000/api/customers_view/?in_use=No&customer_name=Tom I should get result as below { customer_id:567, customer_name=Tom, in_use:No } Since … -
Unable to run the docker image for the ethereum project
I have been trying to run the project https://github.com/Mattie432/Blockchain-Voting-System The following steps are given to run the image. 1.Ensure docker is running with sudo service docker start. 2.Build the docker image with docker build -t applicationserver . while in the 2_ApplicationServer directory. 3.Run the docker image with docker run -p 80:80 applicationserver and map the internal port 80 to the localhost port 80. But following error is shown while the third step docker run -p 80:80 applicationserver [docker_entrypoint] Running database migrations.. Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 305, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute self.check() File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 385, in check include_deployment_checks=include_deployment_checks, File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 372, in _run_checks return checks.run_checks(**kwargs) File "/usr/local/lib/python3.5/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/usr/local/lib/python3.5/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/usr/local/lib/python3.5/site-packages/django/core/checks/urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "/usr/local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python3.5/site-packages/django/urls/resolvers.py", line 310, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python3.5/site-packages/django/urls/resolvers.py", line … -
Create manytomany to user with value
I am building an application where I need to add to the user model 'skills'. These skills are created and added by the user being this also a model. I want to add to this skills, related with a many to many relationship, a value. This value will be a number from 1 to 10 specifing the level of the user at a particular skill. So that I need to relate a level to each skill added to the user. models.py class Skill(models.Model): name = models.CharField(max_length=50) class Perfil(AbstractUser): skills = models.ManyToManyField(Skill, blank=True, null=True) Does anyone know how can I resolve this issue. Thanks in advance. -
Filter JSON results - Django 1.8
I've tried this: def profile(request): parsedData = [] if request.method == 'POST': username = request.POST.get('user') req = requests.get('https://api.github.com/users/' + username + '/repos') jsonList = [] jsonList=req.json() userData = {} for data in jsonList: userData['html_url'] = data['html_url'] userData['created_at'] = data['created_at'] userData['updated_at'] = data['updated_at'] userData['forks_count'] = data['forks_count'] repo_instance = Repo.objects.create(name=data['id']) repos = Repo.objects.filter(updated_at__lt = timezone.now()).order_by('updated_at') parsedData.append(userData) return render(request, 'app/profile.html', {'data': parsedData}) Here's my model: class Repo(models.Model): name = models.CharField('Name of repo', max_length=255) login = models.CharField('Login', max_length=255) blog = models.CharField('Blog', max_length=255) email = models.CharField('Email', max_length=255) public_gists = models.CharField('Public Gists', max_length=255) updated_at = models.DateTimeField('Updated at', blank=True, null=True) The profile method on views.py, makes a query to an address like this one What am I missing? The results aren't being filtered, or should I use some other parameter instead of lt? Or maybe it's the fact that updated_at is not being called into the method, just id field? -
Form verification with MySQL database using Django
Hi, I'm new to coding and I wanted to build a program using Django and MySQL that would be useful for me. Essentially I wanted to build a site where I can input a 9-digit ID code into a form, then have the site verify if that 9-digit number exists in a database. I wanted to have a database with +100,000 9-digit numbers to check against. If the number exists I wanted to send back a "Number is valid" message and if not a "Number is invalid" message. Could someone direct me to a book/example/tutorial that discusses how to check form data against large MySQL databases. -
Django-Allauth remove email field in signup form
I only use Linked-In as means to authenticate. When the user gives permission in Linked-In, he get's send to my own form so I can gather extra information. But it seems Allauth only lets me add fields to the default form using: ACCOUNT_SIGNUP_FORM_CLASS = 'myapp.forms.MySignUpForm' But the email field is always visible (and filled in with the email from Linked-In). Is it true that I have no way of dropping this field? I don't want the user to be able to change his email into something else than his Linked-In email. -
Django login page via /accounts/login/ instead of /
I have just begun using Django and after a long time struggling I finally made the login work. The only problem is that I have to go to ip_address/accounts/login/ to login. I want to have this as the first thing you see, so on the link: ip_address/ I was wondering if there is such a thing like LOGIN_URL for the homepage or another solution. Thanks -
How can users add to a database in Django
Within the admin app it's possible to add to a database. But is there a way where users who have accounts on the website can add to the database. For example a playlist where a user can add information about songs to -
Order a recipe queryset by replies number using django-disqus
I have a recipe model and i need create a view for most commented recipes, i'm using django-disqus for handling recipe's comments, but i don't know how can i order the queryset by the recipe's comment number. class PopRecipeListView(GlobalQueryMixin, ListView): model = Recipe context_object_name = "recipe_list" template_name = 'recipe/recipe_top_list.html' def get_queryset(self): qs = super(PopRecipeListView, self).get_queryset() if qs: qs = qs.extra( select={ 'comments': # get comment numbers } ).filter(shared=True).order_by('-rate')[:20] return qs What's the properly way? -
Passing list of dicts to form
I have a rather fundamental query regarding django and form handling. Suppose I have a form called "questions.html". I wish to give all the fields names, so I write a view to give names to all the fields. The data from the form is then supposed to be passed to a view for processing, and then response is generated and given to another page, called "answers.html". Do I need 2 views for handling this? Is my flow correct?