将补充表单数据与Django中的用户对象关联
我想让在我的网站上注册的用户通过django表单提交“项目列表”。我用的是django allauth。提交此表单后,我希望将数据呈现在一个唯一的URL上,供公众浏览 我的模板:将补充表单数据与Django中的用户对象关联,django,forms,models,django-allauth,Django,Forms,Models,Django Allauth,我想让在我的网站上注册的用户通过django表单提交“项目列表”。我用的是django allauth。提交此表单后,我希望将数据呈现在一个唯一的URL上,供公众浏览 我的模板: <form class="listing" id="listing_form" method="post" action=""> {{ form.as_p }} <input type="hidden" name="{{ redirect_field_name }}" value="/" /&g
<form class="listing" id="listing_form" method="post" action="">
{{ form.as_p }}
<input type="hidden" name="{{ redirect_field_name }}" value="/" />
<button type="submit">Submit</button>
</form>
我的模型:
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from employerProfiles import models as employerModels
class ProjectListing(models.Model):
company = models.ForeignKey(employerModels.EmployerProfile)
title = models.CharField(max_length = 200)
short_description = models.CharField(max_length = 200)
full_description = models.TextField()
skills_required = models.TextField()
photo = models.ImageField(upload_to='uploads/listingPhotos')
hours_per_week = models.DecimalField(max_digits=4, decimal_places=2)
number_of_weeks = models.IntegerField()
start_date = models.DateField(auto_now=False, auto_now_add=False)
end_date = models.DateField(auto_now=False, auto_now_add=False)
location = models.CharField(max_length=100)
def __unicode__(self):
return self.company
最好的方法是什么?谢谢
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from employerProfiles import models as employerModels
class ProjectListing(models.Model):
company = models.ForeignKey(employerModels.EmployerProfile)
title = models.CharField(max_length = 200)
short_description = models.CharField(max_length = 200)
full_description = models.TextField()
skills_required = models.TextField()
photo = models.ImageField(upload_to='uploads/listingPhotos')
hours_per_week = models.DecimalField(max_digits=4, decimal_places=2)
number_of_weeks = models.IntegerField()
start_date = models.DateField(auto_now=False, auto_now_add=False)
end_date = models.DateField(auto_now=False, auto_now_add=False)
location = models.CharField(max_length=100)
def __unicode__(self):
return self.company