'Render ModelForm in different app's template
Is there a way I could render the following modelform in a different template outside of it's app, it works correctly on a template inside the app but does not work outside of it.
Models.py
class Bid(models.Model):
tasker = models.ForeignKey(Tasker, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=10, decimal_places=0)
task_owner = models.ManyToManyField(User, blank=True)
completed = models.BooleanField(default=False)
Forms.py
class CreateBidForm(forms.ModelForm):
class Meta:
model = Bid
fields = (
'tasker',
'price',
'task_owner',
'completed'
)
Views.py
class SubmitBid(CreateView):
template_name = "listing_detail.html"
form_class = CreateBidForm
def post(self, request):
form = CreateBidForm(request.POST or None, request.FILESquest)
if form.is_valid():
bid = form.save(commit=False)
bid.tasker = request.user
bid.save()
return redirect('/')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
