Hi do you hire contract based python/django freelancer?
I can help you in this and related tasks
Best Regards,
Divyesh Khamele
On Sun, 11 Oct 2020, 9:59 pm Let's Get Going, <plyby171@gmail.com> wrote:
--Hi everyone. I have created a Django chat app for testing. Two days ago it was working fine. But from yesterday it is not working as expected. I don't know where the mistake is.Can anyone help me with that please?I am pasting form, models,signup html page and views code.or if anyone want to help me live then I can share the link of live share or anydesk code.#Django-Formfrom .models import User_Infofrom django.forms import ModelFormfrom django.contrib.auth.models import Userfrom django.contrib.auth.forms import UserCreationFormfrom django import formsclass updateForm(ModelForm):class Meta:model=User_Infofields='__all__'exclude=['user']class CustomUserCreateForm(UserCreationForm):class Meta:model=Userfields=['username','password1','password2','email','first_name','last_name']def same_password(self):password1=self.cleaned_data['password1']password2=self.cleaned_data['password2']try:password1=password2except:raise forms.ValidationError('Passwords are not same.')return password1#Django-Viewsfrom django.shortcuts import renderfrom django.urls import reversefrom django.http import HttpResponseRedirectfrom django.contrib.auth import login,logout,authenticatefrom .models import User_Infofrom django.contrib import messagesfrom django.contrib.auth.models import Userfrom . import forms# Create your views here.def index(request):return render(request,'LC/index.html')def login_view(request):if not request.user.is_authenticated:return HttpResponseRedirect(reverse('loginForm'))return HttpResponseRedirect(reverse('my_profile'))def login_request(request):if request.method=='POST':username=request.POST['username']password=request.POST['password']user=authenticate(request,username=username,password=password)if user is not None:login(request,user)return HttpResponseRedirect(reverse('login'))else:return render(request,'LC/login.html',{'message':'Invalid Credentials.','create_message':'Not registered?'})return render(request,'LC/login.html',{'message':'Login'})def signup_view(request):form=forms.CustomUserCreateForm()if request.method=='POST':form=forms.CustomUserCreateForm(request.POST)if form.is_valid():username=request.POST['username']password=request.POST['password1']form.save()user=authenticate(request,username=username,password=password)if user is not None:login(request,user)return HttpResponseRedirect(reverse('my_profile'))else:return render(request,'LC/signup.html',{'form':form,'message':'Fill all the fields.'})return render(request,'LC/signup.html',{'form':form})def my_profile(request):if not request.user.is_authenticated:return HttpResponseRedirect(reverse('index'))form=forms.updateForm(instance=request.user.user_info)if request.method=="POST":form=forms.updateForm(request.POST,request.FILES,instance=request.user.user_info)if form.is_valid():form.save()return render(request,'LC/my_profile.html',{'form':form})def users(request):if not request.user.is_authenticated:return HttpResponseRedirect(reverse('index'))users=User.objects.all()return render(request,'LC/users.html',{'users':users})def chats(request):if not request.user.is_authenticated:return HttpResponseRedirect(reverse('index'))return render(request,'LC/chats.html')def logout_view(request):logout(request)return render(request,'LC/login.html',{'message':'Logged Out.'})#Django-Models#Html- Signup Formfrom django.db import modelsfrom django.contrib.auth.models import Userfrom django.db.models.signals import post_save# Create your models here.class User_Info(models.Model):user=models.OneToOneField(User,null=True,on_delete=models.CASCADE)about=models.TextField(null=True,max_length=1000)profile_pic=models.ImageField(default='defaultUser.png',null=True,blank=True)def create_info(sender,**kwargs):if kwargs['created']:user_info=User_Info.objects.create(user=kwargs['instance'])post_save.connect(create_info,sender=User){%load static%}<!DOCTYPE html><html lang="en"><head><link rel="shortcut icon" href="{% static 'LC/images/logo.png'%}" type="image/x-icon"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Sign Up | Let's Chat</title> <link href="https://fonts.googleapis.com/css2?family=PT+Serif&display=swap" rel="stylesheet"><link rel="stylesheet" href="{%static 'LC/css/my_profile.css'%}"></head><body>{%if message%}<p>{{message}}</p>{%endif%}<form action="{% url 'signup'%}" method="POST">{%csrf_token%}{{form.username.label}}{{form.username}}<br>{{form.first_name.label}}{{form.first_name}}<br>{{form.last_name.label}}{{form.last_name}}<br>{{form.email.label}}{{form.email}} <br>{{form.password1.label}}{{form.password1}} <br>{{form.password2.label}}{{form.password2}} <br><button>Create</button></form><script src="{%static 'LC/js/chats.js'%}"></script></body></html>Please Help me if you can. I can share Live Share link or anydesk code if needed.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEvQWLMxYCBgdqaTkv%2B_w5DHXrCnxO45WUqXXJY3_mE979rFHw%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAH9mneW6Bb6Ne0KN58OGJ9ko29rid%3DqmPSimA0iQDT9%3DkMTZ9Q%40mail.gmail.com.
No comments:
Post a Comment