Closed lip365 closed 7 years ago
I don't really understand your question. May you specify what's your purpose?
sorry I just saw your reply, in my post model I have two fields url = models.URLField(max_length=250, blank=True, null=True) and video = EmbedVideoField(verbose_name='My video',blank=True, null=True). User is pasting url for bot of them, so I was wondering if I can just show one url form and if user puts video url then make django-embeded-video to activate. otherwise my url function to work. The purpose is to simply show one url form rather than two.
should I play around with my views.py for this?
class PostCreateView(CreateView):
model = Post
form_class = PostForm
template_name = 'main/add_post.html'
def form_valid(self, form):
self.object = form.save(commit=False)
# any manual settings go here
#self.object.category = Category.objects.filter(category__in=categories).all()
self.object.moderator = self.request.user
self.object.image = extract(self.object.url)
self.object.save()
return HttpResponseRedirect(reverse('post', args=[self.object.slug]))
this is my forms.py
`
class PostForm(forms.ModelForm):
# category = CategoryChoices()
title = forms.CharField(max_length=128, help_text="plz enter")
url = forms.URLField(max_length=200,
help_text="Please enter the URL of the page.", required=False)
views = forms.IntegerField(widget=forms.HiddenInput(), initial=0)
class Meta:
model = Post
widgets = {
'category':Select2Widget,
}
exclude = ['pub_date', 'moderator', 'rank_score','slug', 'image']`
Hello , thanks for making this app. Is there a way to combine url form I created and video url form together? I have url = models.URLField(max_length=250, blank=True, null=True) video = EmbedVideoField(verbose_name='My video',blank=True, null=True)
I want them to be combined, is this possible?