Hi everyone, I am a total newbie and this is my first post at stackoverflowew although I have found a lot of good info while learning python. I am trying to get this to work since days and I get more and more fustrated. I will try to include as much info as i think is needed. Your hints for debugging this will be appreciated.
The editor works fine in the admin part of the site but not in my main views
THis is my model and modelform:
class UserEmployeeEditForm(ModelForm):
class Meta:
model = Employee
fields = ('photo', 'company_bio', 'personal_bio')
class Employee(models.Model):
username = models.CharField(max_length=15, primary_key=True)
email = models.EmailField()
full_name = models.CharField(max_length=100)
photo = fields.ThumbnailerImageField(
upload_to="employee_photos/",
resize_source=dict(size=(300, 300), crop='smart'))
company_bio = MarkupField(null=True, blank=True)
personal_bio = MarkupField(null=True, blank=True)
And the relevant view
def updateEmployee(request, employee_username):
employee = Employee.objects.get(username=employee_username)
if request.method == 'POST':
form = UserEmployeeEditForm(request.POST, request.FILES, instance=employee)
if form.is_valid():
form.save()
return HttpResponseRedirect('/maxbook/showemployee/'+ employee_username)
else:
form = UserEmployeeEditForm(instance=employee)
return render_to_response("maxbookapp/templates/testing.html", locals())
this is the template:
{% load markitup_tags %}
{% markitup_media %}
{{form.media}}
<table>
<form action='/maxbook/update/{{ employee_username }}/' method="post">
{{ form.as_p }}
<input type="submit" value="Update" />
</form>
{% markitup_editor form.company_bio.auto_id %}
{#% markitup_editor form.personal_bio.auto_id %#}
</table>
One of the two textfields is commented out and it works. The editor appears fine on the other, you can put text in with markup and the preview works but at the end the QueryDict is empty. If there was something in this field it will get wiped out.
I just dont get it.
Also the source of the update page:
<link href="/static/markitup/skins/simple/style.css" type="text/css" media="screen" rel="stylesheet" />
<link href="/static/markitup/sets/html/style.css" type="text/css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="/static/markitup/jquery.min.js"></script>
<script type="text/javascript" src="/static/markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="/static/markitup/sets/html/set.js"></script>
<table>
<form action='/maxbook/update/agagag/' method="post">
<p><label for="id_photo">Photo:</label> <input type="file" name="photo" id="id_photo" /></p>
<p><label for="id_company_bio">Company bio:</label> <textarea id="id_company_bio" rows="10" cols="40" name="company_bio">klkl
lkl lk 54646
<strong>more stuff</strong>
;</textarea></p>
<p><label for="id_personal_bio">Personal bio:</label> <textarea id="id_personal_bio" rows="10" cols="40" name="personal_bio"></textarea></p>
<input type="submit" value="Update" />
</form>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
$("#id_personal_bio").markItUp(mySettings);
});
})(jQuery);
</script>
</table>