Python论坛  - 讨论区

标题:[python-chinese] 帮忙看看这个django的db api问题

2006年04月19日 星期三 12:21

于业平 yyp226 at gmail.com
Wed Apr 19 12:21:01 HKT 2006

正在学习 Django中, <http://www.djangoproject.com/download/0.91/tarball/>
我用的是 Django-0.91 <http://www.djangoproject.com/download/0.91/tarball/>,
感谢limodou兄的django step by step
http://www.woodpecker.org.cn/obp/django/django-stepbystep/newtest/doc/
在学习那个wiki制作时数据库操作出了问题:
1:  # manage.py startapp mywiki

2:  mywiki/models/mywiki.py如下:
    from django.core import meta
    # Create your models here.
    class Wiki(meta.Model):
         pagename=meta.CharField(maxlength=20, unique=True)
         content=meta.TextField()
3: 修改setting.py
4: 执行了#manage.py install mywiki
5: 在shell中操作:
[yyp226 at localhost newtest]$ ./manage.py shell Python 2.4.1 (#1, May 16 2005,
15:19:29)
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.models import mywiki
>>> page=mywiki.Wiki(pagename='newPage',content='welcome here')
>>> page.save()
>>> page.pagename
'newPage'
>>> page.content
'welcome here'
>>> mywiki.get_list()
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute 'get_list'

到这里就出错了 ! 不知道怎么解决

page.save()已经成功更新了数据库了:
mysql> select * from mywiki_wikis;
+----+-----------+--------------+
| id | pagename  | content      |
+----+-----------+--------------+
|  1 | Frontpage | Welcome      |
|  2 | newPage   | welcome here |
+----+-----------+--------------+
2 rows in set (0.00 sec)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060419/f9b2c631/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月19日 星期三 15:53

Pau Lau paulau591 at gmail.com
Wed Apr 19 15:53:17 HKT 2006

在06-4-19,于业平 <yyp226 at gmail.com> 写道:
>
> 正在学习 Django中, <http://www.djangoproject.com/download/0.91/tarball/>
> 我用的是 Django-0.91 <http://www.djangoproject.com/download/0.91/tarball/>,
> 感谢limodou兄的django step by step
> http://www.woodpecker.org.cn/obp/django/django-stepbystep/newtest/doc/
> 在学习那个wiki制作时数据库操作出了问题:
> 1:  # manage.py startapp mywiki
>
> 2:  mywiki/models/mywiki.py如下:
>     from django.core import meta
>     # Create your models here.
>     class Wiki(meta.Model):
>          pagename=meta.CharField(maxlength=20, unique=True)
>          content=meta.TextField()
> 3: 修改setting.py
> 4: 执行了#manage.py install mywiki
> 5: 在shell中操作:
> [ yyp226 at localhost newtest]$ ./manage.py shell Python 2.4.1 (#1, May 16
> 2005, 15:19:29)
> [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from django.models import mywiki
> >>> page=mywiki.Wiki(pagename='newPage',content='welcome here')
> >>> page.save()
> >>> page.pagename
> 'newPage'
> >>> page.content
> 'welcome here'
> >>> mywiki.get_list()
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'get_list'
>
> 到这里就出错了 ! 不知道怎么解决
>
> page.save()已经成功更新了数据库了:
> mysql> select * from mywiki_wikis;
> +----+-----------+--------------+
> | id | pagename  | content      |
> +----+-----------+--------------+
> |  1 | Frontpage | Welcome      |
> |  2 | newPage   | welcome here |
> +----+-----------+--------------+
> 2 rows in set (0.00 sec)
>
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
应该这样才对吧~!

mywiki..Wikiget_list()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060419/1662ecfa/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月19日 星期三 16:08

yi huang yi.codeplayer at gmail.com
Wed Apr 19 16:08:45 HKT 2006

快改用magic-removal吧   0.91不懂挖

On 4/19/06, Pau Lau <paulau591 at gmail.com> wrote:
>
>
>
> 在06-4-19,于业平 <yyp226 at gmail.com> 写道:
> >
> > 正在学习 Django中, <http://www.djangoproject.com/download/0.91/tarball/>
> 我用的是 Django-0.91 <http://www.djangoproject.com/download/0.91/tarball/>,
> 感谢limodou兄的django step by step http://www.woodpecker.org.cn/obp/django/django-stepbystep/newtest/doc/
>
> 在学习那个wiki制作时数据库操作出了问题:
> 1:  # manage.py startapp mywiki
>
> 2:  mywiki/models/mywiki.py如下:
>     from django.core import meta
>     # Create your models here.
>     class Wiki(meta.Model):
>          pagename=meta.CharField(maxlength=20, unique=True)
>          content=meta.TextField()
> 3: 修改setting.py
> 4: 执行了 #manage.py install mywiki
> 5: 在shell中操作:
> [ yyp226 at localhost newtest]$ ./manage.py shell Python 2.4.1 (#1, May 16
> 2005, 15:19:29)
> [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from django.models import mywiki
> >>> page=mywiki.Wiki(pagename='newPage',content='welcome here')
> >>> page.save()
> >>> page.pagename
> 'newPage'
> >>> page.content
> 'welcome here'
> >>> mywiki.get_list()
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'get_list'
>
> 到这里就出错了 ! 不知道怎么解决
>
> page.save()已经成功更新了数据库了:
> mysql> select * from mywiki_wikis;
> +----+-----------+--------------+
> | id | pagename  | content      |
> +----+-----------+--------------+
> |  1 | Frontpage | Welcome      |
> |  2 | newPage   | welcome here |
> +----+-----------+--------------+
> 2 rows in set (0.00 sec)
>
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> 应该这样才对吧~!
>
> mywiki..Wikiget_list()
>
>
>
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
http://codeplayer.blogbus.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060419/d80e1661/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月20日 星期四 03:00

于业平 yyp226 at gmail.com
Thu Apr 20 03:00:45 HKT 2006

mywiki.Wiki.get_list()也是一样的不对,
还有 gjango  + mysql的中文问题不是知道怎么弄
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060420/b949f453/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月20日 星期四 08:54

limodou limodou at gmail.com
Thu Apr 20 08:54:50 HKT 2006

On 4/19/06, 于业平 <yyp226 at gmail.com> wrote:
> 正在学习 Django中,
> 我用的是 Django-0.91,
> 感谢limodou兄的django step by step
> http://www.woodpecker.org.cn/obp/django/django-stepbystep/newtest/doc/
> 在学习那个wiki制作时数据库操作出了问题:
> 1:  # manage.py startapp mywiki
>
> 2:  mywiki/models/mywiki.py如下:
>     from django.core import meta
>     # Create your models here.
>     class Wiki(meta.Model):
>           pagename=meta.CharField(maxlength=20, unique=True)
>          content=meta.TextField()
> 3: 修改setting.py
> 4: 执行了#manage.py install mywiki
> 5: 在shell中操作:
> [ yyp226 at localhost newtest]$ ./manage.py shell Python 2.4.1 (#1, May 16
> 2005, 15:19:29)
> [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from django.models import mywiki
> >>> page=mywiki.Wiki(pagename='newPage',content='welcome
> here')
> >>> page.save()
> >>> page.pagename
> 'newPage'
>  >>> page.content
> 'welcome here'
> >>> mywiki.get_list()
>  Traceback (most recent call last):
>   File "", line 1, in ?
>  AttributeError: 'module' object has no attribute 'get_list'
>
> 到这里就出错了 ! 不知道怎么解决
>
> page.save()已经成功更新了数据库了:
> mysql> select * from mywiki_wikis;
> +----+-----------+--------------+
> | id | pagename  | content      |
> +----+-----------+--------------+
> |  1 | Frontpage | Welcome      |
> |  2 | newPage   | welcome here |
> +----+-----------+--------------+
> 2 rows in set (0.00 sec)
>
>

1. 你给出的链接是 0.92(m-r)版的教程。0.91真正的内容都在我的blog上。
2. 不知你下载过我写的代码看过没有,我是这样写的:

from django.models.wiki import wikis

        pages = wikis.get_list(pagename__exact=pagename)

也就是不是象你所写的 from django.models import mywiki

3. 建议使用m-r分枝。0.91被淘汰是必然的,没必要再在上面浪费时间。

--
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年04月21日 星期五 01:34

于业平 yyp226 at gmail.com
Fri Apr 21 01:34:29 HKT 2006

收到, 我也换0.92了
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060421/f6a31bd1/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号