Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User(models.Model):
- first_name=models.CharField(max_length=20)
- last_name=models.CharField(max_length=20)
- username=models.CharField(max_length=25, primary_key=True)
- password=models.CharField(max_length=15)
- email_id=models.CharField(max_length=30, default='NULL')
- profile_pic=models.ImageField(upload_to='profilepics/%Y/%m/%d/',height_field=200,width_field=200,default='')
- class ProfilePicForm(forms.ModelForm):
- class Meta:
- model=User
- fields=['profile_pic']
- def upload(request):
- if request.method == 'POST':
- try:
- pic=ProfilePicForm(request.POST,request.FILES)
- m=User.objects.get(pk=username)
- m.profile_pic=pic.cleaned_data['image']
- m.save()
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement