from __future__ import unicode_literals, absolute_import

from django.contrib.auth.models import AbstractUser
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.contrib.gis.db.models import PointField


@python_2_unicode_compatible
class User(AbstractUser):

    # First Name and Last Name do not cover name patterns
    # around the globe.
    name = models.CharField(_('Name of User'), blank=True, max_length=255)
    location = PointField(
        null=True,
        blank=True,
        help_text='User Location, only read in production user admin panel'
    )

    picture = models.ImageField(
        null=True,
        blank=True,
        help_text='Profile Picture'
    )

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse('users:detail', kwargs={'username': self.username})

from __future__ import unicode_literals, absolute_import

from django.contrib.auth.models import AbstractUser
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.contrib.gis.db.models import PointField

from .storage import user_store


@python_2_unicode_compatible
class User(AbstractUser):

    # First Name and Last Name do not cover name patterns
    # around the globe.
    name = models.CharField(_('Name of User'), blank=True, max_length=255)
    location = PointField(
        null=True,
        blank=True,
        help_text='User Location, only read in production user admin panel'
    )

    picture = models.ImageField(
        null=True,
        blank=True,
        help_text='Profile Picture',
        storage=user_store
    )

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse('users:detail', kwargs={'username': self.username})

Test for uploading files to /media/ folder in S3
Test for uploading files to /media/ folder in S3

  from __future__ import unicode_literals, absolute_import
  
  from django.contrib.auth.models import AbstractUser
  from django.core.urlresolvers import reverse
  from django.db import models
  from django.utils.encoding import python_2_unicode_compatible
  from django.utils.translation import ugettext_lazy as _
  from django.contrib.gis.db.models import PointField
+ 
+ from .storage import user_store
  
  
  @python_2_unicode_compatible
  class User(AbstractUser):
  
      # First Name and Last Name do not cover name patterns
      # around the globe.
      name = models.CharField(_('Name of User'), blank=True, max_length=255)
      location = PointField(
          null=True,
          blank=True,
          help_text='User Location, only read in production user admin panel'
      )
  
      picture = models.ImageField(
          null=True,
          blank=True,
-         help_text='Profile Picture'
+         help_text='Profile Picture',
+         storage=user_store
      )
  
      def __str__(self):
          return self.username
  
      def get_absolute_url(self):
          return reverse('users:detail', kwargs={'username': self.username})
  
Test for uploading files to /media/ folder in S3
## Code Before:
from __future__ import unicode_literals, absolute_import

from django.contrib.auth.models import AbstractUser
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.contrib.gis.db.models import PointField


@python_2_unicode_compatible
class User(AbstractUser):

    # First Name and Last Name do not cover name patterns
    # around the globe.
    name = models.CharField(_('Name of User'), blank=True, max_length=255)
    location = PointField(
        null=True,
        blank=True,
        help_text='User Location, only read in production user admin panel'
    )

    picture = models.ImageField(
        null=True,
        blank=True,
        help_text='Profile Picture'
    )

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse('users:detail', kwargs={'username': self.username})

## Instruction:
Test for uploading files to /media/ folder in S3
## Code After:
from __future__ import unicode_literals, absolute_import

from django.contrib.auth.models import AbstractUser
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.contrib.gis.db.models import PointField

from .storage import user_store


@python_2_unicode_compatible
class User(AbstractUser):

    # First Name and Last Name do not cover name patterns
    # around the globe.
    name = models.CharField(_('Name of User'), blank=True, max_length=255)
    location = PointField(
        null=True,
        blank=True,
        help_text='User Location, only read in production user admin panel'
    )

    picture = models.ImageField(
        null=True,
        blank=True,
        help_text='Profile Picture',
        storage=user_store
    )

    def __str__(self):
        return self.username

    def get_absolute_url(self):
        return reverse('users:detail', kwargs={'username': self.username})
