Category : forms

Here’s the python snippet @app.route(‘/oxygenadmin’) @is_logged_in def oxygenadmin(): cur=mysql.connection.cursor() cur.execute("SELECT * FROM oxygen") data =cur.fetchall() cur.close() return render_template(‘oxygenadmin.html’, oxygen=data) @app.route(‘/insert’, methods=[‘POST’]) @is_logged_in def insert(): if request.method == ‘POST’: name = request.form[‘name’] contact = request.form[‘contact’] email = request.form[’email’] place = request.form[‘place’] cur = mysql.connection.cursor() cur.execute("INSERT INTO oxygen(name, contact, email, place) VALUES (%s, %s, %s, %s)",(name,contact,email,place)) mysql.connection.commit() ..

Read more

I’m new in learning code, I’m not able to retrieve data from database and display it in html I can’t figure out what’s the problem. I’m trying to override get_context_data to add extra players to render in the template. how can i solve this issue? Below my configuration vieuws.py def addcomment(request, id): url = request.META.get(‘HTTP_REFERER’) ..

Read more

Yes, I did look at the other responses to similar questions. But I haven’t found one that helps me, Ive looked at all the currently available solutions. I am trying to enter a name into a textbox, and then hit submit, allowing me to create a new list of items (the items are irrelevant). But ..

Read more

I’m learning to create custom user form on django and the procedure is still not very clear to me. So, I’m following a tutorial. However, when I try to make migrations I encounter the follow error, but the instructor’s code program worked. I don’t understand why mine is throwing back an error message. Please I ..

Read more

I need to make a form in HTML for a global search (just some selects in mysql) but I’m struggling in making the form work. I created the view: class GlobalSearch(View): template = "name.html" def post(self, request): global_json = {} if "global_search" in request.POST: global_val = request.POST["global_search"] global_json = get_all_elements(global_val) return render(request, self.template, global_json) and ..

Read more