Re: IDE

2008-03-05 Thread limodou

On Wed, Mar 5, 2008 at 10:32 PM, gabriel <[EMAIL PROTECTED]> wrote:
>
> Hi ,
>
> I am at the point of changing IDE before my next project ( a huge one ).
> So far I've used Geany for python but now I am supposed to use django.
> Is it anythong with special support for Django??
>
> I know that recommendations include SPE and Eclipse but I wonder if you
> happened to work with IDE with a nice django support - does anything
> alike exist??
>
>
You can try ulipad. Enable djangoproj plugin in [Tool]->[Plugin Manager...]
Alos need to set django project in Directory Browser Window(press F2,
and add your django project), the Set project menu item in context
menu of directory browser window.

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
meide <>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IDE

2008-03-05 Thread limodou

On Thu, Mar 6, 2008 at 4:06 AM, gabriel <[EMAIL PROTECTED]> wrote:
>
>  What do you think about :
>
>  eclipse + plugins( pydev + html/css )
>  eric4 + django plugin
>  SPE - is there plugin for django
>
>  All of that around for-django usage?
>
I only used UliPad, and didn't used others, and I only use "print" to
debug django, so I have no ideas about other editors. Sorry.

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
meide <>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Guido like Django

2007-05-31 Thread limodou

Many people know that Guido like django, that's right! Today Google
Developer Day is held in Beijing, and Guido also made a python
introduction. In his talk he said at least 4 times that he likes
Django. And I'm very excited about this. And I think maybe it's a
great opportunity for Django development in China, and I hope more and
more people would like to learn Django from now.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django_xmlrpc

2007-06-11 Thread limodou

On 6/12/07, John Goodleaf <[EMAIL PROTECTED]> wrote:
>
> Nevermind. I got it. I missed that _all_ requests should be forwarded to
> handle_xmlrpc. I was expecting the registered ones functions to behave
> "normally." Well it was actually your email that tipped me off, but
> let's chalk it up as an object lesson on reading code. (For anyone
> unfamiliar, the code states clearly that requests should go
> handle_xmlrpc. My bad.) I  coulda solved it with a little more reading.
> And coffee.
>
> Thanks Graham. I look forward to using this xmlrpc interface since it
> hits the sweet spot for my present needs. Simpler than SOAP, less
> cutting edge than REST.
>
If you like you can see one middleware that I wrote before.

http://www.djangosnippets.org/snippets/71/

It's not need to bind all xml-rpc methods into one handler, you can
invoke xml-rpc method through common url, only need to follow
"?format=xmlrpc", so the request and response will be convert to xml
format. But if you want to use this middleware, you should return pure
data but not a real HttpResponse, and the middleware will
automatically convert the pure data into xml format. Please see the
description in the page. And I should say, I'v not been playing with
this snippet for a long time. :)

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[ANN]db_dump.py 2.1 released!

2007-09-18 Thread limodou

I'v created a project db-dump on code.google.com, you can visit it at:
http://code.google.com/p/db-dump/

And db_dump.py is used for dump and restore database of Django. And it
can also support some simple situations for Model changes, so it can
also be used in importing data after the migration of Model.

So if you like it or want to try it, you can download it from
http://db-dump.googlecode.com/files/db_dump2.1.zip

And if you have any idea about it just write a issue or send me an
email, I'll try my best to change it.

If you want to run it, just extract it to project directory, you
should put it with the settings.py together, and run it according to
the document of the project site.

Hope you like it.
-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Tip:decorator and urls.py

2006-12-28 Thread limodou



-8<--
@template('template.html')
def list(request):
if success:
#return HttpResponseRedirect('url')
raise HttpRedirectException
else:
return errorinfo
->8--


I'm sorry, here has a bug, the

raise HttpRedirectException

should be:

raise HttpRedirectException 'url'

--
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Tip:decorator and urls.py

2006-12-28 Thread limodou
 a
HttpRedirectException exception, so you can write your view just like:

-8<--
@template('template.html')
def list(request):
   if success:
   #return HttpResponseRedirect('url')
   raise HttpRedirectException
   else:
   return errorinfo
->8--

So you can use template to deal with two type different output:
redirect and normal render output. Of course, template just my
implementation and I just want to use it to describe some example.
Just some tips, you can do anything what you want if django supports
it.

I hope you have fun with decorator.

--
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Listing folders - how to improve this code

2006-12-29 Thread limodou


On 12/30/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


I have a initial view which works as a folder browser for url:

(r'^f/(?P.*?)/$', 'drcsm.views.list_rcs')

def list_rcs(request, path):
path = '/' + path
# workdir prevents ../ chets but... no cheating
if path.find('..') != -1 or path.find('./') != -1:
raise Exception, 'No cheating'
workdir = settings.RCS_ROOT + normpath(path)


you can use

os.path.join(settings.RCS_ROOT , normpath(path))



if isdir(workdir):
content = listdir(workdir)
files = []
dirs = []
#from dive into python :)
#print [f for f in listdir(workdir) if isfile(join(workdir, f))]
#print [f for f in listdir(workdir) if isdir(join(workdir, f))]
for c in content:
if not c.startswith('.'):
if isdir(workdir + '/' + c):
dirs.append(c)
else:
files.append(c)
return render_to_response('drcsm/' + settings.ENGINE + 
'/list.html',
{'files': files, 'dirs': dirs, 'path': path, 'theme': settings.THEME,
'engine': settings.ENGINE})


you can see os.walk() I think it's better for these things.



else:
return render_to_response('drcsm/' + settings.ENGINE + 
'/error.html',
{'error': 'Zly Katalog', 'theme': settings.THEME, 'engine':
settings.ENGINE})


Can this be improved or has some security holes ?



--
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a candidate for a custom decorator?

2007-01-11 Thread limodou

I suggest that you print the request, args, and kwargs to see the real
arguments.


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a candidate for a custom decorator?

2007-01-11 Thread limodou

On 1/12/07, Brian Beck <[EMAIL PROTECTED]> wrote:
>
> I think your problem is the return values. args is a tuple and request
> should be there instead. In both of your decorators, return fn(request,
> *args, **kwargs) instead of fn(args, kwargs).
>

I think you are right.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



dump and restore tool for django

2007-01-18 Thread limodou


I'v finished a tool for dumping and restoring database for django, you
can find it at:
http://code.djangoproject.com/wiki/DbDumpScript

--
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dump and restore tool for django

2007-01-20 Thread limodou

On 1/20/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> On 1/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > I was looking for something like this :) I'll test it today :)
>
> You should also keep in mind that the fixtures patch that is part of
> ticket #2333 can be used to dump and reload database contents. This
> patch should be applied shortly (it has been slated for inclusion
> before v1.0)
>
Yeah, I of cause see your suggestion, but I found the process is not
very correctly and enough. for example: I cannot specify the output
directory. And if there is foreignkey relationship in one app, the
order of output data is very important. Because the restore process
will use model.objects.create to insert a new record, so if the
foreign object is not created yet, the inserting will be failed. And
what I do is using cursor.execute, so there are no these problem. And
also my tool can support the restore after you changed the model, and
I think is handy for me.

And I also want to proposal that manage.py should has a plugin
interface, so that user can contribute their own useful tool, and this
tool can be invoked through:

manage tool customtool

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dump and restore tool for django

2007-01-20 Thread limodou

> ./manage.py dumpdb > /foo/bar/out.data

I don't like this. Because I want to save the data into different
files according to each table, but not a single file.

> > And if there is foreignkey relationship in one app, the
> > order of output data is very important. Because the restore process
> > will use model.objects.create to insert a new record, so if the
> > foreign object is not created yet, the inserting will be failed.
>
> If you create objects and foreign key relations in a single
> transaction, there shouldn't be any issue with object creation order.

Because the idea above, so it's not very suit for my requirement.

>
> > And
> > what I do is using cursor.execute, so there are no these problem. And
> > also my tool can support the restore after you changed the model, and
> > I think is handy for me.
>
> How does the patch in #2333 prevent you from doing this? Dump your
> data, change your model, modify your data to add new required fields,
> load your data.

I don't want to modify every line of data, but I need a default value
dealing appoach. And #2333 doesn't support this idea. I didn't try
#2333 for: if I remove some fields of a Model, and restore data from
data file, how about #2333 will do?

>
> > And I also want to proposal that manage.py should has a plugin
> > interface, so that user can contribute their own useful tool, and this
> > tool can be invoked through:
> >
> > manage tool customtool
>
> There is no need for this. If you need to write your own tools, they
> can be .py scripts, invoking whatever Django calls are required.
> Manage.py doesn't do anything magical that couldn't be easily
> replicated in your own script.
>

So your thought is very different from mine. I think core.management
has many common methods, and users like me hope to reuse them. If
there is no such plugin system, so I had to write my personal tool
just like db_dump.py, and it'll be a whole program, and I need
introduce many things I need from core.management which I think
useful.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Mako ?

2007-01-21 Thread limodou

On 1/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi
> I'm wondering if someone tried to integrate Mako templates with Django
> ?
>
> http://www.makotemplates.org/
>
>
yi huang has something about it:
http://huangyilib.googlecode.com/svn/trunk/mashi_django/mako_django.py

You can see it.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dump and restore tool for django

2007-01-23 Thread limodou

On 1/24/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
>
> Russell Keith-Magee wrote:
> > Glad you like it. I'm hoping to get some time in the next week or so
> > to finish off the few things that are needed before I bug Adrian for
> > permission to commit. In the meantime, if you have any suggestions or
> > comments, let me know.
>
> Maybe I could just throw in another use case and we can see if the
> dump/restore facility will work in this way too...
>
> Right now I'm working on a project that we're developing a new data
> model with.  The content team is already starting to input data.
> Occasionally I find a need to add a new database column to support
> something new.  This is your typical schema evolution need.
>
> If I could dump the current data, run an sqlreset, and reload the data,
> that would be amazingly helpful.  (At least until schema evolution comes
> online or even as an alternative approach after it's available.)
>
> Would/Could it work like this?
>
> Is the dump/restore facility tied to fixtures?  I see a dumpdb option in
> your patch but not a reloaddb (or the like)... just a 'installfixture'.
>
> -Rob
>
Your case is just I mentioned before, and for simple situations,
db_dump.py tool can automatically add new column with default value
defined in Model, and if there is not a default value defined in
Model, you can change the data file, and add 'default' key to specify
the default value of a new column, or the new column is renamed from
an old column , you can add 'reference' type for new column, then the
value of new column will use the value of referred column. Details you
can find in wiki page.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



bug report:cut filter cann't process unicode

2007-01-24 Thread limodou

if a template variable is unicode, and as I using cut filter, it'll
throw error, and I checked the source code, I found:

def cut(value, arg):
"Removes all values of arg from the given string"
return value.replace(arg, '')

And I also found most filter function have added str() to convert
value to string type. So I think it's a mistake. Isn't it?

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Clone DjangoBook.com -- Open book platform beta release

2007-02-11 Thread limodou

Recently I made a clone project similar djangobook.com, but I add some
extra management features, for example:

Multi-User
Multi-Book

Many things I borrowed from djangobook.com, especially the css. But
the ajax functionality I use jQuery, and also implement a similar
comment dialog. But I'm not a css expert, so if you want the page in
IE, the effect is very bad. So you'd better view the page in Firefox
browser. And I didn't test it in Mac system.

The project is hosted on code.google.com:
http://code.google.com/p/openbookplatform/
If anyone like it, you can download the source code. The project is
released in MIT license.

And here is a screenshot:
http://wiki.woodpecker.org.cn/moin/ObpLatform?action=AttachFile&do=get&target=openbookplatform.png

This project has some bugs and some features also need to improve, for
example: comment management.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Clone DjangoBook.com -- Open book platform beta release

2007-02-11 Thread limodou

On 2/12/07, johnny <[EMAIL PROTECTED]> wrote:
>
> What version of Django does it support, dev or 0.95?
> I was looking for some example in Django and jQuery.  Thank You.
>
django is dev version(trunk)
I'v not used newforms yet.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Clone DjangoBook.com -- Open book platform beta release

2007-02-11 Thread limodou

On 2/12/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On Feb 11, 10:39 am, limodou <[EMAIL PROTECTED]> wrote:
> > Many things I borrowed from djangobook.com, especially the css.
>
> Hi Limodou,
>
> The djangobook.com CSS is *not* available for copying, so please
> change your project so that it uses your own custom CSS. Design theft
> isn't cool.
>
> Thanks,
> Adrian
>
Ok, I see.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Clone DjangoBook.com -- Open book platform beta release

2007-02-11 Thread limodou
On 2/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I've tested it a bit.
>
> + nice and good way to present content, big sets of content :)
> - from SVN I get  "openbookplatform" folder which needs to be changed
> to "openbook" ;)
> - chinese characters  / which I don't see:
> http://www.fotosik.pl/showFullSize.php?id=4030c8e68eb7e4f6

I'll change them.

> - what is "Num:" in chapters ? I see it beeing used as slugs in URL
> but the field isn't validates as slugs - allowing non asci/latin-1
> chars, I got:
> http://localhost:8080/book/1/dgfgfdsss łółę/
>
>
Num, I call it chapter order num, so just like chapter01, chapter02,
and I'll use it to order the chapters. It's just a CharField. You
should use something like 'chapter01', or simple 'c01', 'c02'.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What about a list of finished django applications on the wiki ?

2007-02-11 Thread limodou

On 2/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> There are many django applications on code.google.com and on other
> sites, but not all of them are finished and ready to use or re-use.
> Why not make a "category" on the wiki for finished applications. Each
> page would describe the application, requirements, links, possibly
> some howtos  etc. ?
>
 +1

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Clone DjangoBook.com -- Open book platform beta release

2007-02-11 Thread limodou

I'v update the code and css, so if there are still some unsuitable
places, please point them out.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Open Book Platform demo site is up

2007-02-12 Thread limodou
I'v setup a demo site for open book platform project. So you can visit
it : http://limodou.51boo.com
This site is just for testing and demo, so don't put important things in it.

Thanks the master of 51boo.com, without his help I cann't run up the site.

The project can be found at: http://code.google.com/p/openbookplatform/
it's an open source project, if you like you can download it.

Site env:

python: 2.5
django: trunk
database: sqlite3
other modules: PIL, pygments, docutils

Strongly suggest that using Firefox to visit the site ! ! !

And hope everyone happy in the Spring Festival.
预祝大家春节快乐!

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Open Book Platform demo site is up

2007-02-12 Thread limodou

On 2/13/07, Don Arbow <[EMAIL PROTECTED]> wrote:
>
> On Feb 12, 2007, at 6:30 AM, limodou wrote:
> > I'v setup a demo site for open book platform project. So you can visit
> > it : http://limodou.51boo.com
> > This site is just for testing and demo, so don't put important
> > things in it.
>
>
>
> I would refrain from using other's images on your site (you took a
> cover image of an Apress book and put a title on it to look as if
> there is an Apress book that is related to your site). You claim
> copyright for yourself, and yet you appropriate other's work.
>
> Don

The book image just a default image, and I could change it. So you can
upload your own book image.

Please take it easy, this site just a demo site, and I setup it just
wan to show the demo, so you can change everything if you want. And
I'll change the default book image.

Thanks.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Open Book Platform demo site is up

2007-02-12 Thread limodou

On 2/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> you could use verbose_name and help_text to clarify purpose of fields
> like num, and in case num - make it a slugField. Also a note for
> models:

num is not the same as slug, because I will use num to order the
chapters order. So it has some order require, for example: chapter01
chapter 02, etc.

And for now, I wrote the form html just pure html code, I don't use
form to create them for me. I think write form html directly is now
easy for me.

>
> Book -> Chapter -> Articles could be bit better (or a "line break"
> feature for chapter) For example:
>
> Django the Book:
>
> Chapter 1. Basics
> --- what is django
> --- how to use orm
>
> Chapter 2. Deploying Django on servers
> --- apache
> --- cherokee
> --- nginx
> --- blal bla bla
>

What's these? Abstract? keywords?

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Open Book Platform demo site is up

2007-02-12 Thread limodou

> Don isn't being unreasonable. People are (understandably) very
> protective of their creative efforts. It doesn't matter whether it is
> a demo or a production site, whether it is fixed content of modifiable
> content - you have published something to the world which you didn't
> create, and have claimed it as your own (You put a (c) Limodou at the
> bottom of each page, but don't attribute other sources). This is poor
> form, and you shouldn't be surprised at the reaction it provokes.
>

Ok, thanks. I'd like to receive any suggestion or criticism, and if
there is something not good, I'll change or remove them.

I'll remove the copyright message. So any other idea? The book image
I'v changed.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Open Book Platform demo site is up

2007-02-12 Thread limodou

On 2/13/07, Jianjun <[EMAIL PROTECTED]> wrote:
>
> limodou,
> Thanks for sharing the source code. It looks a nice.
> I got one question: I create a book on the demo site and I couldn't
> find how to enable the comment bar on the left side. Did I miss
> something? All the sample books except for the very first one do NOT
> show the comment bar on the left side. Why is that?
>
You should use restructuredtext to write your book, and if you want a
comment block, you should put something like [01], [02], and the site
will auto convert [xx] into comment block.
for example:

[01]Title
=

[02]This is the first paragraph.

[03]This is the second paragraph.

And this project only support ,  tag. So sometime
you put [xx] at the beginning of the line, but it may not should at
all. At this time, I think the converted result tag may not be
supported.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a way for a template file to know its name?

2007-02-13 Thread limodou

On 2/13/07, Michael Lake <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Malcolm Tredinnick wrote:
>  > There isn't any way to do this built into Django. It may not always make
>  > sense, either, since a template could just be a string (hence have no
>  > name).
>  >
>  > Looking through some code I have written, I found a case where I was
>  > doing something like you are and I am just passing in a "no_display"
>  > variable in the context on the pages that shouldn't have a link like
>  > this. I test to see if no_display is false before trying to display the
>  > link (in fact, in my case, it's on a help page, too).
>
> Thats perfect, thanks.
> I now have
> {% if not no_display %}
> ... a help link in a div 
> {% else %}
> ... a blank div element ...
> {% endif %}
>
> and in my views for the just for the help function I have:
> render-to_reponse('lab/help.html', {'no_display': 1})
>
> Works a treat. Thanks.

Why not use

{% block help %}... a help link in a div {% endblock %}

in base.html, and in help.html

{% block help %}{% endblock %}

I think this will be simple.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: catalog of django apps?

2007-02-15 Thread limodou

On 2/16/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote:
> > That would be great. In fact, it would be nice if many of the
> > component apps of the site were themselves available on the site for
> > building other software component catalog sites.
>
> Absolutely. I'm a fan of open-source sites (hopefully going to be
> launching one soon!).
>
> > What do you think of the idea of having (optional) conventions for
> > improving the ability of apps to work together?
>
> I've come across a few useful things I've been meaning to write up,
> but I've already got a huge backlog of blog entries I need to finish
> :)
>
> I think that a lot of it comes down to four things:
>
> 1. Good conventions for code structure, so things end up in
> predictable locations.
> 2. Use of the "app directories" template loader so you can distribute
> sample templates with the app.
> 3. Careful import statements which don't rely on the name of an
> overarching project (which isn't hard, but a little different setup
> from when people do a project where all the apps live in directories
> under the project dir).
> 4. Documentation. Can't stress this one enough: having both standalone
> documentation and docstrings and comments throughout the code can make
> or break an app's reusability.
>
> Anybody else got thoughts on useful ways to help the reusability of a
> Django app? There are some other minor things like how to safely
> handle custom SQL, but the four I've listed are, in my experience, the
> big ones.
>
Good points.

And I also think about the deployment or installation of the apps, and
also want to easy deal with static files, such as css, images, js, of
cause these may still mainly associated with deployment things.

And consider the Ajax and reuse, so I think how to improve the reuse
of common apps, for example:

1. How to include templates or extend templates
2. How to reuse the view functions
3. How to deal ajax functionalities
4. How to seperate common functionalities and special functionalities

Maybe I write not so clearly, but I don't know much about how to
express my thoughts, I'm sorry.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: catalog of django apps?

2007-02-15 Thread limodou

On 2/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I'm currently working on a "DjangoForge" type of site right now.  I've
> been working on it for the past few weeks with any spare time that
> I've had.  It's definitely not ready for public consumption yet, but
> it's coming along very nicely and I think that more than a few people
> will find it useful.
>
> I'll definitely post a link to a beta version of the website when it's
> at that point, along with the source code.  It could be really cool if
> the code for the "DjangoForge" site itself could be public, and
> available through its own interface.  (How meta!)
>
> Looking forward to seeing your reactions in some days,
> Eric Florenzano
>
Great! I'll waiting for that.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: catalog of django apps?

2007-02-16 Thread limodou

On 2/16/07, mamcxyz <[EMAIL PROTECTED]> wrote:
>
> Other hard points is what to do with common "modules".
>
> For example, I made my own CMS. Then I wanna get Schatmo. Both have
> custom-extended user modesl, but both are diferent. Also city,
> country, etc...
>
> This is a hard problem. Because is necesary get rid of one of them,
> merge both or simply deny this kind of situation...
>
>
Yeah, you are right. So I think what we need maybe not the real reuse
common modules, but real projects , apps, or code snippets which can
be referenced. Of cause, along with the similar common modules come
out more and more, we could select one and specify it the "official"
common module. But I think we need more referenced apps or projects
first.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Only Validator

2007-02-16 Thread limodou

http://code.djangoproject.com/wiki/OnlyValidator

I worte it just because I only need pure validator functionality, and
I also want it support validator_list. So it'll not replace the
newforms, just for my personal usage, if you find it has some useful,
I'll be very happy for that.

And current version is also in development. But it already can be
used. And there is some different from newforms validation
functionality you should notice.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django snippets

2007-02-25 Thread limodou

On 2/26/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> For a while now I've been annoyed with the fact that, while it's
> relatively easy to build and advertise a complete Django application,
> it's relatively hard to advertise smaller pieces of useful code; there
> are tons of things in the "Cookbook" section of the wiki and on
> people's blogs, but it's almost impossible to keep track of them all.
>
> Hopefully, that will soon fade into memories of "that's what it was
> like in the old days", because today I've launched djangosnippets.org,
> a site whose sole purpose is to make it easy to post and share useful
> bits of Django-related code.
>
> I "soft" launched this earlier today by telling people at PyCon about
> it, so we've got a little bit of content in there now, but if you've
> ever done some cool little trick that made your life easier, I hope
> you'll come by, sign up for an account and post it for all to see, and
> help the site fill out :)
>
> http://www.djangosnippets.org/
>
> (and, of course, the code behind the site is all available under an
> open-source license; see the "about" page for instructions on how to
> get it).
>
Great! I like it. And the site is beautiful.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django snippets

2007-02-25 Thread limodou

On 2/26/07, limodou <[EMAIL PROTECTED]> wrote:
> On 2/26/07, James Bennett <[EMAIL PROTECTED]> wrote:
> >
> > For a while now I've been annoyed with the fact that, while it's
> > relatively easy to build and advertise a complete Django application,
> > it's relatively hard to advertise smaller pieces of useful code; there
> > are tons of things in the "Cookbook" section of the wiki and on
> > people's blogs, but it's almost impossible to keep track of them all.
> >
> > Hopefully, that will soon fade into memories of "that's what it was
> > like in the old days", because today I've launched djangosnippets.org,
> > a site whose sole purpose is to make it easy to post and share useful
> > bits of Django-related code.
> >
> > I "soft" launched this earlier today by telling people at PyCon about
> > it, so we've got a little bit of content in there now, but if you've
> > ever done some cool little trick that made your life easier, I hope
> > you'll come by, sign up for an account and post it for all to see, and
> > help the site fill out :)
> >
> > http://www.djangosnippets.org/
> >
> > (and, of course, the code behind the site is all available under an
> > open-source license; see the "about" page for instructions on how to
> > get it).
> >
> Great! I like it. And the site is beautiful.
>
Can you add RSS to the site, so that I can subscribe it to see the
newest entries.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django snippets

2007-02-25 Thread limodou

On 2/26/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 2/25/07, limodou <[EMAIL PROTECTED]> wrote:
> > Can you add RSS to the site, so that I can subscribe it to see the
> > newest entries.
>
> There's some very basic feed code in the app already, but it's not
> quite done and I want to get it right before I start exposing it :)
>
Ok, thanks.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django snippets

2007-02-25 Thread limodou

It seems that I can not change the language type of a snippets. So if
you can add changing language type functionality.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django snippets

2007-02-25 Thread limodou

Some suggestions:

For editing snippets, the title too short, and the code and the
description maybe larger.

For displaying snippets, maybe the description is under the code but
not in right side is better. Because some description maybe long, and
the right side is too narrow to display. And if I can write the
description in ReST?

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



djangosnippets.org is down?

2007-02-26 Thread limodou

Error messages:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

  File "/home/ubernostrum/pylib/django/core/handlers/modpython.py",
line 177, in handler
return ModPythonHandler()(req)

  File "/home/ubernostrum/pylib/django/core/handlers/modpython.py",
line 150, in __call__
response = self.get_response(request)

  File "/home/ubernostrum/pylib/django/core/handlers/base.py", line
125, in get_response
callback, param_dict = resolver.resolve500()

  File "/home/ubernostrum/pylib/django/core/urlresolvers.py", line
200, in resolve500
return self._resolve_special('500')

  File "/home/ubernostrum/pylib/django/core/urlresolvers.py", line
189, in _resolve_special
callback = getattr(self.urlconf_module, 'handler%s' % view_type)

  File "/home/ubernostrum/pylib/django/core/urlresolvers.py", line
177, in _get_urlconf_module
self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])

  File "/home/ubernostrum/pylib/snippets/urls.py", line 5, in ?
from cab.models import Language, Snippet, Tag

  File "/home/ubernostrum/pylib/cab/models.py", line 137

original = models.ForeignKey('self', null=True, blank=True,, editable=False,

   ^

SyntaxError: invalid syntax


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django snippets

2007-02-26 Thread limodou

It seems that only top 20 items can be displayed? right? I think it's a bug.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: json serialization without certain fields and with extra information?

2007-02-28 Thread limodou

On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> hey everyone,
>
>
> 1. is there any way to serialize models and remove some fields? I.e. I
> would like to serialize User for example, but I definitely don't want
> the email to be there.
>
> 2. is there a way to provide "custom" parts of the serialization? For
> example, when serializing a Book I would like to see it's "tags" even if
> they are just an array of tags without tag-id etc etc
>
> In general I would like to create some API pages that dump JSON. It
> would be great to be able to specify which parts of an object are
> "private" and which are "public" and which are "additional" so I could
> automatically do this.
>
> Any hints appreciated!
>
you can just create your own dict variable, and then using simplejson
to convert it to json


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: json serialization without certain fields and with extra information?

2007-02-28 Thread limodou

On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> limodou wrote:
> > On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
> >> hey everyone,
> >>
> >>
> >> 1. is there any way to serialize models and remove some fields? I.e. I
> >> would like to serialize User for example, but I definitely don't want
> >> the email to be there.
> >>
> >> 2. is there a way to provide "custom" parts of the serialization? For
> >> example, when serializing a Book I would like to see it's "tags" even if
> >> they are just an array of tags without tag-id etc etc
> >>
> >> In general I would like to create some API pages that dump JSON. It
> >> would be great to be able to specify which parts of an object are
> >> "private" and which are "public" and which are "additional" so I could
> >> automatically do this.
> >>
> >> Any hints appreciated!
> >>
> > you can just create your own dict variable, and then using simplejson
> > to convert it to json
>
> Of course, but that's exactly what I'm trying to avoid...
>
django also uses simplejson to dump python variable, why you want to
avoid it? And I think using simplejson is more flexiable and simple.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: json serialization without certain fields and with extra information?

2007-02-28 Thread limodou

My code will seem like:

def _get_data(request, obj):
if obj.icon:
icon = '' %
(obj.get_icon_url(), obj.title)
else:
icon = '' % obj.title
authors = [x.username for x in obj.authors.all()]
return ({'id':obj.id, 'icon':icon, 'title':obj.title,
'description':obj.description, 'author':','.join(authors),
'modifydate':obj.modifydate.strftime("%b %d,%Y %I:%m %p")})

def ajax_list(request):
result = []
objs = Book.objects.all()
for o in objs:
result.append(_get_data(request, o))
return json_response(result)

So I'd like write my own data gather method, and it can return other
data just like html snippets except for field value.

And for json method should be:

def json_response(data):
encode = settings.DEFAULT_CHARSET
return HttpResponse(simplejson.dumps(uni_str(data, encode)))

def uni_str(a, encoding=None):
if not encoding:
encoding = settings.DEFAULT_CHARSET
if isinstance(a, (list, tuple)):
s = []
for i, k in enumerate(a):
s.append(uni_str(k, encoding))
return s
elif isinstance(a, dict):
s = {}
for i, k in enumerate(a.items()):
key, value = k
s[uni_str(key, encoding)] = uni_str(value, encoding)
return s
elif isinstance(a, unicode):
return a
elif isinstance(a, (int, float)):
return a
elif isinstance(a, str) or (hasattr(a, '__str__') and
callable(getattr(a, '__str__'))):
if getattr(a, '__str__'):
a = str(a)
return unicode(a, encoding)
else:
return a

You can put json_response and uni_str into a module file. So I think
the work will be not so hard.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and jQuery Autocomplete Routing Help

2007-03-05 Thread limodou

On 3/6/07, johnny <[EMAIL PROTECTED]> wrote:
>
> I am using jQuery to do the autocomplete.  Autocomplete  request
> backend script like this: script_url?q=foo.  But there is a problem
> with django routing?
>
> (r'^tag/autocomplete/?q=(?P\w+)/$',
> 'apps.tag.views.tag_autocomplete'),
>
> Here is my error:
>
> [05/Mar/2007 15:11:51] "GET /tag/autocomplete/?q=a HTTP/1.1" 404 4218
> [05/Mar/2007 15:11:51] "GET /jquery/img/indicator.gif HTTP/1.1" 404
> 3697
> [05/Mar/2007 15:11:52] "GET /tag/autocomplete/?q=app HTTP/1.1" 404
> 4218
>
> Thank you.
>
Because django will parse the string after '?' as QueryString, so your
url pattern should be:

(r'^tag/autocomplete/$')

And process q=xxx in request.GET, for example:

s = request.GET.get('q', '')

>> [05/Mar/2007 15:11:51] "GET /jquery/img/indicator.gif HTTP/1.1"

It seems that you didn't correctly setup the static files, if you are
using development server(via manage.py runserver), you should see the
document:

 http://www.djangoproject.com/documentation/static_files/


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with profiles

2007-03-05 Thread limodou

On 3/6/07, MattW <[EMAIL PROTECTED]> wrote:
>
> Dear All,
>
> I've upgraded to the svn code, but I'm still having problems with user
> profiles.
>
> I've got a method in views.py:
>
> @login_required
> def viewprofile(request):
> uname = request.user.username
> try:
> profile = request.user.get_profile()
> except User.DoesNotExist:
> request.user.profile.donequestions=[]
> request.user.profile.donequestions.save()
>
> but I keep getting an error:
>
> DoesNotExist at /accounts/profile/
> MySiteProfile matching query does not exist.
>
> I know this is mentioned in the book, but I'm not clear on how to
> handle the error.
>
> Thanks,
>
> Matt
>
You can read this blog from James Bennett:
http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model
-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: creating a website log

2007-03-05 Thread limodou

I think maybe you can hook the pre_save() signal to do this thing.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: creating a website log

2007-03-05 Thread limodou

I think signals will be easier, if you also want to record delete
information of a record, you can also hook pre_delete, the pseudo code
is:

from django.db.models import signals

def pre_save(sender, instance, signal, *args, **kwargs):
if instance.id:#update
state = 'change'
old_record = serder.objects.get(id=instance.id) #because the
instance has been changed, so you should get the unchanged record
first
result = #compre old_record and instance
else:
state = 'add'
result = #format instance
WriteLog(state, result)

def pre_delete(sender, instance, signal, *args, **kwargs):
state = 'delete'
result = #format instance
WriteLog(state, result)

dispatcher.connect(pre_save , signal=signals.pre_save)
dispatcher.connect(pre_delete , signal=signals.pre_delete)

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: uploding image file

2007-03-05 Thread limodou

On 3/6/07, samira <[EMAIL PROTECTED]> wrote:
>
> Hello all
> I have Problem with uploading file in Django. First time I want to use
> python regular way of uploading file but it is not work by Django. As
> I studied Django has "ImageField" and "FillField" but I don't really
> know how I can use them, can any body help me?
> Regards
> Samia
>
http://www.djangoproject.com/documentation/faq/#how-do-i-use-image-and-file-fields

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: uploding image file

2007-03-06 Thread limodou

On 3/6/07, samira <[EMAIL PROTECTED]> wrote:
>
> Thanks, but I read it before, I add
> photo = models.ImageField('/images')in my models classes and

You should read the document carefully, and you should set upload_to parameter.

> newData = request.POST.copy()
> new_data.update(request.FILES) in views, Also for display it in
> template I add this line to it.
>
>  enctype="multipart/form-data">
>  {{ form.photo }}{{ form.photo_file }}
> but nothing display in my template :-s do you know what is ths
> problem? shall I write any code in manipulator or not?
>

And if you want to use image in template, you really used is the url
of the image, and there is a default get_FOO_url() function to return
the url of a file or image. You can find more details in db_api
document.

http://www.djangoproject.com/documentation/db_api/

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: uploding image file

2007-03-06 Thread limodou

On 3/6/07, samira <[EMAIL PROTECTED]> wrote:
>
> Mybe I didn't describe good. this is my project: I want to have user
> page that get member information and allow user to upload her display
> image. I don't know how I can do this,.
>
Here is a example:

1. settings.py

MEDIA_ROOT = 'media/'

2. template





3. model

class UserProfile(models.Model):
portrait = models.ImageField(_('Photo'), upload_to='photo', blank=True)
user = models.ForeignKey(User, unique=True)

You can see there is a upload_to parameter, so the real image will be save in :

os.path.join(MEDIA_ROOT, field.upload_to)

4.  view snippet

#get or create user
if data.get('photo', None):
filename = 'photo_%d.jpg' % user.id
user.save_photo_file(filename, data['photo']['content']

user.save()

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: applying a patch in windows ???

2007-03-06 Thread limodou

On 3/6/07, MacH G <[EMAIL PROTECTED]> wrote:
> hi all ,
> for the list_filter to add fields other than specified fields i got a patch
> file (list_filter.3.diff ) from the following url
> http://code.djangoproject.com/ticket/3400  but i do know
> how to apply it in windows could somebody tell me the command to apply it .
>
> thanks in advance
>
Try tortoiseSVN tool.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: uploding image file

2007-03-06 Thread limodou

On 3/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> You don't have to use the ImageField if you just want to upload it the
> old python way, you can just store the filename in a textfield...I
> gave a sample in a post yesterday:
>
> http://groups.google.com/group/django-users/browse_thread/thread/ede06a3602a39100?hl=en
>
Of cause you can do it yourself, but django's appoach is more
djangonist I think.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User model extension

2007-03-06 Thread limodou

On 3/6/07, Adam Rutkowski <[EMAIL PROTECTED]> wrote:
>
> First of all I'd like to say hi - I'm completely new to Django & Python,
> however very excited about it; great framework, great language.
> While reading Django docs I came across a problem, that I wasn't be able
> to find exact solution for. The point is how to handle a situation when
> the user model in one's app should be extended with some attributes
> (and/or) behaviour. I suppose I should use the existing model, somehow
> inherit from it or reuse it. How is this usually handled in the
> django-way?
> Take care

you can read this blog:
http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model
-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template Tags

2007-03-08 Thread limodou

On 3/8/07, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
> I have a template that loops through a simple query set and displays the
> data in a table.
>
> I now need to add another column to my table.  However,  the data in the
> new column is a calculation based on two of the other fields
> in that record.
>
> I presume that this can be done using a template tag, but I can't work
> out how it can be done.  I can't see how I can pass the values of the
> other fields into
> a tag.  Can anybody please advise the best way to do this.
>
> MerMer
>
You can see :

http://www.djangosnippets.org/snippets/9/


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and jQuery Autocomplete Routing Help

2007-03-08 Thread limodou

On 3/9/07, johnny <[EMAIL PROTECTED]> wrote:
>
> I am new to python and javaScript, I have created a funtion that
> return the tags via ajax.  I tried to replicate the php example.  But
> it's not working.  I doesn't return any tags back to my html page via
> ajax.  I need some help.  I am using jQuery autocomplete plugin from
> here: 
> http://just-tech.blogspot.com/2006/12/jquery-tweaking-auto-complete-plugin.html.
> Here is my function in view:
>
> def tag_autocomplete(request):
> #$q = $_GET['q'];
> #foreach($countries as $country) {
> #if(eregi("^".$q, $country)) {
> #echo $country."\r\n";
> #}
>
> s = request.GET.get('q', '')
> current_tags = list(Tag.objects.all())
> for tag in current_tags:
> if (search (s.lower(), tag.normalized_tag)):
> print "%s" % (tag.normalized_tag)
>
For django, just print won't return the result, but print output in
the console(if you are using develping server), you should return a
HttpResponse() object, and the good format of the returned data is
json, so there is a example from your code:

from django.utils import simplejson

s = request.GET.get('q', '')
#current_tags = list(Tag.objects.all())
result = []
for tag in Tag.objects.filter(name=s):
#if (search (s.lower(), tag.normalized_tag)):
#print "%s" % (tag.normalized_tag)
result.append(tag.normalized_tag)
return HttpResponse(simplejson.dumps(result))

If you are using Firefox and installed Firebug plugin, you can see the
response message.


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: choosing ajax framework (for my projects) :)

2007-03-09 Thread limodou

On 3/9/07, Igor Guerrero <[EMAIL PROTECTED]> wrote:
> http://jquery.com/
>
> On 3/9/07, ashwoods <[EMAIL PROTECTED]> wrote:
> >
> > with so many choices, you dont really know where to start :(
> >
> > things like i would like to do.
> >
> > 1) update the contents of a div element with the content fading out
> > and in (news on the first page)
> > 2) select form elements that populate depending what the "parent" form
> > element was chosen
> > 3) when i click on a link in a row of a table, change the rows height
> > and load some data and a picture.
> > 4) "live search"
> >
> > id say pretty simple stuff. but where should i start? prototype, mojo,
> > mochi, and thousands of others.
> > what would you recommend, those of you who have experience? :)
> >
> > i must also say that i actually don't enjoy coding in javascript :)
> > traumatized when trying to write cross browser javascript 8 years ago.
> >
> > cheers, ashley
> >
I also agree with jQuery. And I'v build some projects using jquery.
You can see an example at : http://limodou.51boo.com


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: choosing ajax framework (for my projects) :)

2007-03-10 Thread limodou
On 3/10/07, Georgi Stanojevski <[EMAIL PROTECTED]> wrote:
>
> limodou напиша:
>
> > You can see an example at : http://limodou.51boo.com
>
> Your forms(I tried user registration) don't give any feedback while they
> are being submited that's really, really bad usability. :)
>
> When you do something with ajax it's really important to give feedback
> to the user that something is happening.
> At least Firefox doesn't show a XMLHTTPRequest as being loaded in the
> status bar and you don't know how long does it take to get the response
> back from your server back to the user even if it's just couple of bytes.
>
> I tend to replace the submit button with an ajax-loader animated gif(*1)
> and disable the forms while they are beeing processed.
>
> Here is an example with Prototype on
> http://code.djangoproject.com/wiki/AjaxPrototypeNewForms
>
>
> (*1) There are some nice ajax loader gifs here http://www.ajaxload.info/
>
What you said are some details, and if you want to implement them with
jQuery, it's not difficult in jQuery. I just mainly aim the
functionality.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: QueryDict instance is immutable

2007-03-12 Thread limodou

On 3/13/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> Hi!
> I have created a form using newforms, and one field is author which I
> want to fill using the current username, I did this:
> request.POST['author']="Username I want"
> and I got this error:
> "QueryDict instance is immutable"
> Ok, what should I do? I thought about create a hidden widget for this
> field, but that's not secure enough.
> Is there a way to do what I want?
>
> Thank you!
>
You can do like this:

old = request.POST._mutable
request.POST._mutable = True
for k, v in args.items():
request.POST[k] = v
request.POST._mutable = old

But except you have strong idea, I don't suggest that you do like
above. You can copy() it and the new instance can be changed.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using template filters inside condition statements

2007-03-13 Thread limodou

On 3/14/07, bgcooper <[EMAIL PROTECTED]> wrote:
>
> Our app uses a number of state integers mapped to names inside a
> dictionary. The state stored in the model is an integer and we use the
> dictionary to pull out the names whenever we want to.
>
> We have a custom template filter to get the names from the template
> context. e.g.
>
> {{ message.state|stateName }}

First, you could see 'choices' parameter in CharField or IntegerField,
and django has a handly function get_FOO_display() to get the
corresponding string value of a special key, just like what you want.
In db_api document, searcin get_FOO_display you'll get the answer.

>
> We cannot, however, seem to get this working inside condition
> statements in a template e.g.
>
> {% ifequal message.state|stateName "Sent" %}
>
> Is this a known limitation? I'd rather use this in my templates than
> some magic number associated with the state.
>
>
Second, yeah there is limit for ifequal, you can not using filter to
template var. There is not a good sulotion I think, except you can use
CatchTag written by me. http://www.djangosnippets.org/snippets/10/

For example:

{% catch as state %}{{ message.state|stateName }}{% endcatch %}
{% ifequal state "Sent" %}


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: backup/restore DB data...

2007-03-16 Thread limodou

On 3/16/07, Jens Diemer <[EMAIL PROTECTED]> wrote:
>
>
> I would like to backup and restore my django App-Database. This should
> be usable with a Web-GUI.
> I thought fixtures would be well usable for it. But there are some
> problems with this. Look at:
> http://groups.google.com/group/django-users/browse_thread/thread/6a4e9781d08ae815
>
> What is a good/other way, for DB backups?
>
You can try db_dump.py tool, it's not a web-gui based, but a command line tool.

http://www.djangosnippets.org/snippets/14/

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: backup/restore DB data...

2007-03-16 Thread limodou

On 3/17/07, Michael <[EMAIL PROTECTED]> wrote:
>
>
> On 3/17/07, limodou <[EMAIL PROTECTED] > wrote:
> >
> > On 3/16/07, Jens Diemer <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > I would like to backup and restore my django App-Database. This should
> > > be usable with a Web-GUI.
> > > I thought fixtures would be well usable for it. But there are some
> > > problems with this. Look at:
> > >
> http://groups.google.com/group/django-users/browse_thread/thread/6a4e9781d08ae815
> > >
> > > What is a good/other way, for DB backups?
> > >
> > You can try db_dump.py tool, it's not a web-gui based, but a command line
> tool.
> >
> > http://www.djangosnippets.org/snippets/14/
> >
>
> It is a very good tool to work with Mysql or sqlite3 but not with
> Postgresql.
>
I haven't worked with Postgresql ever, or if you like you can help me
with it. Or if I have time, I need to learn about Postgresql.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: backup/restore DB data...

2007-03-16 Thread limodou

On 3/16/07, Jens Diemer <[EMAIL PROTECTED]> wrote:
>
> limodou schrieb:
> > You can try db_dump.py tool, it's not a web-gui based, but a command line 
> > tool.
> >
> > http://www.djangosnippets.org/snippets/14/
>
> Very cool! It seems to work without problems ;)
>
> I made a hack to put it into my web install section:
> http://pylucid.net/trac/changeset/930
>
> But i must redirect the stdout and make a fake optparse options...
>
> Is it possible you change the script, so its easy to use it without a shell?
>

So you want just run it as a module? And what output do you want? Just
output to stdout?

>
> And a feature request: a option to zip all dumpfiles and load the dump
> on-the-fly from a zip archive. So a user can download one zipfile as a
> backup ;)
>

It's a good idea. I'll think about it.

>
> btw. can you insert a Licence statements into you script?

Ok, I'll add a BSD License.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: I wish for a "less than" and "greater than" in templates

2007-03-21 Thread limodou

On 3/22/07, Michael Lake <[EMAIL PROTECTED]> wrote:
>
> Kenneth Gonsalves wrote:
>
> > On 22-Mar-07, at 9:25 AM, Michael Lake wrote:
> >>>write your own tag - someone has done it, you can see it in this
> >>>file:
> >>>
> >>>http://nrcfosshelpline.in/code/browser/trunk/web/templatetags/
> >>>base_utils.py
> >>>
> >>>class CompareNode near the end
> >>
> >>But that link above no longer works.
>
> > works now - thanks for the heads up on this
> Thanks for that Kenneth.
> The code there looks like just what I need.
>
You can also use PyIf tag(written by me) to do that.

http://www.djangosnippets.org/snippets/12/

And it can support any python expression. So it's more general I think.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Powered Tabblo to be acquired by HP

2007-03-23 Thread limodou

On 3/23/07, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>
> We at Tabblo are of course very excited about the acquisition by HP.
> One of the things that HP valued in Tabblo was our ability to innovate
> quickly and deliver solid products in a short amount of time.  We
> definitely feel like Django was one of the reasons we were able to do
> that, and to make such an impression on HP.
>
> So thanks a bunch to the entire Django community.  You were part of our
> success.  We'll be continuing with Django inside HP.  Here's to more
> successes in the future!
>
> --Ned.
>
Wow, great!

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django models to SqlAlchemy models | preliminary implementation

2007-04-09 Thread limodou

On 4/10/07, Norjee <[EMAIL PROTECTED]> wrote:
>
> Quite often there has been talk about using SqlALchemy in Django, but
> as far as I'm aware there is no implementation yet.
>
> For me, replacing Django's model is definitely too ambitious, so I
> tried the next best thing, use Django's model declaration to create a
> SqlAlchemy binding. For most of the (read my) use cases, this works.
> As my main interest in SqlAlchemy is to use its more advanced query
> syntax, it is sufficient for me. One notable downside is that it adds
> a little overhead, instead of one model representation you end up with
> the, the Django one and the SqlAlchemy one.. But so be it..
>
> Anyway the first steps can be found at 
> http://jeroen.concept-q.com/projects/djangoalchemy/
> Any comments are welcome. (Though, as I mentioned in the readme as
> well.. I'll be rather busy and probably slow to respond.. so be it..)
>
Great!

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Detect ajax request

2007-04-10 Thread limodou

On 4/10/07, Ryan  Kanno <[EMAIL PROTECTED]> wrote:
>
> I've searched Googs and this group for an answer to the following
> question:
>
> Is there a standard way to detect if a request was an ajax one?  I
> know I could append a key to the ajax request like in Mr. Bennett's
> post here:
>
> http://www.b-list.org/weblog/2006/07/31/django-tips-simple-ajax-example-part-1
>
> ie http://website.com/some/request/?xhr and in my view, dump out json
> accordingly, etc, but I was wondering if there was a standard way
> without attaching a key (perhaps looking at a request header).
>
> Thanks,
> Ryan
>
For some ajax lib (i.e. jQuery, prototype) they will send a custom http header:

HTTP_X_REQUESTED_WITH = 'XMLHttpRequest'

So you can test it to know if a request is a ajax request I think.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Which ajax framework django will support in the upcoming 1.0, prototype/dojo/jquery?

2007-04-12 Thread limodou

On 4/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> pcad, there's some good points there, and maybe many of us could share
> more code showing how we've integrated whatever JS toolkit with
> Django. But I like the agnostic stand. They give the tools to connect
> easily. HOW you connect is up to you.
>
> I like jQuery. You like mochikit. Others like YUI, or Prototype, or
> Dojo. Who's right? Everybody. Nobody. It depends.
>

Goog point! I like jQuery also.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

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



Re: \d and \w regular expressions?

2007-05-08 Thread limodou

On 5/9/07, gsmith <[EMAIL PROTECTED]> wrote:
>
> Is there any documentation of what these do?  I'm assuming that this
> is a Python regular expression?
>
> The reason I ask is becuase I have a line in my urls.py file that
> looks like this
>
> (r'^csi/rso/(news|members)/(\w{1,100})/$',
> 'mysite.rso.views_rso.showtitlepage'),  This works fine when the value
> of my url doesn't contain a "-".  However, sometimes I have a url like
> below
>
> "csi/rso/members/the-test/"
>
> The above errors out becuase of the "-" in the url.  Does anybody know
> what I need to use to accept the character "-" in the url?
>
> Also, on a side note...is it good to have \w{1,100}.  This variable is
> going to be a name.  I'll never know how long a name is and it's
> doubtful that a name would be 100 characters.  Is there a better way
> of capturing this value.
>
> Thanks for any help
>
I suggest that you can test the length of the name in view method, and
don't limit the length of url pattern. The pattern could be:

[\w-]{1,100}

If you don't want {1,100}, you could [\w-]+


-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error creating super user

2007-05-08 Thread limodou

On 5/9/07, Ben Schwarze <[EMAIL PROTECTED]> wrote:
>
> Hi Kabads,
>
> you need to add "django.contrib.admin" to your installed apps in
> settings:
>
> E.g.:
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> )
>
> Afterwards you should run "python manage.py syncdb" again. This will
> prompt you to create a superuser.
>
> Cheers,
> Ben
>
If you don't want to use admin, you should just install
django.contrib.auth, it's enough.

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



about i18n question

2005-11-04 Thread limodou
I found that the zh_CN translation option should be "Simplified
Chinese", but not "Traditional Chinese" in the global_settings.py in
conf directory。

And I'm the Chinese translator, I want to know how to submit the changes.

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


Re: about i18n question

2005-11-04 Thread limodou

2005/11/4, hugo <[EMAIL PROTECTED]>:
> >And I'm the Chinese translator, I want to
> >know how to submit the changes.
>
> I'd say best way to do it is to open a ticket and attach the updated PO
> file. Then either Adrian or Jacob can put it into trunk.

I see. Thanks.

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


Django developing in NewEdit

2005-11-05 Thread limodou

NewEdit is a Python Editor base on wxPython. I'm learning django
recently, and I'm beginning develop some extension about django in
NewEdit. The process is continuing. I'v finished something like these:

 * django project wizard(need install it) -- you can create a django
project directory in NewEdit. This function will invoke
"django-admin.py startproj myproj" command, and also create run.bat
and run file, these files will set PYTHONPATH and
DJANGO_SETTINGS_MODULE environment variable. So you can run them
before running the django-admin.py.

 * django project plugin(need choice it) -- you can create a django
app under a django project directory. This function will invoke
"django-admin.py  startapp myapp" command. This function is combined
with directory browser, so you need open directory browser first(press
F2).

 * auto extend function(need download it) -- Just a test template. I'v
finished .html extension. So as you editing html file in django
project, once you press some key, NewEdit will auto extend it. For
example:

as you entering "{%", once you press space key, NewEdit will popup a
list including "extends, comment, for, ..." etc.

I'm sorry for my English. But I hope it will be useful for developing django.

In order to express the meaning more clearly, I'll make a flash
tutorial about this as soon as I can. But the function is still
developing, if you have good ideas, you can email a letter.

BTW, you can also using NewEdit to save some code snippets, and you
can apply them as editing.

NewEdit project: http://wiki.woodpecker.org.cn/moin/NewEdit
SVN: http://cvs.woodpecker.org.cn/svn/woodpecker/newedit (recommend)

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


Flash tutorial: How to use NewEdit to build simple django project skelecton

2005-11-06 Thread limodou

Flash tutorial online review:
http://wiki.woodpecker.org.cn/moin/NewEditTutorial?action=AttachFile&do=get&target=how_djangoproj.swf

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


Re: django-admin not seeing settings.py

2005-11-06 Thread limodou

2005/11/7, Waylan Limberg <[EMAIL PROTECTED]>:
>
> I'v gone through the first toturial before on another box no problem,
> but on this machine I can't seem to get it to work. After setting the
> database conection info in myproject/settings.py I try to run
> 'django-admin.py init --settings=myproject.settings'. I get the
> following error:
>
> Error: The database couldn't be initialized.
> Could not load database backend: No module named psycopg. Is your
> DATABASE_ENGINE setting (currently 'postgresql') spelled correctly?
> Available optionas are: 'ado_mssql', 'mysql', 'postgresql', 'sqlite3'
>
> The thing is that I DO NOT have it set to 'postgresql' in
> myproject/setting.py but have tried both 'mysql' and 'sqlite3'. I
> still get the same message. Oh, and I can 'import myproject' from the
> Python interactive prompt without problem, so I know thats not it.
> I've tried setting the 'DJANGO_SETTINGS_MODULE' or using the
> '--settings' option, but nothing seems to make a difference. Any
> suggestions?

if you set sqlite3, I tried myself, you should also need to install
pysqlite2 package, and also need to set DATABASE_NAME variable, and
also need to use sqlite3 command tool to create a database file,
django-admin.py will not create one for you. It's my experience.


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


Re: django-admin not seeing settings.py

2005-11-06 Thread limodou

> I just noticed that the line breaks (in the comments) on the first two
> lines were actual line breaks, not just wrapping text. I fixed that,
> but still no go. The last two lines are definitely wrapping text.
>
> It's still telling me the DATABASE_ENGINE is set to 'postgresql'
>

maybe there is a settings directory and settings.py, if the situation
is like this, you should delete the settings directory. I'v
encountered this situation once, because of the admin manage changes.
You should delete all django source code, and recheckout the code from
svn.

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


why pub_date is split to pub_date_date and pub_date_time

2005-11-16 Thread limodou

I want to use generic view to create my model polls's form html code,
but I found pub_date is split to pub_date_date and pub_date_time, I
want to know if there are some documents remind this. I used below
code:

{% for field in form.fields %}
{{field}}
{% endfor %}

and I want to know how to get field display name?

btw: polls model is the example from tutorial

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


FileUploadField bug?

2005-11-16 Thread limodou

I'm testing generic view, and I had a FileField in my polls model, but
as I summited, I got a Exception:

TypeError at /polls/add/
string indices must be integers
Request Method: POST
Request URL:http://127.0.0.1:8000/polls/add/
Exception Type: TypeError
Exception Value:string indices must be integers
Exception Location:

c:\python24\lib\site-packages\django-0.90-py2.4.egg\django\core\formfields.py
in isNonEmptyFile, line 499

the code line is: if not field_data['content']:

And I print the field_data, I saw it is a string, but not a list. Is this a bug?

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


Re: FileUploadField bug?

2005-11-16 Thread limodou

2005/11/16, limodou <[EMAIL PROTECTED]>:
> I'm testing generic view, and I had a FileField in my polls model, but
> as I summited, I got a Exception:
>
> TypeError at /polls/add/
> string indices must be integers
> Request Method: POST
> Request URL:http://127.0.0.1:8000/polls/add/
> Exception Type: TypeError
> Exception Value:string indices must be integers
> Exception Location:
> 
> c:\python24\lib\site-packages\django-0.90-py2.4.egg\django\core\formfields.py
> in isNonEmptyFile, line 499
>
> the code line is: if not field_data['content']:
>
> And I print the field_data, I saw it is a string, but not a list. Is this a 
> bug?
>

I want to know why no one answer my email?

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


Re: why pub_date is split to pub_date_date and pub_date_time

2005-11-16 Thread limodou

> Fields can create multiple FormFields.

So you mean Fields is not the same as FormFields, and the splited
FormFields can be combine again as auto saving to DB? But if I want to
manually create a form in template, what rule should I followed with ?
Is there some document?

> This is why iterating over the
> FormFields is not going to get you very satisfactory results for
> autogenerating a form.
>
> If you wish to autogenerate a form consistently, you can take a look at
> how it is done by the admin in the new-admin branch. However, this part
> is not yet documented and won't be until the API is fully baked. (Post
> core fields removal.)
>
> Robert
>

Thanks.

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


Re: FileUploadField bug?

2005-11-16 Thread limodou

2005/11/16, Adrian Holovaty <[EMAIL PROTECTED]>:
>
> On 11/16/05, limodou <[EMAIL PROTECTED]> wrote:
> > I'm testing generic view, and I had a FileField in my polls model, but
> > as I summited, I got a Exception:
>
> Hi limidou,
>
> We can't help you much in this case, unless you paste your URLconf and
> models. Go ahead and show us that stuff, and we'll be able to help
> you!
>
Thanks to  Adrian first.

May be it's a bug, I'v made a patch to it, the ticket is #816. I
followed the tutorial, my model is:

#coding=utf-8
from django.core import meta
import datetime

# Create your models here.

class Poll(meta.Model):
question = meta.CharField(maxlength=200)
pub_date = meta.DateTimeField('date published')
attachment = meta.FileField(upload_to='upload')

def __repr__(self):
return self.question

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
was_published_today.short_description = 'Was published today'

class META:
admin = meta.Admin(
fields = (
(None, {'fields': ('question',)}),
('Test', {'fields': ('pub_date',), 'classes': 'collapse'}),
('attachment', {'fields':('attachment',)}),
),
list_display = ('question', 'pub_date', 'was_published_today'),
list_filter = ['pub_date'],
search_fields = ['question'],
date_hierarchy = 'pub_date',
)

class Choice(meta.Model):
poll = meta.ForeignKey(Poll, edit_inline=meta.TABULAR, num_in_admin=3)
choice = meta.CharField(maxlength=200, core=True)
votes = meta.IntegerField(core=True)

def __repr__(self):
return self.choice

My URLconf is:

from django.conf.urls.defaults import *

info_dict = {
'app_label': 'polls',
'module_name': 'polls',
}

urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list', info_dict),
(r'^(?P\d+)/$',
'django.views.generic.list_detail.object_detail', info_dict),
(r'^(?P\d+)/results/$',
'django.views.generic.list_detail.object_detail', dict(info_dict,
template_name='polls/results')),
(r'^(?P\d+)/vote/$', 'myproj.apps.polls.views.polls.vote'),
(r'^add/$', 'django.views.generic.create_update.create_object',
dict(info_dict, post_save_redirect="/polls/%(id)s/")),
(r'^(?P\d+)/update/$',
'django.views.generic.create_update.update_object', dict(info_dict,
post_save_redirect="/polls/%(object_id)s/")),
)

my polls_form.html template is:

{% block content %}
Create a polls:

{% if form.has_errors %}
Please correct the following error{{ errors|pluralize }}:
{% endif %}


{% for field in form.fields %}


{{field.field_name}}

{{field}}


{% if field.errors %}*** {{ field.errors|join:", "
}}{% endif %}
{% endfor %}








{% endblock %}

As I summited with a file, I always got a error message is "*** This
field is required." under the attachment field. So I checked the
generic source code and compared with admin source code, I found the
code is not very the same, so I made the ticket #816, and as I
submited again, it was successful.

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


Re: why pub_date is split to pub_date_date and pub_date_time

2005-11-16 Thread limodou

> This isn't very well documented right now.
> See "http://www.djangoproject.com/documentation/model_api/";, under
> DateTimeField:
>
> "the admin represents this as two  fields, with
> JavaScript shortcuts. "

But there are no JavaScript shortcuts in output code of generic view,
may be a bug?
>
> It should probably be mentioned that this is not just in the admin, but
> also in every automatically created manipulator.

Thanks you very much. I see.

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


Re: why pub_date is split to pub_date_date and pub_date_time

2005-11-16 Thread limodou

2005/11/17, Robert Wittams <[EMAIL PROTECTED]>:
>
> limodou wrote:
> >>This isn't very well documented right now.
> >>See "http://www.djangoproject.com/documentation/model_api/";, under
> >>DateTimeField:
> >>
> >>"the admin represents this as two  fields, with
> >>JavaScript shortcuts. "
> >
> >
> > But there are no JavaScript shortcuts in output code of generic view,
> > may be a bug?
>
> You can include the javascript from the admin in your own app.
>

Ok, thanks.


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


Re: Access request object in model's hooks and display methods

2005-11-17 Thread limodou

2005/11/17, plisk <[EMAIL PROTECTED]>:
>
> Hi there.
>
> Seems like its not possible to access request object in hooks like
> pre_save and display methods(those are listed in list_display) ? Is it
> supposed to be like this by design ? If so then hardly its very
> convinient to use in real applications. For example, i would like to
> get server address and port in post_save hook, current logged in user
> in display method and so on..
>
> Or maybe there is the way ?
>
>

May be middleware can do this. But I'm not sure.

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


Using NewEdit to design django model

2005-11-18 Thread limodou

In order to quick create django model, I make some extension to
NewEdit(http://wiki.woodpecker.org.cn/moin/NewEdit), so you can create
django model in GUI method. I'v made a flash tutorial, you can see it
online or download it.

see online: 
http://wiki.woodpecker.org.cn/moin/NewEditTutorial?action=AttachFile&do=get&target=how_django_model.swf
download it(recommend):
http://wiki.woodpecker.org.cn/moin/NewEditTutorial?action=AttachFile&do=get&target=how_django_model.zip

Hope someone has interesting.
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit


Re: Django developing in NewEdit

2005-11-22 Thread limodou

> Great job! I was waiting for something like this!
>
Thanks. :)

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


Re: 关于对APP也应加入一个"verbose_name"或"verbose_name_plural"

2005-12-23 Thread limodou
在 05-12-24,风尘无限<[EMAIL PROTECTED]> 写道:
>
> 对于非英语的Django用户/爱好者,对每一个"app"也加入一个"verbose_name"或"verbose_name_plural",以便于WEB
> PAGE的友好好浏览是必要的。
>
> 我的实现方式:
> 一、修改adminapplist.py为:
> 
> from django.core import template
>
> class AdminApplistNode(template.Node):
> def __init__(self, varname):
> self.varname = varname
>
> def render(self, context):
> from django.core import meta
> from django.utils.text import capfirst
> app_list = []
> user = context['user']
>
> for app in meta.get_installed_model_modules():
> app_label = ''
> app_name = app.__name__[app.__name__.rindex('.')+1:]
>
> if hasattr(app, 'verbose_name'):
> app_label = app.verbose_name
> else:
> app_label = app_name;
> has_module_perms = user.has_module_perms(app_label)
>
> if has_module_perms:
> model_list = []
> for m in app._MODELS:
> if m._meta.admin:
> module_name = m._meta.module_name
> perms = {
> 'add': user.has_perm("%s.%s" % (app_label,
> m._meta.get_add_permission())),
> 'change': user.has_perm("%s.%s" %
> (app_label, m._meta.get_change_permission())),
> 'delete': user.has_perm("%s.%s" %
> (app_label, m._meta.get_delete_permission())),
> }
>
> # Check whether user has any perm for this
> module.
> # If so, add the module to the model_list.
> if True in perms.values():
> model_list.append({
> 'name':
> capfirst(m._meta.verbose_name_plural),
> 'admin_url': '%s/%s/' % (app_name,
> m._meta.module_name),
> 'perms': perms,
> })
>
> if model_list:
> app_list.append({
> 'name': app_name.title(),
> 'title': app_label.title(),
> 'has_module_perms': has_module_perms,
> 'models': model_list,
> })
> context[self.varname] = app_list
> return ''
>
> def get_admin_app_list(parser, token):
> """
> {% get_admin_app_list as app_list %}
> """
> tokens = token.contents.split()
> if len(tokens) < 3:
> raise template.TemplateSyntaxError, "'%s' tag requires two
> arguments" % tokens[0]
> if tokens[1] != 'as':
> raise template.TemplateSyntaxError, "First argument to '%s' tag
> must be 'as'" % tokens[0]
> return AdminApplistNode(tokens[2])
>
> template.register_tag('get_admin_app_list', get_admin_app_list)
> ###
> 二、修改template index.hmtl的内容:
> {% for app in app_list %}
> 
> {{ app.name }}
> 
> {% for model in app.models %}
> 为:
> {% for app in app_list %}
> 
>     {{ app.title }}
> 
> {% for model in app.models %}
> ###
> ###
> 三、这样在每一个app的module定义PY文件中加入如下属性就可以在管理界面中看到了:
> ###
> verbose_name = u'保险业务信息管理'.encode('gb2312')
> ###
>
>
兄弟,这是老外的邮件列表啊,怎么不用英文呢?老外有几个看得懂呢?

Hi, guy, why did you write it in Chinese, why not in English?

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


Re: Upgrading models...

2005-12-26 Thread limodou

2005/12/27, quentinsf <[EMAIL PROTECTED]>:
>
> There's also some stuff here:
>
> http://code.djangoproject.com/wiki/DocumentationSuggestions
>

I suggest that there may be a admin command just like: django-admin.py
reinstall app
to do the things like: django-admin.py sqlreset appname | psql dbname

I think this will be helpful in developing period.

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


Re: Upgrading models...

2005-12-26 Thread limodou

2005/12/27, James Bennett <[EMAIL PROTECTED]>:
>
> On 12/26/05, limodou <[EMAIL PROTECTED]> wrote:
> > I suggest that there may be a admin command just like: django-admin.py
> > reinstall app
> > to do the things like: django-admin.py sqlreset appname | psql dbname
> >
> > I think this will be helpful in developing period.
>
> I'd be against it, just because I don't think there should ever be an
> automated script that blows away an existing DB. And as for speed,
> well, most of the time when I'm developing like that and changing
> models a lot I just use sqlite and delete the DB file when I update
> the model, then recreate it quickly with django-admin.py or manage.py.
> Just as easy that way.
>

May be sqlite can do like that, but other databases can not just
remove the database file. And this appoach will destroy all the
tables, but what I want may be just a single app, not the whole
project. So if there is not a "reinstall"(or reinstallapp) command I
still need to run something like: django-admin.py sqlreset appname |
psql dbname

What you said just suit for some situation.

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


Re: Upgrading models...

2005-12-26 Thread limodou

2005/12/27, James Bennett <[EMAIL PROTECTED]>:
>
> On 12/26/05, limodou <[EMAIL PROTECTED]> wrote:
> > May be sqlite can do like that, but other databases can not just
> > remove the database file. And this appoach will destroy all the
> > tables, but what I want may be just a single app, not the whole
> > project. So if there is not a "reinstall"(or reinstallapp) command I
> > still need to run something like: django-admin.py sqlreset appname |
> > psql dbname
>
> I've just always considered sqlite to be a really handy DB for
> development use because of things like this; there's no need to muck
> about with running your own database server (though for later stages
> of testing I do have MySQL and Postgres on a development box), with
> creating databases and granting access, etc., and it's often far
> easier to delete an sqlite file and re-create it (just put the
> appropriate calls to django-admin.py or, better, manage.py on separate
> lines in a shell script, and you can completely reset in a matter of
> seconds) than to drop database tables and figure out which ones need
> to be re-created or, worse, to blow away an entire MySQL or Postgres
> database and re-create it with appropriate permissions.
>
If there is a handy command in django-admin.py, I think, it may be
better than everyone who need the function has to write his own shell
file to do the same things. It just a suggestion, I think it can be
helpful for someone like me -- a lazy man.

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


Re: Is Django right now me?

2005-12-26 Thread limodou

2005/12/27, Tom Tobin <[EMAIL PROTECTED]>:
>
> On 12/27/05, reiale <[EMAIL PROTECTED]> wrote:
> >
> > Does Django sound right for this project?
>
> I don't know; I couldn't tell which of the dozen of your
> (accidentally, I assume) copy-and-pasted sections of your email to
> read.  :-p
>
maybe it a spam email?

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


Maybe the easiest tutorial

2005-12-26 Thread limodou

I'v made a easiest and simplest tutorial, just want the study work can
be from scratch but not a big one, I hope this will be helpful. This
tutorial will only aim to create a "Hello, django!" page, there will
be no more things except it. So there is almost nothings in it, but it
can be run in django.

1. setup the django (just python setup.py install)

2. django-admin.py startproject newtest
then goto newtest directory

3. modify settings.py
I won't want to change it, but if I just start the web server, there
will raise a execption show that I didn't config the database options.
So I had to change the settings.py, just these lines:

DATABASE_ENGINE = 'sqlite3'

But I'll not use them in this tutorial. And make sure you have
pysqlite2 module installed. If this one can be skipped, this tutorial
will be easier.

4. create a helloworld.py file in newtest directory
the content of the file is:

from django.utils.httpwrappers import HttpResponse

def index(request):
return HttpResponse("Hello, django.")

5. modify urls.py

urlpatterns = patterns('',
# Example:
(r'^$', 'helloworld.index'),

# Uncomment this for admin:
# (r'^admin/', include('django.contrib.admin.urls.admin')),
)

I map the null to 'helloworld.index'

6. start the web server

manage.py runserver

7. view the result

You will see the "Hello, django!" in the browser.

That's the all. The only thing I used just is urldispatcher.

I hope it will be fun for beginners.
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit


Re: Maybe the easiest tutorial

2005-12-27 Thread limodou
2005/12/28, Jarek Zgoda <[EMAIL PROTECTED]>:
>
> limodou napisał(a):
>
> > 7. view the result
> >
> > You will see the "Hello, django!" in the browser.
> >
> > That's the all. The only thing I used just is urldispatcher.
> >
> > I hope it will be fun for beginners.
>
> Yea, this is the simplest "tutorial" one can imagine, but it wouldn't
> help the beginners in any way, as it doesn't explain how Django works.
> IMO, it's worthless.
>

What I want is beginning from the easiest things, I think a good
tutorial should spread its content a bit and a bit. So the tutorial I
written, just shows how django works, and how to use url dispatch. And
it's just a beginning tutorial, I'v finished three chapter but written
in Chinese. So others will not be the easitest one. I don't want to
explain how django works, but just show. If someone like it and want
to know why, he will drill down himself. Remember, what I written just
for beginners who may have other experience. The official tutorial
shows too much at once just for newbies I throught, if it can spread
slowly I think it's better.

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


Re: A very simple application

2005-12-30 Thread limodou

2005/12/31, Michael Hipp <[EMAIL PROTECTED]>:
>
> I have a base.html that is a skeleton html document with this call to my
> 'simple' app added:
>
>{{ simple.saysomething }}


You may make a wrong understand about the view, url-dispatch, and
template. The view is used to provide methods which can be used to
output web pages. But you cann't directly use them, they should be
configured in urls.py, just like:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
# Example:
(r'^$', 'helloworld.index'),
)

The above means that a domain just like single http://localhost:8000
matches the rule (r'^$'), and django will invoke helloworld.index
method, helloworld is a view, and index is a method in it, just like
your code.

But if you want to access template, you should deal the template and
output the content, just like:

from django.core.extensions import render_to_response
def index(request):
return render_to_response('base', {'message': "This is from the
'simple' app."})

and your templat should be:

{{ message }}

And you also should configure the template directory in settings.py.
There is so many things need to do.

I'm writting a tutorial step by step , but it's written in Chinese, if
you can read it , just to see my blog. In that I explained a bit and a
bit.

>
> In mysite/apps/simple/views.py there is:
>
>from django.utils.httpwrappers import HttpResponse
>def saysomething(request):
>  return HttpResponse("This is from the 'simple' app.")
>
> And settings.py has:
>INSTALLED_APPS = ("mysite.apps.simple",)
>
> But there appears to be no output from "saysomething". What am I missing?
>
> Also, what is the best way to get debug output from Django? I tried a 'print'
> statement in 'saysomething' but it seemed to go nowhere.
>
> Thanks,
> Michael
>


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


Re: A very simple application

2005-12-30 Thread limodou

> Yes. But I still seem to be off somewhere...
>
>  From 
> http://www.djangoproject.com/documentation/tutorial3/#write-your-first-view
> there is:
> --
> from django.utils.httpwrappers import HttpResponse
>
> def index(request):
>  return HttpResponse("Hello, world. You're at the poll index.")

HttpResponse just return the message to the caller, not directly to the screen.

>
> This is the simplest view possible. Go to "/polls/" in your browser, and you
> should see your text.
> --
>
> I don't know how to reconcile this with what James Bennett and limodou wrote
> about using render_to_response() instead of HttpResponse() as none of the
> examples in the docs use render_to_response() as their return value from the
> view method. So the advice seems contradictory to the docs.

render_to_response is a utility function provided by django, if you
don't want to use it, you can do it yourself, just like:

from django.utils.httpwrappers import HttpResponse
from django.core.template import loader, Context

def output(request, filename):
response = HttpResponse()
t = loader.get_template('base')
c = Context({
'message': 'message here',
})
response.write(t.render(c))
return response
>
> The tutorial seems to be saying that anything returned from a view by way of
> the HttpResponse() call will be sent directly to the screen. And at another
> place is shows the url pattern to trap the correct url:
>(r'^polls/$', 'myproject.apps.polls.views.index')
> Which seems a simple process of
>urlpattern -> view -> template -> screen
>
Wrong, should be:

urldispatch -> view -> screen
   |
   v
  template

template can only be called, but it cann't directly output to screen,
only views can.

> But I can't see in the tutorial example what is put in the template that will
> receive this "Hello, world..." output.
>
template receives variable, and it should be invoked by views.

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


Re: registration/login or admin/login?

2005-12-31 Thread limodou

2005/12/31, Vladimir Labath <[EMAIL PROTECTED]>:
> here is my solutions
>
> create folder 'registration' in 'templates'
> copy
> django_src/django/contrib/admin/templates/admin/login.html
> to templates/registartion
> change {% extends "admin/base_site" %}
>
> for example into views.py:
> from django.views.decorators.auth import login_required
> ..
>  
>  def add_entry(request):
>  .
> ...
> add_entry = login_required(add_entry)
>
> good luck
>  Vlado
>
>
>
>
> On 12/27/05, Alice <[EMAIL PROTECTED]> wrote:
> >
> > yes, and that doesn't contain anything on using the existing templates
> > and views - if they should be used at all.
> >
> > Alice

I found that you can use admin's login function:

from django.contrib.admin.views.decorators import staff_member_required

@staff_member_required
def upload(request):

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


Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread limodou

2006/1/4, EricHsu <[EMAIL PROTECTED]>:
>
> the python way
>
> {% for page_number in range(pages) %}
>
> doesn't work either... :'(
>
>
May be you should use forloop.counter for that.

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


Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread limodou

2006/1/4, EricHsu <[EMAIL PROTECTED]>:
>
> Hi limodou, could you pls be more specific? Thanks!
>
>
I thought the pages is a list, but I was wrong, and I didn't find
there is a range filter in templates document, so I think either you
create a new range filter, or you create a list in view's code. May be
the best thing is to create a new ticket for this new filter.

Sorry for wrong reply.

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


Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread limodou
2006/1/4, EricHsu <[EMAIL PROTECTED]>:
>
> guys, I did it by hacking into django's list_detail.py
>
> just add a simply line here:
>
> $ svn diff list_detail.py
> Index: list_detail.py
> ===
> --- list_detail.py  (revision 1813)
> +++ list_detail.py  (working copy)
> @@ -58,6 +58,7 @@
>  'next': page + 1,
>  'previous': page - 1,
>  'pages': paginator.pages,
> +   'pages_list': range(1, paginator.pages + 1),
>  'hits' : paginator.hits,
>  }, context_processors)
>  else:
>
>
> then, I can access the pages_list (a real list:) from my template:
>
> {% if is_paginated %}
> 
> {% for page_number in pages_list %}
> {{ page_number }}
> {% endfor %}
> 
> {% endif %}
>
> Could I submit this line of code into django's source? hehe
>
>
I think create a range filter may be better. May be someone don't need
pages_list。But range is more generic.

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


Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-04 Thread limodou

2006/1/4, EricHsu <[EMAIL PROTECTED]>:
>
> Guys, I created the range0 (0-index) and range1 (1-index filter
>
> $ svn diff defaultfilters.py
> Index: defaultfilters.py
> ===
> --- defaultfilters.py   (revision 1813)
> +++ defaultfilters.py   (working copy)
> @@ -433,6 +433,14 @@
>  from pprint import pformat
>  return pformat(value)
>
> +def range0(value):
> +"A python style range() function, 0-index"
> +return range(value)
> +
> +def range1(value):
> +"A python style range() function, 1-index"
> +return range(1, value + 1)
> +
>  # Syntax: register.filter(name of filter, callback)
>  register.filter(add)
>  register.filter(addslashes)
> @@ -482,3 +490,5 @@
>  register.filter(wordcount)
>  register.filter(wordwrap)
>  register.filter(yesno)
> +register.filter(range0)
> +register.filter(range1)
>
>
> then use it like this:
>
> {% for page_number in pages|range1 %}
> {{ page_number }}
> {% endfor %}
>
>
Great! And you should make it a new ticket, hope this one can be
included in django.

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


Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-04 Thread limodou

2006/1/4, EricHsu <[EMAIL PROTECTED]>:
>
> hi all, I've submitted it as a ticket :)
>
> http://code.djangoproject.com/ticket/1162
>
>
Good! Just let us waiting...

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


Re: Images. Stylesheets. Javascripts. Where do I put 'em.

2006-01-04 Thread limodou

2006/1/4, iGL <[EMAIL PROTECTED]>:
>
> on windows, MEDIA_URL and MEDIA_ROOT, did not quit help; I haven't
> understood why...

MEDIA_URL is used for file or image upload.
>
> all I did then was to put:
>
> in urls something like
> r'^m/(?P.*)$', 'media', {'document_root':
> 'D:\\django\\testapp\\media\\'}),
>
> and in views
>
> from django.views.static import serve
>
> media = serve
>
> and in the base template:
>
>  href="http://localhost:8000/m/myst2.css"; />
>
> awfully hardcoded, though... :(
>
>
There are two state in django:

1. development
2. Apache(or some other web server)

Django has said that it doesn't serve static files(in static_files
document), so if you want to use built-in static files service, you
should setup in urls.py just like:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': STATIC_PATH}),

STATIC_PATH is absolute path. If you done that, you could use it in
links just like:



If you want to serve static files in Apache, you could see the
mod_python document, and just configure like that:

Alias /site_media d:/project/svn/limodou/django-stepbystep/newtest/media

SetHandler None


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


  1   2   3   >