def File_Open(request):
if (request == request.FILES):
file = request.FILES.open()
return render(request, 'recruitment/open_file.html', {file : 'file'})url(r'^candidatelist/'
r'resume-view/'
r'(?P<resumeFile>/$',
views.File_Open,
name = 'resume_view'--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b2cf38b0-6a6a-45c1-84b9-c4cf678b6c9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
url(r'^candidatelist/'
r'(?P<year>\d{4})/'
r'(?P<month>\d{1,2})/'
r'(?P<day>\d{1,2})/'
r'(?P<slug>[-\w]*)/'
r'update/'
r'resume/'
r'(?P<resumeFile>)/$',
Candidate_Update.as_view(),
name = 'resume_view')class Candidate(models.Model):
resumeFile = models.FileField(upload_to="resume/")
{% for candidate in candidatelist %}
<tr>
<td><a href="{{candidate.get_update_url}}">{{candidate.lastname}}</a>
</td>
<td>{{candidate.firstname}}</td>
<td>{{candidate.career}}</td>
<td>{{candidate.email}}</td>
<td><a href="{{ MEDIA_URL }}">{{candidate.resumeFile}}"</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}def CandidateList(request):
candidatelist = Candidate.objects.all()
return render(request, 'recruitment/candidatelist.html', {'candidatelist': candidatelist})
class Candidate_Detail(ObjectUpdateMixin, View):
form_class = CandidateForm
model = Candidate
template_name = 'recruitment/candidate_detail.html'
class Candidate_Update(ObjectUpdateMixin, View):
form_class = CandidateForm
model = Candidate
template_name = 'recruitment/candidate_update.html'class ObjectCreateMixin:
form_class = None
template_name = ' '
def get(self, request):
return render(
request,
self.template_name,
{'form': self.form_class()}
)
def post(self, request):
bound_form = self.form_class(request.POST, request.FILES)
if bound_form.is_valid():
new_object = bound_form.save()
return redirect(new_object)
else:
return render(
request,
self.template_name,
{'form' : bound_form})
class ObjectUpdateMixin:
form_class = None
model = None
template_name = ' '
def get(self, request, slug, **kwargs):
obj = get_object_or_404(self.model,
slug__iexact=slug
)
context = {'form' : self.form_class(instance=obj),
self.model.__name__.lower() : obj,}
return render(
request,
self.template_name,
context
)
def post(self, request, slug, **kwargs):
obj = get_object_or_404(self.model, slug=slug)
bound_form = self.form_class(request.POST, request.FILES, instance=obj)
if bound_form.is_valid():
new_object = bound_form.save()
return redirect(new_object)
else:
context = {
'form' : bound_form,
self.model.__name__.lower() : obj,
}
return render(
request,
self.template_name,
context)<td><a href="{{ MEDIA_URL }}">{{candidate.resumeFile}}"</a></td>
<td><a href="{{candidate.resumeFile.url}}">{{candidate.resumeFile.name}}"</a></td>
Using the URLconf defined in hr_solution.urls,
Django tried these URL patterns, in this order:
The current URL, candidatelist/resume/Resume_Wilfredo_Rivera.pdf, didn't match any of these.
How can I desing a url that match the one with the uploaded file and what view handles it?