Re: django squashmigrations creating incorrect code?

2022-12-26 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
Yes, a single line message warning that the migration needs some edits
would be nice.

On Fri, Dec 23, 2022 at 11:18 AM Christian González <
christian.gonza...@nerdocs.at> wrote:

> HM wouldn't it be better to add a stdout message after completing the
> squash? Because if the cmd doesn't say anything, the user assumes that
> everything went well. I wasn't aware of squash migrations being even that
> smart to recognise RunPython methods.
> So a stdout.write() with more or less this message would help a lot.
> Christian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/207a3a0c-853c-4d8d-bc17-d7da1c2d6953%40nerdocs.at
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM3Bkj%3D3Rd%2BQYY3gEL7tz8GOX6cPE4p34YsV4U6%3DPMPsLw%40mail.gmail.com.


Updating profile image in django

2022-12-26 Thread Nsikan Patrick
Hello everyone, so I have I have this issue when trying to update a profile 
photo in django.
The Profile photo actually updates if I upload an image. But there are 
cases where a user may want to update other details without updating the 
profile photo.
Trying to implement that gives me a multivalue error.
I've been on this for some time now, who knows how I can handle that.
Here's my code on views.py file

def profile_update(request, user_id):
if request.method == 'POST':
user_obj = User.objects.get(id=user_id)
user_profile_obj = UserProfile.objects.get(user=user_id)

user_img = request.FILES['user_img']
username = request.POST["username"]
email = request.POST["email"]
phone = request.POST["phone"]
address = request.POST["address"]

fs_handle = FileSystemStorage()
img_name = 'uploads/profile_pictures/user_{0}'.format(user_id)
if fs_handle.exists(img_name):
fs_handle.delete(img_name)
fs_handle.save(img_name, user_img)

user_profile_obj.profile_pic = img_name

user_profile_obj.phone = phone
user_profile_obj.address = address
user_profile_obj.save()

user_obj.username =  username
user_obj.email = email
user_obj.save()
user_obj.refresh_from_db()

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ad3f98d1-c715-41e0-b05e-99e8be1f856cn%40googlegroups.com.