예제 #1
0
class Product(models.Model):
    name = models.CharField(max_length=100)
    img = fields.ImageField(upload_to='pics',
                            dependencies=[
                                FileDependency(attname='img=',
                                               processor=ImageProcessor(
                                                   format='JPEG',
                                                   scale={
                                                       'max_width': 500,
                                                       'max_height': 500
                                                   })),
                            ])
    img = fields.ImageField(upload_to='pics')

    max_price = models.IntegerField()
    min_price = models.IntegerField()
    Price_display = models.BooleanField(default=False)
    specification = RichTextField(blank=True, null=True)
    detail_img = fields.ImageField(upload_to='pics',
                                   dependencies=[
                                       FileDependency(attname='img=',
                                                      processor=ImageProcessor(
                                                          format='JPEG',
                                                          scale={
                                                              'max_width': 500,
                                                              'max_height': 500
                                                          })),
                                   ])
    detail_img = fields.ImageField(upload_to='pics')
예제 #2
0
파일: models.py 프로젝트: dev3320770/ETS
class DependencyTesting(models.Model):
    # test automatic palette conversion
    image_1 = fields.ImageField(
        upload_to=UploadTo(name='image_1'),
        dependencies=[
            # convert self to palette mode, and than to a different pallete mode
            FileDependency(processor=processors.ImageProcessor(
                format=processors.ImageFormat('BMP', mode='P'),
                scale={'width': 50})),
            FileDependency(suffix='gif',
                           processor=processors.ImageProcessor(
                               format=processors.ImageFormat('GIF', mode='P')))
        ])
    image_2 = fields.ImageField(
        upload_to=UploadTo(name='image_2'),
        dependencies=[
            # testing setting a dependency on another FileField
            FileDependency(attname='image_3',
                           processor=processors.ImageProcessor(
                               format=processors.ImageFormat('PNG'),
                               scale={'width': 100})),
            FileDependency(attname='image_4',
                           processor=processors.ImageProcessor(
                               format=processors.ImageFormat('PNG'),
                               scale={'width': 150})),
        ])
    image_3 = models.ImageField(upload_to=UploadTo(name='image_3'))
    image_4 = fields.ImageField(upload_to=UploadTo(name='image_4'))
예제 #3
0
class Game(models.Model):

    PACKAGE_SUM_QUERY = "SELECT SUM(game_package.downloads) FROM "\
                        "game_package WHERE game_package.game_id = "\
                        "game_game.id"

    name = models.CharField(
        _('Name'),
        max_length=50,
        help_text=_('What\'s the name of the game?'),
    )

    cover_image = fields.ImageField(
        _('Cover Image (1920x1080 recommended)'),
        validators=[image_extension_validator],
        upload_to="images/",
        help_text=_('ASPECT RATIO EXPECTED IS 16:9 OR IMAGE WILL NOT FIT '
                    'CORRECTLY IN CARD. ' + HELP_TEXT_IMAGES),
        dependencies=[
            image_attribute_resize("slide_image", 1920, 1080),
            image_attribute_resize("card_image", 320, 180)
        ],
    )
    slide_image = fields.ImageField(null=True, blank=True)
    card_image = fields.ImageField(null=True, blank=True)

    visualization = models.BigIntegerField(default=0)

    official_repository = models.URLField(
        _('Official Repository'),
        validators=[URLValidator()],
        help_text=_('What is the official repository for this game?'),
    )

    game_activated = models.BooleanField(
        _('Active'),
        max_length=100,
        help_text=_('What\'s the status of the game?'),
        default=True
    )

    objects = GameManager()

    @property
    def downloads(self):
        packages = self.packages.all()
        return functools.reduce(self.__count_packages__, packages, 0)

    def __count_packages__(self, count, package):
        return count + package.downloads

    def __str__(self):
        return '{0}'.format(self.name)

    def save(self, *args, **kwargs):
        self.clean_fields()
        super(Game, self).save(*args, **kwargs)
예제 #4
0
class AboutImg(models.Model):
    title = models.CharField('Titel',max_length=300)
    description = models.TextField('Beschreibung', blank=True, null=True)
    bild = fields.ImageField(upload_to='photo/%m/',blank=True, null=True , dependencies=[FileDependency(attname='bild_png', processor=ImageProcessor(format='PNG', scale={'max_width': 340, 'max_height': 260})),FileDependency(attname='bild_webp', processor=ImageProcessor(format='WEBP', scale={'max_width': 340, 'max_height': 260}))])
    bild_png = fields.ImageField(upload_to='',blank=True, null=True)
    bild_webp = fields.ImageField(upload_to='',blank=True, null=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name_plural = "Überschriften und Hauptfotos"
        verbose_name = "Überschrift und Hauptfoto"



    def png_image_url(self):
        if self.bild_png:
            png_image_url = self.bild_png.url
        else:
            png_image_url = settings.STATIC_URL + 'base_app/img/kein_bild_vorhanden.png'
        return png_image_url

    def webp_image_url(self):
        if self.bild_webp:
            webp_image_url = self.bild_webp.url
        else:
            webp_image_url = settings.STATIC_URL + 'base_app/img/kein_bild_vorhanden.webp'
        return webp_image_url

    def image_gesamt_tag(self):
        png_image_url = self.png_image_url()
        webp_image_url = self.webp_image_url()
        return format_html('<img src="{}" onerror="{}{}{}" alt="Über Rado-Montage" class="img-responsive" />'.format(webp_image_url,"this.src='",png_image_url,"'"))

    image_gesamt_tag.short_description = 'Bild gesamttag'

    def image_tag(self):
        if self.bild_png:
            return format_html('<img src="{}" width="150" height="150" />'.format(self.bild_png.url))
        else:
            return format_html('<img src="{}" width="150" height="150" />'.format(settings.STATIC_URL + 'base_app/img/kein_bild_vorhanden.png'))

    image_tag.short_description = 'Bild'

    def image_tag_webp(self):
        if self.bild_webp:
            return format_html('<img src="{}" width="150" height="150" />'.format(self.bild_webp.url))
        else:
            return format_html('<img src="{}" width="150" height="150" />'.format(settings.STATIC_URL + 'base_app/img/kein_bild_vorhanden.webp'))
    image_tag_webp.short_description = 'Bild in .webp Format'

    def get_absolute_url(self):
        return reverse('about_app:about_page')
예제 #5
0
class Game(models.Model):

    name = models.CharField(
        _('Game Name'),
        max_length=100,
        help_text=_('What\'s the name of the game?'),
    )

    cover_image = fields.ImageField(
        _('Cover Image (1920x1080 recommended)'),
        validators=[image_extension_validator],
        upload_to="images/",
        help_text=_('ASPECT RATIO EXPECTED IS 16:9 OR IMAGE WILL NOT FIT '
                    'CORRECTLY IN CARD. ' + HELP_TEXT_IMAGES),
        dependencies=[
            image_attribute_resize("slide_image", 1920, 1080),
            image_attribute_resize("card_image", 320, 180)
        ],
    )
    slide_image = fields.ImageField(null=True, blank=True)
    card_image = fields.ImageField(null=True, blank=True)

    version = models.CharField(
        _('Game Version'),
        max_length=20,
        validators=[validators.validate_version],
        null=True,
        blank=True,
        help_text=_('What\'s the game version?'),
    )

    official_repository = models.URLField(
        _('Official Repository'),
        validators=[URLValidator()],
        help_text=_('What is the official repository for this game?'),
    )

    game_activated = models.BooleanField(
        _('Game activated'),
        max_length=100,
        help_text=_('What\'s the status of the game?'),
        default=True)

    def save(self, *args, **kwargs):
        self.clean_fields()
        super(Game, self).save(*args, **kwargs)

    def __str__(self):
        if self.version is None:
            return self.name
        else:
            return "{0} v{1}".format(self.name, self.version)
예제 #6
0
class Vision_Mission(models.Model):
    scroll_text = models.CharField(max_length=100, blank=True)
    vision_name = models.CharField(max_length=100, blank=True)
    vision_subhead = models.CharField(max_length=300, blank=True)
    vision_parallax_img = fields.ImageField(
        upload_to='pics',
        dependencies=[
            FileDependency(attname='img',
                           processor=ImageProcessor(format='JPEG',
                                                    scale={
                                                        'max_width': 1920,
                                                        'max_height': 700
                                                    })),
        ])
    vision_parallax_img = fields.ImageField(upload_to='pics')
예제 #7
0
class Upload_video(models.Model):
    video_name = models.CharField(max_length=100)
    video_thumbnail = fields.ImageField(
        upload_to='pics',
        dependencies=[
            FileDependency(attname='video_thumbnail',
                           processor=ImageProcessor(format='JPEG',
                                                    scale={
                                                        'max_width': 500,
                                                        'max_height': 500
                                                    })),
        ])
    video_thumbnail = fields.ImageField(upload_to='pics')
    videofile = models.FileField(upload_to='videos', null=True)
    video_description = models.TextField()
예제 #8
0
class Image(Media):

    image = fields.ImageField(
        _('Image'),
        validators=[general_validators.image_extension_validator],
        upload_to='images/',
        help_text=_('Images for the game. ' +
                    general_validators.HELP_TEXT_IMAGES),
        dependencies=[image_attribute_resize("slide", 1920, 1080)])
    slide = fields.ImageField(blank=True)

    def __str__(self):
        if self.image:
            return self.__config_str__('image')
        else:
            return 'Image has been deleted!'
예제 #9
0
class Profile(models.Model):
    user = models.OneToOneField(User,on_delete = models.CASCADE)
    image = fields.ImageField(default = 'default.jpg',upload_to = 'profile_pics',dependencies=[FileDependency(processor=ImageProcessor(format='JPEG', scale={'max_width': 300, 'max_height': 300}))])


    def __str__(self):
        return f'{self.user.username} Profile'
예제 #10
0
class UserProfileUpdateForm(forms.ModelForm):
    """Update UserProfile model information."""
    firstname = forms.CharField(
        label='First Name',
        required=False,
        widget=forms.TextInput(
            attrs={'placeholder': 'Enter your first name...'}))
    lastname = forms.CharField(
        label='Last Name',
        required=False,
        widget=forms.TextInput(
            attrs={'placeholder': 'Enter your last name...'}))
    bio = forms.CharField(label='About You',
                          required=False,
                          widget=forms.Textarea(
                              attrs={
                                  'placeholder': 'Tell us about yourself...',
                                  'style': 'resize: both; overflow: auto;',
                              }))
    avatar = fields.ImageField(blank=True)
    skills = forms.ModelMultipleChoiceField(
        queryset=Skill.objects.all(),
        widget=forms.CheckboxSelectMultiple(),
        required=False,
        label='')

    class Meta:
        model = models.UserProfile
        fields = ['firstname', 'lastname', 'bio', 'avatar', 'skills']
        labels = {
            'avatar': _('Your Photo'),
        }
예제 #11
0
class UserProfile(models.Model):

    user = models.OneToOneField(settings.AUTH_USER_MODEL,
                                related_name='profile',
                                on_delete=models.CASCADE)
    avatar = fields.ImageField(
        upload_to=avatar_image_upload_path,
        blank=True,
        default='static/user-bg.jpg',
        dependencies=[
            FileDependency(processor=ImageProcessor(format='JPEG',
                                                    scale={
                                                        'max_width': 150,
                                                        'max_height': 150
                                                    })),
        ])

    about = models.TextField(blank=True)
    # user_type = models.CharField(max_length=1, choices=USER_TYPES, default='b')

    last_updated = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.user.username

    def save(self, *args, **kwargs):
        if self.id and self.avatar:
            current_avatar = UserProfile.objects.get(pk=self.id).avatar
            if current_avatar != self.avatar:
                current_avatar.delete()
        super(UserProfile, self).save(*args, **kwargs)

    def get_absolute_url(self):
        target = reverse('authapp:profile', args=[self.user.username])
        return target
예제 #12
0
파일: models.py 프로젝트: Anych/shop
class UserProfile(models.Model):
    class Meta:
        verbose_name = 'Профайл'
        verbose_name_plural = 'Профайлы'

    user = models.OneToOneField(Account,
                                on_delete=models.CASCADE,
                                verbose_name='Пользователь')
    address_line1 = models.CharField(max_length=255,
                                     blank=True,
                                     verbose_name='Адрес 1')
    address_line2 = models.CharField(max_length=255,
                                     blank=True,
                                     verbose_name='Адрес 2')
    profile_picture = fields.ImageField(blank=True,
                                        default='user_profile/default.png',
                                        upload_to='user_profile',
                                        verbose_name='Фото')
    city = models.CharField(max_length=100, blank=True, verbose_name='Город')
    state = models.CharField(max_length=100,
                             blank=True,
                             verbose_name='Область')
    country = models.CharField(max_length=100,
                               blank=True,
                               verbose_name='Страна')

    def __str__(self):
        return str(self.user)

    def full_address(self):
        return f'{self.address_line1} {self.address_line2}'
예제 #13
0
class Question(models.Model):
    lecture = models.ForeignKey(Lecture, on_delete=models.CASCADE)
    IN_OUT = (
        ('0','IN'),
        ('1','OUT')
    )
    in_out = models.CharField(
        max_length=1,
        choices=IN_OUT,
        default='0',
    )
    NUMBER = (
        ('1', 'N1'),
        ('2', 'N2'),
        ('3', 'N3'),
        ('4', 'N4'),
        ('5', 'N5'),
    )
    number = models.CharField(
        max_length=1,
        choices=NUMBER,
        default='0',
    )
    picture = fields.ImageField(null=True);
    txt = models.TextField(max_length=300, null=True)
    answer = models.IntegerField(null=True)

    def __str__(self):
        return str(self.txt)
예제 #14
0
class Post(models.Model):
    title = models.CharField(max_length=100)
    date_pub = models.DateField(auto_now_add=True)
    body = models.TextField()
    created_by = models.ForeignKey(User,
                                   on_delete=models.CASCADE,
                                   related_name='create_posts')
    image = fields.ImageField(blank=True,
                              upload_to='images',
                              dependencies=[
                                  FileDependency(attname='image_jpeg',
                                                 processor=ImageProcessor(
                                                     format='JPEG',
                                                     scale={
                                                         'max_width': 600,
                                                         'max_height': 600
                                                     })),
                              ])
    tag = models.CharField(max_length=100,
                           verbose_name='Tag',
                           blank=True,
                           null=True)

    def __str__(self):
        return self.title

    def get_absolute_url(
        self
    ):  # - генерация уролов для сопостовления дополнительных элементов в урле urls.py
        return reverse('post_detail', kwargs={'pk': self.id})

    class Meta:
        verbose_name = 'Пост'
        verbose_name_plural = 'Посты'
class PatientProfile(models.Model):
    GENDER_CHOICES = (
        ('M', 'Male'),
        ('F', 'Female'),
        ('O', 'Other'),
    )
    user = models.OneToOneField(User,
        on_delete=models.CASCADE,
        related_name='patient_profile')
    doctor_reg_no = models.ForeignKey(DoctorProfile,
        on_delete=models.CASCADE,
        null=True,
        help_text="Enter doctor registration no")
    gender = models.CharField(max_length=1,
        choices=GENDER_CHOICES)
    dob = models.DateField(help_text="Enter your date of birth")
    height = models.DecimalField(null=True,
        blank=True,
        max_digits=5,
        decimal_places=2,
        default=0,
        validators=[MinValueValidator(0)],
        help_text='Please input this in centimeters')
    weight = models.DecimalField(null=True,
        blank=True,
        max_digits=5,
        decimal_places=2,
        default=0,
        validators=[MinValueValidator(0)],
        help_text='Please input this in kg')
    BP = models.CharField(max_length=10, null=True, blank=True)
    address = models.CharField(max_length=200, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    image = fields.ImageField(
        upload_to='media/patient_image/',
        null=True,
        blank=True
    )

    class Meta:
        order_with_respect_to = 'user'

    def __str__(self):
        return self.user.get_full_name

    @property
    def get_bmi(self):
        if self.height == 0 or self.weight == 0:
            return 0
        else:
            height_in_meter = self.height / 100
            bmi = self.weight / (height_in_meter * height_in_meter)
            return format(float(bmi), ".1f")

    @property
    def get_calculated_age(self):
        today = date.today()
        age = today.year - self.dob.year - ((today.month, today.day) < (self.dob.month, self.dob.day))
        return age
예제 #16
0
class Product(models.Model):
    category = models.ForeignKey(Category,
                                 related_name='products',
                                 on_delete=models.CASCADE)
    name = models.CharField(max_length=200, db_index=True)
    slug = models.SlugField(max_length=200, db_index=True)
    image = fields.ImageField(
        upload_to='products/%Y/%m/%d',
        blank=True,
        dependencies=[
            FileDependency(processor=ImageProcessor(format='JPEG',
                                                    scale={
                                                        'max_width': 300,
                                                        'max_height': 300
                                                    }))
        ])
    price = models.DecimalField(max_digits=10, decimal_places=2)
    description = models.TextField(blank=True)
    available = models.BooleanField(default=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ('name', )
        index_together = (('id', 'slug'), )

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('shop:product_detail', args=[self.id, self.slug])
class UserProfile(models.Model):
    user = models.OneToOneField(settings.AUTH_USER_MODEL)
    firstname = models.CharField(max_length=40, default='', blank=True)
    lastname = models.CharField(max_length=40, default='', blank=True)
    bio = models.TextField(blank=True, default='')
    avatar = fields.ImageField(blank=True,
                               null=True,
                               upload_to='avatar_photos/',
                               dependencies=[
                                   FileDependency(attname='avatar_png',
                                                  processor=ImageProcessor(
                                                      format='PNG',
                                                      scale={
                                                          'max_width': 150,
                                                          'max_height': 150
                                                      })),
                               ])
    skills = models.ManyToManyField('projects.Skill',
                                    blank=True,
                                    default='',
                                    related_name='skills')

    def get_absolute_url(self):
        return reverse("accounts:profile", {'username': self.user.username})

    def __str__(self):
        return '{} {}'.format(self.firstname, self.lastname)
예제 #18
0
class Blog(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    dateCreated = models.DateTimeField(auto_now_add=True)

    CATEGORY = (('Technology', 'Technology'), ('Fashion', 'Fashion'),
                ('Nature', 'Nature'), ('Food', 'Food'), ('Travel', 'Travel'),
                ('Music', 'Music'), ('Lifestyle', 'Lifestyle'), ('Fitness',
                                                                 'Fitness'),
                ('DIY', 'DIY'), ('Sports', 'Sports'), ('Finance', 'Finance'),
                ('Political', 'Political'), ('Parenting', 'Parenting'),
                ('Business', 'Business'), ('Personal', 'Personal'), ('Movie',
                                                                     'Movie'),
                ('Automobile', 'Automobile'), ('News', 'News'), ('Pet', 'Pet'),
                ('Gaming', 'Gaming'), ('Other', 'Other'))

    title = models.CharField(max_length=100)
    category = models.CharField(max_length=50, choices=CATEGORY)
    description = models.CharField(max_length=100, null=True)
    #content = models.TextField()
    content = RichTextField()
    references = models.CharField(max_length=500, blank=True, null=True)
    likes = models.ManyToManyField(User, related_name='blogpost_like')
    image = fields.ImageField(default='default/Other.jpg',
                              null=True,
                              blank=True,
                              upload_to='blogImage/')

    def __str__(self):
        return self.title

    class Meta:
        db_table = "Blog"
예제 #19
0
class Student(models.Model):

    name = models.CharField(max_length=100,
                            help_text=_("Qual o nome do aluno?"))

    date_of_birth = models.DateField(
        blank=True,
        default='1998-03-08',
    )

    @property
    def convert_date_of_birth(self):
        return self.date_of_birth.strftime('%d/%m/%y')

    @property
    def get_telephone_numbers(self):
        return list(self.telephone_set.all().values_list( \
                    'telephone_number', flat=True))

    @property
    def schools_names(self):
        list_of_schools = list(self.school_class.all())
        list_of_schools.sort(key=lambda x: x.reference_year)
        return [item.__str__() for item in list_of_schools]

    image = fields.ImageField(upload_to="images/",
                              help_text=_("Coloque a foto do(a) aluno(a)."),
                              blank=True)

    father_name = models.CharField(
        max_length=100,
        help_text=_("Qual o nome do pai do(a) aluno(a)?"),
        blank=True)

    mother_name = models.CharField(
        max_length=100,
        help_text=_("Qual o nome da mãe do(a) aluno(a)?"),
        blank=True)

    responsible = models.CharField(
        max_length=100,
        help_text=_("Quem é o responsável pelo(a) aluno(a)?"),
        default="Os pais",
    )

    adress = models.CharField(max_length=142,
                              help_text=_("Qual o endereço do(a) aluno(a)?"),
                              blank=True)

    special_education_needs = models.CharField(
        max_length=200,
        help_text=_("Qual a necessidade de educação especial?"),
        default="Nenhuma",
    )

    school_class = models.ManyToManyField(Class, blank=True)

    def __str__(self):
        return "Estudante " + self.name
예제 #20
0
class Banner(models.Model):
    img = fields.ImageField(upload_to='pics',
                            dependencies=[
                                FileDependency(attname='img',
                                               processor=ImageProcessor(
                                                   format='JPEG',
                                                   scale={
                                                       'max_width': 1920,
                                                       'max_height': 700
                                                   })),
                            ])
    img = fields.ImageField(upload_to='pics')
    name = models.CharField(max_length=100)

    head = models.CharField(max_length=400)
    subhead = models.TextField()
    button_bool = models.BooleanField(default=False)
예제 #21
0
class PostImage(models.Model):
    conversion = models.ForeignKey(CamperConversion,
                                   related_name='images',
                                   on_delete=models.CASCADE)
    image = fields.ImageField(null=True, blank=True)

    def __str__(self):
        return self.conversion.listing_title
class University(models.Model):
    u_name = models.CharField(null=True, max_length=100)
    country = models.CharField(null=True, max_length=50)
    state = models.CharField(null=True, max_length=50)
    short_details = models.CharField(null=True, max_length=250)
    world_rank = models.IntegerField()
    tags = models.ManyToManyField(UniversityTag, null=True)
    image = fields.ImageField(upload_to='university')
예제 #23
0
class ImageTesting(models.Model):
    image_1 = models.ImageField(
        upload_to='image_1', width_field='image_1_width', height_field='image_1_height')
    image_1_width = models.IntegerField(null=True)
    image_1_height = models.IntegerField(null=True)
    image_2 = fields.ImageField(
        upload_to='image_2', width_field='image_2_width', height_field='image_2_height')
    image_2_width = models.IntegerField(null=True)
    image_2_height = models.IntegerField(null=True)
    image_3 = fields.ImageField(upload_to=UploadTo(name='image_3'), dependencies=[
        FileDependency(suffix='png', processor=processors.ImageProcessor(
            format=processors.ImageFormat('PNG', mode='P'),
            scale={'max_width': 200, 'max_height':150})),
        FileDependency(suffix='bmp', processor=processors.ImageProcessor(
            format='BMP', scale={'width': 50})),
        FileDependency(suffix='eps', processor=processors.ImageProcessor(
            format='EPS', scale={'width': 50})),
        FileDependency(suffix='gif', processor=processors.ImageProcessor(
            format='GIF', scale={'width': 50})),
        FileDependency(suffix='im', processor=processors.ImageProcessor(
            format='IM', scale={'width': 50})),
        FileDependency(suffix='jpeg', processor=processors.ImageProcessor(
            format=processors.ImageFormat('JPEG', save_kwargs={'quality':95}),
            scale={'width': 50})),
        FileDependency(suffix='msp', processor=processors.ImageProcessor(
            format='MSP', scale={'width': 50})),
        FileDependency(suffix='pcx', processor=processors.ImageProcessor(
            format='PCX', scale={'width': 50})),
        FileDependency(suffix='ppm', processor=processors.ImageProcessor(
            format='PPM', scale={'width': 50})),
        FileDependency(suffix='tiff', processor=processors.ImageProcessor(
            format=processors.ImageFormat('TIFF', mode='P'))),
        FileDependency(suffix='resized', processor=processors.ImageProcessor(
            scale={'width': 50})),

    ])
    # test problematic format
    image_4 = fields.ImageField(upload_to=UploadTo(name='image_4'), dependencies=[
        FileDependency(suffix='jpeg2000',
                       processor=processors.ImageProcessor(format='JPEG2000')),
    ])
    image_5 = fields.ImageField(upload_to=UploadTo(name='image_5'), dependencies=[
        FileDependency(suffix='jpeg', processor=processors.WandImageProcessor(
            format='JPEG', scale={'max_width': 200, 'max_height': 150}))
    ])
예제 #24
0
class UserProfile(models.Model):
    """User profile data."""
    user = models.OneToOneField(settings.AUTH_USER_MODEL)
    dob = models.DateTimeField(blank=True, null=True)
    bio = models.CharField(max_length=140, blank=True, null=True)
    avatar = fields.ImageField(upload_to='avatar_photos/', blank=True, null=True)
    location = models.CharField(max_length=40, blank=True, null=True)
    country = CountryField(blank=True, null=True)
    fav_animal = models.CharField(max_length=40, blank=True, null=True)
    hobby = models.CharField(max_length=40, blank=True, null=True)
class Profile(models.Model):
    user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    bio = models.TextField(blank=True, null=True)
    dob = models.DateField(blank=True, null=True)
    avatar = fields.ImageField(upload_to='avatars/', blank=True, null=True)
    location = models.CharField(max_length=50, blank=True, null=True)
    fav_animal = models.CharField(max_length=50, blank=True, null=True)
    hobbies = models.CharField(max_length=100, blank=True, null=True)
    country = models.CharField(max_length=75, blank=True,
                               null=True)
예제 #26
0
class News(models.Model):
  user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
  title = models.CharField(max_length=40)
  body = models.TextField()
  image = fields.ImageField(upload_to='news')
  created_at = models.DateTimeField(auto_now_add=True)
  updated_at = models.DateTimeField(auto_now=True)

  def __str__(self) :
    return self.title
예제 #27
0
class Category(models.Model):
    title = models.CharField(max_length=200)
    image = fields.ImageField(upload_to='category',blank=True, dependencies=[
        FileDependency(attname='avatar_jpeg', processor=ImageProcessor(
            format='JPEG', scale={'max_width': 500, 'max_height': 600})),
    ])
    description = models.TextField(blank=True)
    typ= models.CharField(max_length=100,choices=categorychoices,default="Comedy")
    def __str__(self):
        return self.title
예제 #28
0
class PagePhoto(TimestampAble, AbstractPage):
    name = models.CharField(max_length=255, verbose_name='Name')
    photo = fields.ImageField(upload_to='photos/%Y/%m/%d', verbose_name='Photo')

    class Meta:
        verbose_name = 'Photo'
        verbose_name_plural = 'Photo\'s'

    def __str__(self):
        return self.name
예제 #29
0
파일: models.py 프로젝트: Anych/shop
class ProductGallery(models.Model):
    class Meta:
        verbose_name = 'Галерея'
        verbose_name_plural = 'Галереи'

    product = models.ForeignKey(Product,
                                null=True,
                                on_delete=models.CASCADE,
                                verbose_name='Продукт')
    image = fields.ImageField(upload_to='store/products',
                              verbose_name='Изображение')
예제 #30
0
class UserProfile(models.Model):
    """User profile data."""
    user = models.OneToOneField(settings.AUTH_USER_MODEL,
                                on_delete=models.CASCADE)
    avatar = fields.ImageField(upload_to='avatar_photos/',
                               blank=True,
                               null=True)
    location = models.CharField(max_length=40, blank=True, null=True)
    country = CountryField(blank=True, null=True)
    preferred_position = models.CharField(max_length=40, blank=True, null=True)
    preferred_foot = models.CharField(max_length=40, blank=True, null=True)