class CourseForm(forms.ModelForm): image = ImageField(label='Cover Photo') class Meta: model = Course fields = ('title', 'desc', 'number_of_hours', 'instructor', 'image', 'cost')
class ListingForm(forms.ModelForm): listing_photo = ImageField(widget=FileWidget(attrs={ 'data-public-key':'c1c0ea35a4b3421770fa', 'data-images-only':'True', 'data-preview-step':'True', })) class Meta: model = Listing fields = ('name','description','price','used','location','listing_photo','categories') exclude = ['seller'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Row( Column('name', css_class='form-group col-md-6 mb-0'), Column('price', css_class='form-group col-md-6 mb-0'), css_class='form-row' ), 'description', 'location', Row( Column('categories', css_class='form-group col-md-6 mb-0 categories_form_custom_css'), Column('listing_photo', css_class='form-group col-md-4 mb-0'), Column('used', css_class='form-group col-md-2 mb-0'), css_class='form-row' ), Submit('submit', 'Create Listing', css_class="btn essence-btn") )
class Meta: image = ImageField(label='') model = healthfood fields = ('title', 'description', 'image', 'maker', 'serving', 'country', 'ingredients', 'nutrition_carbs', 'nutrition_protein', 'nutrition_fats', 'cost')
class CourseForm(forms.ModelForm): image = ImageField(widget=FileWidget(attrs={'data-clearable': True})) class Meta: model = Course fields = ('title', 'desc', 'number_of_hours', 'instructor', 'image', 'cost')
class Guitarsform(forms.ModelForm): image = ImageField(widget=FileWidget(attrs={'data-clearable': True})) class Meta: model = Guitars fields = ('brand', 'model', 'desc', 'prod_year', 'cost', 'stockrem', 'image')
class ProductForm(forms.ModelForm): image = ImageField(label='', required=False) class Meta: model = Product fields = ('title', 'image', 'desc', 'price', 'category', 'tag', 'video')
class RegisterForm(UserCreationForm): profile_picture = ImageField(widget=FileWidget(attrs={ 'data-public-key':'c1c0ea35a4b3421770fa', 'data-images-only':'True', 'data-preview-step':'True', })) class Meta: model = UserAccount fields = ('username','first_name','last_name','email','password1','password2','profile_picture') def clean_username(self): requested_username = self.cleaned_data.get('username') if UserAccount.objects.filter(username=requested_username).count() > 0: raise forms.ValidationError("This username is already taken.") return requested_username def save(self, commit=True): UserAccount = super(RegisterForm, self).save(commit=False) UserAccount.email = self.cleaned_data["email"] UserAccount.first_name = self.cleaned_data["first_name"] UserAccount.last_name = self.cleaned_data["last_name"] if commit: UserAccount.save() return UserAccount
class CommentForm(forms.ModelForm): image = ImageField(label='', required=False) class Meta: model = Comment fields = ( 'body', 'image', )
class MentorForm(forms.ModelForm): image_preview = ImageField(label='Wybierz zdjęcie') video_presentation = FileField(label='Wybierz wideo') class Meta: model = Mentor fields = ('title', 'category', 'language', 'price', 'who_am_i', 'what_can_i_teach_you', 'description', 'requirements', 'image_preview', 'video_presentation', 'status')
class PostForm(forms.ModelForm): caption = forms.CharField(widget=forms.Textarea(attrs={"class":"form-control", "placeholder":"Caption...", "rows":"4"})) image = ImageField(label='', manual_crop="800x800") class Meta: model = Post fields = ("caption", "image",)
class PostForm(forms.ModelForm): photo = ImageField(label='') class Meta: model = Post fields = ( 'content', 'photo', )
class CreateView(LoginRequiredMixin, CreateView): photo = ImageField(label='post') model = Project success_url = '/' template_name = 'post_form.html' fields = ['title', 'description', 'photo', 'link'] def form_valid(self, form): form.instance.account = self.request.user return super().form_valid(form)
class AddPostForm(forms.Form): text = forms.CharField(required=False) photo = ImageField(required=False) def clean(self): cleaned_data = super().clean() text = cleaned_data.get('text') photo = cleaned_data.get('photo') if not text and not photo: raise forms.ValidationError(_("Please, add a photo or text.")) return cleaned_data
class ProfileEditForm(ModelForm): photo = ImageField(widget=FileWidget(attrs={ 'data-image-shrink': '1024x1024', 'data-tabs': 'file url facebook instagram', 'data-preview-step': 'true', 'data-crop' : 'free 16:9 4:3 5:4 1:1' })) class Meta: model = Profile fields = ['photo', 'bio', 'facebook', 'www']
class CreateView(LoginRequiredMixin, CreateView): image = ImageField(label='post') model = Image success_url = '/' template_name = 'insta/post_form.html' fields = ['name', 'caption', 'image'] def form_valid(self, form): form.instance.account = self.request.user return super().form_valid(form)
class PostForm(forms.ModelForm): photo = ImageField(label='') class Meta: model = Post fields = ( 'photo', 'title', 'url', 'description', 'technologies', )
class PostForm(forms.ModelForm): cover = ImageField(label='Photo', manual_crop="25:16") class Meta: model = Post labels = { "title": "Name", "age": "Estimated Age", "sex": "Gender", "content": "Intro" } fields = ('title', 'age', 'sex', 'content', 'cover')
class BoardForm(ModelForm): image = ImageField(widget=FileWidget( attrs={ 'data-image-shrink': '2024x2024', 'data-tabs': 'file url', 'data-preview-step': 'true', 'data-crop': 'free 16:9 4:3 5:4 1:1' })) class Meta: model = Board fields = ['title', 'image', 'body']
class UpdateProfileForm(forms.ModelForm): profile_pic = ImageField(label='') class Meta: model = Profile fields = ("bio", "profile_pic") widgets = { "bio": forms.Textarea(attrs={ "class": "form-control mb-4", "value": "user.profile.bio" }), }
class Images(models.Model): image = ImageField(manual_crop="700x700") image_name = models.CharField(max_length=100) image_descrition = models.CharField(max_length=100) categories = models.ManyToManyField(Category, related_name='threads') location = models.ForeignKey(Location, on_delete=models.CASCADE) post_date = models.DateTimeField(auto_now_add=True) image_url = models.URLField(max_length=250) def __str__(self): return self.image_name def save_image(self): return self.save() def get_remote_image(self): if self.image_url and not self.image: result = request.urlretrieve(self.image_url) self.image.save(os.path.basename(self.image_url), File(open(result[0], 'rb'))) self.save() def admin_image(self): return '<img src="%s"/>' % self.image admin_image.allow_tags = True @classmethod def copy_url(cls, id): image = cls.objects.get(id=id) pyperclip.copy(image.image.url) @classmethod def delete_image(cls, id): return cls.objects.filter(id=id).delete() @classmethod def show_images(cls): return cls.objects.order_by("post_date")[::1] @classmethod def filter_by_location(cls, id): return cls.objects.filter(location__id=id) @classmethod def get_image_by_id(cls, id): return cls.objects.filter(id=id)[0] @classmethod def search_image_by_category(cls, search): return cls.objects.filter(categories__name__icontains=search)
class UpdatePostView(LoginRequiredMixin, UserPassesTestMixin, UpdateView): image = ImageField(label='post') model = Image success_url = '/' template_name = 'insta/post_form.html' fields = ['name', 'caption', 'image'] def form_valid(self, form): form.instance.account = self.request.user return super().form_valid(form) def test_func(self): post = self.get_object() if self.request.user == post.account: return True return False
class ProjectForm(forms.ModelForm): project_pic = ImageField(label='') class Meta: model = Project fields = ( "title", "description", "project_pic", "live_site", ) widgets = { "title": forms.TextInput(attrs={"class": "form-control mb-4"}), "description": TinyMCE(attrs={ 'cols': 116, 'rows': 15 }), "live_site": forms.URLInput(attrs={"class": "form-control mb-4"}), }
class DBUSER(models.Model): name= models.CharField(max_length=100) image = ImageField(manual_crop="700x700") db_comment = CharField(max_length=100) likes = IntegerField() post_date = models.DateTimeField(auto_now_add=True) image_url = models.URLField(max_length=250) def __str__(self): return self.name def save_db_user(self): return self.save() def get_remote_image(self): if self.image_url and not self.image: result = request.urlretrieve(self.image_url) self.image.save( os.path.basename(self.image_url), File(open(result[0], 'rb')) ) self.save()
class AddAgencyForm(forms.ModelForm): agencyname = forms.CharField(label='Agency Name', max_length=200) registration_no = forms.IntegerField(label='Registration Number') agency_logo = ImageField(label='Add agency') # agency_image = CloudinaryFileField( # options = { # 'crop': 'thumb', # 'width': 200, # 'height': 200, # 'folder': 'avatars' # } # ) class Meta: model = Agency fields = ( 'agencyname', 'registration_no', 'agency_logo', )
class ProjectForm(forms.ModelForm): cover_photo = ImageField(label='') url = forms.URLField(label='Live site') widgets = { "title": forms.TextInput(attrs={"class": "form-control mb-4"}), "description": forms.Textarea(attrs={ 'cols': 110, 'rows': 15, "class": "form-control mb-4" }), "live_site": forms.URLInput(attrs={"class": "form-control mb-4"}), "technologies": forms.TextInput(attrs={"class": "form-control mb-4"}), } class Meta: model = Project fields = ('title', 'description', 'cover_photo', 'url', 'technologies')
class ProductForm(forms.ModelForm): product_picture = ImageField(widget=FileWidget( attrs={ 'data-public-key': '47e54d77c7a9f66c3f0c', 'data-images-only': 'True', 'data-preview-step': 'True', 'data-image-shrink': '500x500', 'data-crop': '1:1', })) seller_id = forms.CharField(widget=forms.HiddenInput( attrs={'readonly': 'readonly'})) class Meta: model = Product fields = '__all__' exclude = ('views', ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Row(Column('product_picture', css_class='form-group col-md-6 mb-0'), Column(Row(Column('name', css_class="form-group col mb-0"), css_class="form-row"), Row(Column('price', css_class="form-group col mb-0"), Column('year', css_class="form-group col mb-0"), css_class="form-row"), css_class='form-group col-md-6 mb-0'), css_class='form-row'), Row(Column('quantity_in_stock', css_class="col"), css_class='form-row'), Row(Column('description', css_class="col"), css_class='form-row'), Row(Column('seller_id', css_class="col"), css_class='form-row'), Row(Column('region', css_class='form-group col-md-4 mb-0'), Column('body', css_class='form-group col-md-4 mb-0'), Column('nodes', css_class='form-group col-md-4 mb-0'), css_class='form-row'), Submit('submit', 'Save Listing', css_class="btn"))
class AvatarForm(forms.ModelForm): profile_img = ImageField(label='', required=False) class Meta: model = Photographer fields = ('profile_img', )
class ItemForm(forms.ModelForm): photos = ImageField(label="image") class Meta: model = Item fields = ('name', 'done', 'category', 'tags', 'photos')
class ImgForm(forms.Form): picImg = ImageField(label='')
class Meta: image = ImageField(widget=FileWidget(attrs={'data-clearable':True})) model=Game # fields will display on form as arranged fields=('name', 'category', 'description', 'inside_box', 'price', 'image', 'homepage_display')