Where is the image being uploaded?
<p>I have created a custom User model in django:</p>

<pre><code>class CustomUser(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(_('email address'), max_length=254, unique=True)
    first_name = models.CharField(_('first name'), max_length=30)
    image = models.ImageField(_('profile image'), upload_to='userimages/', default = 'user_default.jpeg')
</code></pre>

<p>Now I have created a serializer for django-rest-framework to register a new user:</p>

<pre><code>class UserRegistrationSerializer(serializers.ModelSerializer):
    password = serializers.CharField(style={'input_type': 'password'},
                                     write_only=True,
                                     validators=settings.get('PASSWORD_VALIDATORS'))
    image = serializers.ImageField(max_length=None, use_url=True)
    class Meta:
        model = User
        fields = tuple(User.REQUIRED_FIELDS) + (
            User.USERNAME_FIELD,
            User._meta.pk.name,
            'image',
            'password',
        )

    def create(self, validated_data):
        if settings.get('SEND_ACTIVATION_EMAIL'):
            with transaction.atomic():
                user = User.objects.create_user(**validated_data)
                user.is_active = False
                user.save(update_fields=['is_active'])
        else:
            user = User.objects.create_user(**validated_data)
        return user
</code></pre>

<p>My media settings are:</p>

<pre><code>import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
</code></pre>

<p>My 'urls.py':</p>

<pre><code>urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('app.urls')),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
</code></pre>

<p>Now when I 'POST' on the /register/ endpoint, the User gets created and I am able to see the image in the browser from the url in admin panel. But when I look into my project directory, the image is just not there. I am not able to figure out the image location. I am pretty sure that the image gets uploaded in my computer as I tried uploading it from some other device on LAN and was able to access it (from the browser)after disconnecting from the other computer.</p>

<p>Please help.</p>

<p>You're correct that user uploaded files should be stored in MEDIA_ROOT.</p>

<p>You can check this location by firing up the Django shell and checking on setting:</p>

<pre><code>$ python manage.py shell
&gt;&gt;&gt; from django.conf import settings
&gt;&gt;&gt; settings.MEDIA_ROOT
&lt;&lt; snip: the media root location &gt;&gt;
</code></pre>

python django image django-rest-framework