The method all() in overrided models.Manager doesn't works as expected

2012-12-30 Thread Shuge Lee
I'm writing a simple CMS, it stores page file data on local file system instead of SQL server. I do overrides the model Page's Manager, but it not works as expected, problems - PageManager.all(it calls PageQuerySet?) doesn't works - I can create Page object in Admin, but can't view it

ManyToManyField('self') doesn't works as expect

2010-12-14 Thread Shuge Lee
I created a model to save map, a map is contains many room(RoomConfig). # model class RoomConfig(models.Model): room_name = models.CharField(max_length = 64) room_to_room = models.ManyToManyField('self', through = 'RoomToRoomConfig') class RoomToRoom(models.Model): DIRECTION_CHOICES

Re: read static file error

2009-10-14 Thread Shuge Lee
;bayua...@gmail.com> wrote: > Hi Shuge Lee, > > On 10/9/09, Shuge Lee <shuge@gmail.com> wrote: > > > > > > > > > Environment: ubuntu 9.04 + django 1.1 + apache 2.* > > > I did followinghttps://wiki.ubuntu.com/Django > > > however, I g

read static file error

2009-10-09 Thread Shuge Lee
Environment: ubuntu 9.04 + django 1.1 + apache 2.* I did following https://wiki.ubuntu.com/Django however, I got this error message http://dpaste.com/105064/ My configure file: cat /etc/apache2/sites-available/online http://dpaste.com/105065/ The file and path structure of my django project:

get current URL

2009-09-13 Thread Shuge Lee
How to get current URL ? --~--~-~--~~~---~--~~ 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

overwrite and delete uploaded file

2009-08-22 Thread Shuge Lee
How to make it with nice way? I do override with stupid way: http://dpaste.com/83943/ Anyone have better idea? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

login with email backend result in URL rules doesn't work

2009-08-07 Thread Shuge Lee
For user could login with email or username, I did as what this page http://www.djangosnippets.org/snippets/74/ said # in settings.py # ... AUTHENTICATION_BACKENDS = ( 'online.accounts.backends.EmailOrUsernameModelBackend', 'django.contrib.auth.backends.ModelBackend' ) # ... l...@lab

overwrite User model

2009-08-05 Thread Shuge Lee
django.contrib.auth.models.User I don't like models.User, but I like Admin view, and I will keep admin view in my application. How to overwirte models.User Make it just look like following class ShugeUser(User) username = EmailField(uniqute=True, verbose_name='EMail as your username',

Re: how to modified filefiled after created it

2009-08-03 Thread Shuge Lee
I see. Thanks. On Aug 3, 1:54 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Aug 3, 1:29 pm, Shuge Lee <shuge@gmail.com> wrote: > > > NO > > > just image add new seed in admin > > > upload a file with status "UNAPPROVE" >

Re: how to modified filefiled after created it

2009-08-03 Thread Shuge Lee
' > > def __setattr__(self, k, v): > if k == 'status': > self.name = v.lower() > super(Foo, self).__setattr__(k, v) > > f = Foo() > f.status = 'APPROVE' > print f.status # will print 'APPROVE' > print f.name # will print 'approve

Re: how to modified filefiled after created it

2009-08-03 Thread Shuge Lee
I think Django could add new API for FileField such as FileField.change_path(new_path) On Aug 3, 7:28 am, Shuge Lee <shuge@gmail.com> wrote: > Please take a lookhttp://dpaste.com/74606/ > > or here > > # in models.py > > UNAPPROVE = 0 > ACCEPT = 1 &

how to modified filefiled after created it

2009-08-03 Thread Shuge Lee
Please take a look http://dpaste.com/74606/ or here # in models.py UNAPPROVE = 0 ACCEPT = 1 REJECT = 2 unapprove_path = os.path.join(MEDIA_ROOT, 'unapprove') accept_path = os.path.join(MEDIA_ROOT, 'accept') reject_path = os.path.join(MEDIA_ROOT, 'reject') def get_filepath(instance,

howto change FileField value in model.save() ?

2009-07-31 Thread Shuge Lee
Take a look here http://dpaste.com/73953/ or following # in models.py class Seed(models.Model): name = models.CharField(max_length=128) UPLOAD_ROOT = 'uploads' files = models.FileField(upload_to=UPLOAD_ROOT, blank=True, null=True) source = models.CharField(max_length=256,

Re: howto get value of model instance in form.py

2009-07-30 Thread Shuge Lee
://groups.google.com/group/django-users/browse_thread/thread/7b42604519c3b27e/2e01f339cdf0c3cc?lnk=gst=get+model+value+in+form#2e01f339cdf0c3cc On Jul 30, 10:06 pm, Shuge Lee <shuge@gmail.com> wrote: > http://dpaste.com/73301/ --~--~-~--~~~---~--~~ You

howto get value of model instance in form.py

2009-07-30 Thread Shuge Lee
http://dpaste.com/73301/ --~--~-~--~~~---~--~~ 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

change field value before valid of admin

2009-07-01 Thread Shuge Lee
# cat models.py class Seed(models.Model): name = models.CharField(max_length=128, unique=True) category = models.ForeignKey(Category) source = models.CharField(max_length=256) now, I want source = category + '/' + name if user doesn't fill source field in admin view How to do that

I couldn't re-write save() of mymodels in admin.py instead of models.py ?

2009-06-26 Thread Shuge Lee
models.py http://gpaste.com/p/3747b admin.py http://gpaste.com/p/3d432 --~--~-~--~~~---~--~~ 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

Re: How to doing something after change db record with admin view?

2009-06-25 Thread Shuge Lee
I want to redirect with HttpResponseRedirect or stop and display a error message in admin view, when user change some record in admin view while it not means some conditions. I try to rewrite save() in models.py class Seed(models.Model): def save(self): if

Re: Why why why not write a search module for Django user?

2009-06-19 Thread Shuge Lee
I got it On Jun 18, 5:36 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Jun 18, 9:39 am, Shuge Lee <shuge@gmail.com> wrote: > > > Search is used in most of CMS, > > for avoid re-invent the wheel, please provider a search engine module. > > h

Why why why not write a search module for Django user?

2009-06-18 Thread Shuge Lee
Search is used in most of CMS, for avoid re-invent the wheel, please provider a search engine module. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Does Django have to run with Python-2.5 ?

2009-06-17 Thread Shuge Lee
Does Django have to run with Python-2.5 ? l...@lab ~/online $ python2.6 manage.py runserver Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management l...@lab ~/online $

Does Django have to run with Python-2.5 ?

2009-06-17 Thread Shuge Lee
Does Django have to run with Python-2.5 ? l...@lab ~/online $ python2.6 manage.py runserver Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management l...@lab ~/online $

How to doing something after change record of DB with admin view?

2009-06-11 Thread Shuge Lee
For some reason, I want to create a static file after user change record of DB with admin view, I need to use signal http://docs.djangoproject.com/en/dev/topics/signals/#topics-signals , or other stuff? --~--~-~--~~~---~--~~ You received this message because you

How to doing something after change db record with admin view?

2009-06-11 Thread Shuge Lee
How to doing something after change record of DB with admin view? For some reason, I want to create a static file after user change record of DB with admin view, I need to use signal http://docs.djangoproject.com/en/dev/topics/signals/#topics-signals , or other stuff?

Re: a error occurs while use comment framework

2009-02-14 Thread Shuge Lee
thanks On Dec 30 2008, 1:26 pm, "James Bennett" <ubernost...@gmail.com> wrote: > On Mon, Dec 29, 2008 at 3:38 AM, Shuge Lee <shuge@gmail.com> wrote: > > return render_to_response( 'a.html', {'obj': obj, 'category': > > Category} ) >

Re: a error occurs while use comment framework

2008-12-29 Thread Shuge Lee
Is this a bug ? On Dec 29, 9:30 pm, Shuge Lee <shuge@gmail.com> wrote: > I sure I have wrote '(r'^comments/', include > ('django.contrib.comments.urls')),' into /path/to/project/url.py > > On Dec 29, 7:47 pm, Grigory Fateyev <g...@anastasia.ru> wrote: > > >

Re: a error occurs while use comment framework

2008-12-29 Thread Shuge Lee
I sure I have wrote '(r'^comments/', include ('django.contrib.comments.urls')),' into /path/to/project/url.py On Dec 29, 7:47 pm, Grigory Fateyev <g...@anastasia.ru> wrote: > Hello Shuge Lee! > On Mon, 29 Dec 2008 01:38:26 -0800 (PST) you wrote: > > &g

a error occurs while use comment framework

2008-12-29 Thread Shuge Lee
setting.py ... INSTALLED_APPS = ( ... 'django.contrib.comments', ... python manage.py syncdb ... view.py from shuge.fap_soft.models import * #Category return render_to_response( 'a.html', {'obj': obj, 'category': Category} ) a.html ... {% load comments %} {% render_comment_form for

cross table querying II

2008-12-26 Thread Shuge Lee
class tb1( models.Model ): name = models.CharField(max_length=32) tb2 = models.ForeignKey(Category) class tb2( models.Model ): name = models.CharField(max_length=64) Do I have to use Manager when do cross-table querying such SELECT tb1.name, tb2.name as tb2_name FROM tb1

Re: cross table querying

2008-12-26 Thread Shuge Lee
thanks On Dec 21, 11:44 am, Malcolm Tredinnick wrote: > On Fri, 2008-12-19 at 19:58 -0800,Shuge Leewrote: > > [...] > > It's not really necessary to post all that SQL and Python, since you're > only really asking about a couple of the models. If you can reduce your >

Re: Is there a bug in http://docs.djangoproject.com/en/dev/topics/db/models/ ?

2008-12-22 Thread Shuge Lee
I got another idea for it now. Thank for your reminder. :-) On Dec 15, 2:00 pm, Malcolm Tredinnick wrote: > On Sun, 2008-12-14 at 21:32 -0800, lee wrote: > > [...] > > > It seems that official docs hasn't give a reference to howto define > > 'ON DELETE CASCADE ON

cross table querying

2008-12-19 Thread Shuge Lee
# mysql.sql CREATE TABLE IF NOT EXISTS `os` ( `id` int(11) NOT NULL auto_increment, `name` varchar(64) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; INSERT INTO `os` (`id`, `name`) VALUES (1, 'All'), (2, 'Windows'), (3,