Hello

I've been trying to figure out how to use modelforms and so far ive
managed to do things on my own. But now im trying to prepopluate
modelform and it does not work - not completely anyway.

Model:
from django.db import models
from tinymce import models as tinymce_models

class article(models.Model):
        name = models.CharField(max_length=200)
        content = tinymce_models.HTMLField()

Form:
from django.db import models
from django import forms
from mce.arts.models import article
from tinymce.widgets import TinyMCE
from django.forms import ModelForm


class articleForm(ModelForm):
        content = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows':
30}))
        class Meta:
                model = article

view:
        i = article.objects.get(id=4)
        initial_dict = {
                'name': i.name,
                'content':i.content,
        }
        form = articleForm(initial=initial_dict)

view:
<form method="POST" action="/add_article/">
        <table>
        {% for field in form %}
                <tr><td>{{ field.label_tag }}</td><td>{{ field }}</td></tr>
        {% endfor %}
        </table>
<input type="submit" value="Submit" />
</form>

Result is that first field is filled but the 2nd is not. It is not
problem of tinymce scripts, because if i remove the editor scripts
from view then i just get an empty textfield.

There are several resuts if i search the web about prepopulating model
fields, but none of them is about such problem. For prepopulating
itself i followed this thread as an example :
http://groups.google.com/group/django-users/browse_thread/thread/ff839ebf86cfac3a/4a3451f9bfc09143?lnk=raot


Alan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to