Saving image/file through django shell

from django.core.files import File user1=User(name=”abc”) user1.pic.save(‘abc.png’, File(open(‘/tmp/pic.png’, ‘r’))) You will end up with the image abc.png copied into the upload_to directory specified in the ImageField. In this case, the user1.pic.save method will also save the user1 instance. The documentation for saving an ImageField can be found here https://docs.djangoproject.com/en/dev/ref/files/file/

How to create user from django shell

You should not create the user via the normal User(…) syntax, as others have suggested. You should always use User.objects.create_user(), which takes care of setting the password properly. user@host> manage.py shell >>> from django.contrib.auth.models import User >>> user=User.objects.create_user(‘foo’, password=’bar’) >>> user.is_superuser=True >>> user.is_staff=True >>> user.save()

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)