The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

Working on SignUp page


I noticed that there's a views.py script separately inside the following folders; signup, signin, reset-password

The views renders the signup.html templates. I tried to include the backend logic inside the views.py script inside of the signup folder to save a user's data to my postgres database but it's not working.

I need help. I'll like to know if I can create a separate views.py script to handle both signup and user login instead of having separate views.py scripts inside each folder


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)

Deleted comment
Deleted comment

We've just lately commenced a new web site, the details anyone present on this internet site features made it easier for us drastically. Cheers pertaining to your occasion & operate. blog comment service


Deleted comment
 
Deleted comment

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. 먹튀검증



Hi

Yes, you can consolidate the backend logic for both signup and user login into a single views.py script. Here's a general approach to do this in Django:

Update your urls.py to include the URLs for both signup and login views. For example:

from django.urls import path
from . import views

urlpatterns = [
path("signup/", views.signup, name="signup"),
path("login/", views.login, name="login"),
]

In your views.py file, you can define functions to handle both signup and login logic. For example:

from django.shortcuts import render
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login

def signup(request):
if request.method == "POST":
# Handle signup logic here
# For example, create a new user
username = request.POST.get("username")
password = request.POST.get("password")
email = request.POST.get("email")
user = User.objects.create_user(username=username, email=email, password=password)
user.save()
# Redirect to a success page or login page
return redirect("login")
else:
# Render the signup form
return render(request, "signup.html")

def login(request):
if request.method == "POST":
# Handle login logic here
username = request.POST.get("username")
password = request.POST.get("password")
user = authenticate(username=username, password=password)
if user is not None:
# Log the user in
login(request, user)
# Redirect to a success page or home page
return redirect("home")
else:
# Return an invalid login message
return render(request, "login.html", {"error_message": "Invalid credentials"})
else:
# Render the login form
return render(request, "login.html")

Update your signup.html and login.html templates to submit the form data to the appropriate URLs (/signup/ and /login/).


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.