V-FOR-VEND3TTA / return-and-exchange-system

A return and exchange system to streamline the return and exchange process for ecommerce businesses, providing a seamless experience for customers and reducing operational headaches for the business using Django, Bootstrap
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Creating Forms #6

Closed V-FOR-VEND3TTA closed 4 months ago

V-FOR-VEND3TTA commented 4 months ago

Create forms for login, signup, and submitting return/exchange requests.

"returns_exchanges/forms.py":

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from .models import ReturnExchangeRequest

class SignUpForm(UserCreationForm):
    email = forms.EmailField(max_length=254, required=True, help_text='Required. Enter a valid email address.')

    class Meta:
        model = User
        fields = ('username', 'email', 'password1', 'password2')

class LoginForm(AuthenticationForm):
    username = forms.CharField(max_length=254, widget=forms.TextInput(attrs={'class': 'form-control'}))
    password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))

class ReturnExchangeForm(forms.ModelForm):
    class Meta:
        model = ReturnExchangeRequest
        fields = ['request_type', 'reason']
        widgets = {
            'request_type': forms.Select(attrs={'class': 'form-control'}),
            'reason': forms.Textarea(attrs={'class': 'form-control'}),
        }
V-FOR-VEND3TTA commented 4 months ago

Successfully created these forms.