help error in form usage

147 views
Skip to first unread message

Phang Mulianto

unread,
Aug 14, 2011, 9:27:15 AM8/14/11
to django-users
hi..need help..

Here are the model :


class Post(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()
    slug = models.SlugField(max_length=50, unique=True, help_text='Unique Value for Article page URL, created from title.')
    is_publish = models.BooleanField(default=False)
    categories = models.ManyToManyField(Category)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
   
    class Meta:
            db_table = 'post'
            ordering = ['-created_at']
            verbose_name_plural = 'Posts'
           
    def __unicode__(self):
        return self.title
   
    @models.permalink
    def get_absolute_url(self):
        return ('article_post', ())


here are my view :

def myadmin_change_post(request, template_name='blog/admin/change_post.html'):
    try:
        id= request.GET.get('id','4')
    except ValueError:
        id=1
    #post = get_object_or_404(Post,pk=id)
    post = Post.objects.get(pk=id)
    form = AdminPostForm(initial=post)
    return render_to_response(template_name,locals(),context_instance = RequestContext(request) )

here are the template :
{% extends "myadmin/index.html" %}

{%block content %}
<br /><br />
<table class="formtable">
<form action="" method="post">
{% csrf_token %}
    <tbody>
    {% for field in form.visible_fields %}
            {% if forloop.first %}
                {% for hidden in form.hidden_fields %}
                {{ hidden }}
                {% endfor %}
            {% endif %}
            <tr class="{% cycle 'altRow' 'evenRow' %}">
                <td>{{ field.label_tag }}</td>
                <td>{{ field }}
                    {{ field.errors }}
                </td>
            </tr>
    {% endfor %}
    </tbody>
</table><input type="hidden" name="next"  value="{{ reuest.path }}">
<input type="submit" value="Submit" />
</form>
</table>

{% endblock %}

The problem is, when in the view, the form is unbound the page display .
when i bound the form like this :

form = AdminPostForm(initial=post)  => generate error in template
but when    
form = AdminPostForm() => No error but the field all empty

What i intend to do is, edit the data in the form, which like change form/edit form.
any clue for this error..
the error are :

TemplateSyntaxError at /article/change/

Caught AttributeError while rendering: 'Post' object has no attribute 'get'
Request Method: GET
Request URL: http://127.0.0.1:8000/article/change/?id=4
Django Version: 1.3
Exception Type: TemplateSyntaxError
Exception Value:
Caught AttributeError while rendering: 'Post' object has no attribute 'get'
Exception Location: c:\python27\lib\site-packages\django\forms\forms.py in value, line 470
Python Executable: c:\python27\python.exe
Python Version: 2.7.2
Python Path:
['C:\\Users\\mulianto\\workspace\\myblog\\src\\myblog',
'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'c:\\python27\\lib\\site-packages\\simplejson-2.1.6-py2.7.egg',
'c:\\python27\\lib\\site-packages\\pyasn1-0.0.13-py2.7.egg',
'c:\\python27\\lib\\site-packages\\pymongo-1.11-py2.7-win32.egg',
'c:\\python27\\lib\\site-packages\\mongoengine-0.4-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'c:\\python27\\DLLs',
'c:\\python27\\lib',
'c:\\python27\\lib\\plat-win',
'c:\\python27\\lib\\lib-tk',
'c:\\python27',
'c:\\python27\\lib\\site-packages',
'c:\\python27\\lib\\site-packages\\PIL']
Server time: Sun, 14 Aug 2011 21:14:41 +0800


Template error

In template c:\users\mulianto\workspace\myblog\src\myblog\templates\blog\admin\change_post.html, error at line 9

Caught AttributeError while rendering: 'Post' object has no attribute 'get'

1 {% extends "myadmin/index.html" %}
2
3 {%block content %}
4 <br /><br />
5 <table class="formtable">
6 <form action="" method="post">
7 {% csrf_token %}
8 <tbody>
9 {% for field in form.visible_fields %}
10 {% if forloop.first %}
11 {% for hidden in form.hidden_fields %}
12 {{ hidden }}
13 {% endfor %}
14 {% endif %}
15 <tr class="{% cycle 'altRow' 'evenRow' %}">
16 <td>{{ field.label_tag }}</td>
17 <td>{{ field }}
18 {{ field.errors }}
19 </td>

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/article/change/?id=4

Django Version: 1.3
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.flatpages',
 'myblog.utils',
 'myblog.article',
 'myblog.polling']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')


Template error:
In template c:\users\mulianto\workspace\myblog\src\myblog\templates\blog\admin\change_post.html, error at line 9
   Caught AttributeError while rendering: 'Post' object has no attribute 'get'
   1 : {% extends "myadmin/index.html" %}


   2 :


   3 : {%block content %}


   4 : <br /><br />


   5 : <table class="formtable">


   6 : <form action="" method="post">


   7 : {% csrf_token %}


   8 :     <tbody>


   9 :      {% for field in form.visible_fields %}


   10 :             {% if forloop.first %}


   11 :                 {% for hidden in form.hidden_fields %}


   12 :                 {{ hidden }}


   13 :                 {% endfor %}


   14 :             {% endif %}


   15 :             <tr class="{% cycle 'altRow' 'evenRow' %}">


   16 :                 <td>{{ field.label_tag }}</td>


   17 :                 <td>{{ field }}


   18 :                     {{ field.errors }}


   19 :                 </td>


Traceback:
File "c:\python27\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py" in myadmin_change_post
  132.     return render_to_response(template_name,locals(),context_instance = RequestContext(request) )
File "c:\python27\lib\site-packages\django\shortcuts\__init__.py" in render_to_response
  20.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "c:\python27\lib\site-packages\django\template\loader.py" in render_to_string
  188.         return t.render(context_instance)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  123.             return self._render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in _render
  117.         return self.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
  73.             result = node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
  127.         return compiled_parent._render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in _render
  117.         return self.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
  73.             result = node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
  127.         return compiled_parent._render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in _render
  117.         return self.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
  73.             result = node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
  127.         return compiled_parent._render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in _render
  117.         return self.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
  73.             result = node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
  64.             result = block.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
  73.             result = node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
  64.             result = block.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
  744.                 bits.append(self.render_node(node, context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
  73.             result = node.render(context)
File "c:\python27\lib\site-packages\django\template\defaulttags.py" in render
  227.                 nodelist.append(node.render(context))
File "c:\python27\lib\site-packages\django\template\debug.py" in render
  92.             output = force_unicode(output)
File "c:\python27\lib\site-packages\django\utils\encoding.py" in force_unicode
  71.                 s = unicode(s)
File "c:\python27\lib\site-packages\django\forms\forms.py" in __unicode__
  408.         return self.as_widget()
File "c:\python27\lib\site-packages\django\forms\forms.py" in as_widget
  439.         return widget.render(name, self.value(), attrs=attrs)
File "c:\python27\lib\site-packages\django\forms\forms.py" in value
  470.             data = self.form.initial.get(self.name, self.field.initial)

Exception Type: TemplateSyntaxError at /article/change/
Exception Value: Caught AttributeError while rendering: 'Post' object has no attribute 'get'

Daniel Roseman

unread,
Aug 14, 2011, 2:06:28 PM8/14/11
to django...@googlegroups.com
This line: 
    form = AdminPostForm(initial=post)


should be
    form = AdminPostForm(instance=post)

--
DR.

Phang Mulianto

unread,
Aug 15, 2011, 12:39:30 AM8/15/11
to django...@googlegroups.com
Hi Daniel,

i change it to instance, but still got other errors :


def myadmin_change_post(request, template_name='blog/admin/change_post.html'):
    try:
        id= request.GET.get('id','4')
    except ValueError:
        id=1
    #post = get_object_or_404(Post,pk=id)
    post = Post.objects.get(pk=id)
    form = AdminPostForm(instance=post)

    return render_to_response(template_name,locals(),context_instance = RequestContext(request) )

the form :

class AdminPostForm(forms.Form):
   
   
    cat_choices = [('private','private')]

    title = forms.CharField(widget=forms.TextInput(attrs={'size':'20','value':'','class':''}),label='Title')
    content= forms.CharField(widget=forms.Textarea(attrs={'cols':'40','rows':'5'}),label='Content')
    slug = forms.CharField(widget=forms.TextInput(attrs={'size':'20','class':''}),label='Slug')
    is_publish = forms.BooleanField(label='Publish')
    categories = forms.ChoiceField(choices=cat_choices)
    created_at = forms.DateTimeField(widget=forms.DateTimeInput(),label='Created at')
    modified_at = forms.DateTimeField(widget=forms.DateTimeInput(),label='Modified at')

any clue where the error migh be..

TypeError at /article/change/

__init__() got an unexpected keyword argument 'instance'
Request Method: GET
Request URL: http://127.0.0.1:8000/article/change/?id=2
Django Version: 1.3
Exception Type: TypeError
Exception Value:
__init__() got an unexpected keyword argument 'instance'
Exception Location: C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py in myadmin_change_post, line 132
Python Executable: c:\python27\python.exe
Python Version: 2.7.2
Python Path:
['C:\\Users\\mulianto\\workspace\\myblog\\src\\myblog',
'c:\\python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'c:\\python27\\lib\\site-packages\\simplejson-2.1.6-py2.7.egg',
'c:\\python27\\lib\\site-packages\\pyasn1-0.0.13-py2.7.egg',
'c:\\python27\\lib\\site-packages\\pymongo-1.11-py2.7-win32.egg',
'c:\\python27\\lib\\site-packages\\mongoengine-0.4-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'c:\\python27\\DLLs',
'c:\\python27\\lib',
'c:\\python27\\lib\\plat-win',
'c:\\python27\\lib\\lib-tk',
'c:\\python27',
'c:\\python27\\lib\\site-packages',


'c:\\python27\\lib\\site-packages\\PIL']
Server time: Mon, 15 Aug 2011 12:32:23 +0800


Traceback Switch to copy-and-paste view

  • c:\python27\lib\site-packages\django\core\handlers\base.py in get_response
    1.                     for middleware_method in self._view_middleware:
    2.                         response = middleware_method(request, callback, callback_args, callback_kwargs)
    3.                         if response:
    4.                             break
    5.                 if response is None:
    6.                     try:
    1.                         response = callback(request, *callback_args, **callback_kwargs)
    1. ...
    1.                     except Exception, e:
    2.                         # If the view raised an exception, run it through exception
    3.                         # middleware, and if the exception middleware returns a
    4.                         # response, use that. Otherwise, reraise the exception.
    5.                         for middleware_method in self._exception_middleware:
    6.                             response = middleware_method(request, e)
    Variable Value
    exceptions
    <module 'django.core.exceptions' from 'c:\python27\lib\site-packages\django\core\exceptions.pyc'>
    e
    TypeError("__init__() got an unexpected keyword argument 'instance'",)
    callback_args
    ()
    receivers
    [(<function _rollback_on_exception at 0x025CFAB0>, None)]
    middleware_method
    <bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x027A6C30>>
    self
    <django.core.handlers.wsgi.WSGIHandler object at 0x0276F4D0>
    settings
    <django.conf.LazySettings object at 0x01A788D0>
    request
    <WSGIRequest
    GET:<QueryDict: {u'id': [u'2']}>,
    POST:<QueryDict: {}>,
    COOKIES:{'csrftoken': '5fbc1b8cf0e31318c4f7a1904df1b5c2',
     'sessionid': 'ee90c4ad05c1512cc424c7117f1320c9'},
    META:{'ALLUSERSPROFILE': 'C:\\ProgramData',
     'APACHE2TRIAD_DIR': 'd:\\apache2triad',
     'APPDATA': 'C:\\Users\\mulianto\\AppData\\Roaming',
     'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files',
     'COMPUTERNAME': 'MULIANTO-PC',
     'COMSPEC': 'C:\\Windows\\system32\\cmd.exe',
     'CONTENT_LENGTH': '',
     'CONTENT_TYPE': 'text/plain',
     'CSRF_COOKIE': '5fbc1b8cf0e31318c4f7a1904df1b5c2',
     'DJANGO_SETTINGS_MODULE': 'myblog.settings',
     'FP_NO_HOST_CHECK': 'NO',
     'GATEWAY_INTERFACE': 'CGI/1.1',
     'HOMEDRIVE': 'C:',
     'HOMEPATH': '\\Users\\mulianto',
     'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
     'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
     'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
     'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
     'HTTP_CONNECTION': 'keep-alive',
     'HTTP_COOKIE': 'sessionid=ee90c4ad05c1512cc424c7117f1320c9; csrftoken=5fbc1b8cf0e31318c4f7a1904df1b5c2',
     'HTTP_HOST': '127.0.0.1:8000',
     'HTTP_KEEP_ALIVE': '115',
     'HTTP_REFERER': 'http://127.0.0.1:8000/article/listall/',
     'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110614 Firefox/3.6.18',
     'LOCALAPPDATA': 'C:\\Users\\mulianto\\AppData\\Local',
     'LOGONSERVER': '\\\\MULIANTO-PC',
     'NUMBER_OF_PROCESSORS': '2',
     'OPENSSL_CONF': 'd:\\apache2triad\\opssl\\bin',
     'OS': 'Windows_NT',
     'PATH': 'C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;;c:\\python27\\;;d:\\apache2triad\\bin;d:\\apache2triad\\perl\\bin;d:\\apache2triad\\php\\bin;d:\\apache2triad\\mysql\\bin;d:\\apache2triad\\opssl\\bin;d:\\apache2triad\\python\\bin;d:\\apache2triad\\pgsql\\bin;C:\\Program Files\\Enterprise Vault\\EVClient\\',
     'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
     'PATH_INFO': u'/article/change/',
     'PHP_PEAR_BIN_DIR': 'd:\\apache2triad\\php\\bin',
     'PHP_PEAR_DATA_DIR': 'd:\\apache2triad\\php\\pear\\data',
     'PHP_PEAR_DOC_DIR': 'd:\\apache2triad\\php\\pear\\docs',
     'PHP_PEAR_INSTALL_DIR': 'd:\\apache2triad\\php\\pear',
     'PHP_PEAR_PHP_BIN': 'd:\\apache2triad\\php\\bin\\php-cgi.exe',
     'PHP_PEAR_SYSCONF_DIR': 'd:\\apache2triad\\php',
     'PHP_PEAR_TEST_DIR': 'd:\\apache2triad\\php\\pear\\tests',
     'PPM_DAT': 'd:\\apache2triad\\perl\\site\\lib\\',
     'PROCESSOR_ARCHITECTURE': 'x86',
     'PROCESSOR_IDENTIFIER': 'x86 Family 6 Model 23 Stepping 10, GenuineIntel',
     'PROCESSOR_LEVEL': '6',
     'PROCESSOR_REVISION': '170a',
     'PROGRAMDATA': 'C:\\ProgramData',
     'PROGRAMFILES': 'C:\\Program Files',
     'PROMPT': '$P$G',
     'PSMODULEPATH': 'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\',
     'PUBLIC': 'C:\\Users\\Public',
     'QUERY_STRING': 'id=2',
     'REMOTE_ADDR': '127.0.0.1',
     'REMOTE_HOST': '',
     'REQUEST_METHOD': 'GET',
     'RUN_MAIN': 'true',
     'SCRIPT_NAME': u'',
     'SERVER_NAME': 'mulianto-PC',
     'SERVER_PORT': '8000',
     'SERVER_PROTOCOL': 'HTTP/1.1',
     'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.2',
     'SESSIONNAME': 'Console',
     'SSLEAY_CONF': 'd:\\apache2triad\\opssl\\bin',
     'SYSTEMDRIVE': 'C:',
     'SYSTEMROOT': 'C:\\Windows',
     'TEMP': 'C:\\Users\\mulianto\\AppData\\Local\\Temp',
     'TMP': 'C:\\Users\\mulianto\\AppData\\Local\\Temp',
     'USERDOMAIN': 'mulianto-PC',
     'USERNAME': 'mulianto',
     'USERPROFILE': 'C:\\Users\\mulianto',
     'VBOX_INSTALL_PATH': 'C:\\Program Files\\Oracle\\VirtualBox\\',
     'WINDIR': 'C:\\Windows',
     'wsgi.errors': <open file '<stderr>', mode 'w' at 0x012050D0>,
     'wsgi.file_wrapper': <class 'django.core.servers.basehttp.FileWrapper'>,
     'wsgi.input': <socket._fileobject object at 0x028E09B0>,
     'wsgi.multiprocess': False,
     'wsgi.multithread': True,
     'wsgi.run_once': False,
     'wsgi.url_scheme': 'http',
     'wsgi.version': (1, 0)}>
    callback
    <function myadmin_change_post at 0x028ECC70>
    resolver
    <RegexURLResolver myblog.urls (None:None) ^/>
    urlresolvers
    <module 'django.core.urlresolvers' from 'c:\python27\lib\site-packages\django\core\urlresolvers.pyc'>
    callback_kwargs
    {'template_name': 'blog/admin/change_post.html'}
    response
    None
    urlconf
    'myblog.urls'
  • C:\Users\mulianto\workspace\myblog\src\myblog\..\myblog\article\views.py in myadmin_change_post
    1. def myadmin_change_post(request, template_name='blog/admin/change_post.html'):
    1.     try:
    2.         id= request.GET.get('id','4')
    3.     except ValueError:
    4.         id=1
    5.     #post = get_object_or_404(Post,pk=id)
    6.     post = Post.objects.get(pk=id)
      1.     form = AdminPostForm(instance=post)
        ...
        1.     return render_to_response(template_name,locals(),context_instance = RequestContext(request) )
        1. def myadmin_new_post(request, template_name="blog/admin/change_post.html"):
        2.     if request.method == 'POST': # If the form has been submitted...
        3.         form = AdminPostForm(request.POST) # A form bound to the POST data
        4.         if form.is_valid(): # All validation rules pass


      --
      You received this message because you are subscribed to the Google Groups "Django users" group.
      To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/aasgmM81VrgJ.

      To post to this group, send email to django...@googlegroups.com.
      To unsubscribe from this group, send email to django-users...@googlegroups.com.
      For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

      Phang Mulianto

      unread,
      Aug 16, 2011, 11:47:50 AM8/16/11
      to django...@googlegroups.com
      hi anyone can help me...

      Tom Evans

      unread,
      Aug 16, 2011, 11:58:34 AM8/16/11
      to django...@googlegroups.com
      Your form is not a model form, and so you cannot pass instance=post.
      Since it is just a regular form, you should pass a dictionary of
      values, with the keys of the dictionary being the names of the fields.

      If the form is representing a model, you should be using a model form.

      https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/

      Cheers

      Tom

      Phang Mulianto

      unread,
      Aug 16, 2011, 12:02:10 PM8/16/11
      to django...@googlegroups.com
      Oh i see..

      i read the manual, the django book, no such information about that..
      oh my..better update the manual there..

      thanks for your quick explanation then, i think not a good way to manualy assign a dictionarry to the form, not like in the documentation / book of django. now i get it.

      Thanks

      Mulianto

      Derek

      unread,
      Aug 18, 2011, 9:29:48 AM8/18/11
      to Django users
      The Django Book is a useful general introduction; but now more than 2
      years old. In a framework like Django, which is under constant
      development, such old information gets out-of-date very fast. Tom
      correctly pointed you to the docs; and that is really the best place
      to work from now that you are doing specific development.

      On Aug 16, 6:02 pm, Phang Mulianto <braveh...@gmail.com> wrote:
      > Oh i see..
      >
      > i read the manual, the django book, no such information about that..
      > oh my..better update the manual there..
      >
      > thanks for your quick explanation then, i think not a good way to manualy
      > assign a dictionarry to the form, not like in the documentation / book of
      > django. now i get it.
      >
      > Thanks
      >
      > Mulianto
      >
      > On Tue, Aug 16, 2011 at 11:58 PM, Tom Evans <tevans...@googlemail.com>wrote:
      >
      >
      >
      >
      >
      >
      >
      > > Your form is not a model form, and so you cannot pass instance=post.
      > > Since it is just a regular form, you should pass a dictionary of
      > > values, with the keys of the dictionary being the names of the fields.
      >
      > > If the form is representing a model, you should be using a model form.
      >
      > >https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/
      >
      > > Cheers
      >
      > > Tom
      >
      > > On Tue, Aug 16, 2011 at 4:47 PM, Phang Mulianto <braveh...@gmail.com>
      > > wrote:
      >
      > > > hi anyone can help me...
      >
      > > > On Mon, Aug 15, 2011 at 12:39 PM, Phang Mulianto <braveh...@gmail.com>
      > > wrote:
      >
      > > >> Hi Daniel,
      >
      > > >> i change it to instance, but still got other errors :
      >
      > > >> def myadmin_change_post(request,
      > > template_name='blog/admin/change_post.html'):
      > > >>     try:
      > > >>         id= request.GET.get('id','4')
      > > >>     except ValueError:
      > > >>         id=1
      > > >>     #post = get_object_or_404(Post,pk=id)
      > > >>     post = Post.objects.get(pk=id)
      > > >>     form = AdminPostForm(instance=post)
      > > >>     return render_to_response(template_name,locals(),context_instance =
      > > RequestContext(request) )
      >
      > > >> the form :
      >
      > > >> class AdminPostForm(forms.Form):
      >
      > > >>     cat_choices = [('private','private')]
      >
      > > >>     title =
      > > forms.CharField(widget=forms.TextInput(attrs={'size':'20','value':'','class ':''}),label='Title')
      > > >>     content=
      > > forms.CharField(widget=forms.Textarea(attrs={'cols':'40','rows':'5'}),label ='Content')
      > > >>     slug =
      > > forms.CharField(widget=forms.TextInput(attrs={'size':'20','class':''}),labe l='Slug')
      > > 'C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\ \System32\\WindowsPowerShell\\v1.0\\;;c:\\python27\\;;d:\\apache2triad\\bin ;d:\\apache2triad\\perl\\bin;d:\\apache2triad\\php\\bin;d:\\apache2triad\\m ysql\\bin;d:\\apache2triad\\opssl\\bin;d:\\apache2triad\\python\\bin;d:\\ap ache2triad\\pgsql\\bin;C:\\Program
      > ...
      >
      > read more »
      Reply all
      Reply to author
      Forward
      0 new messages