Re: overriding models.delete()

2010-01-01 Thread Marc Aymerich
On Sat, Jan 2, 2010 at 6:28 AM, Marc Aymerich  wrote:

> I'm overriding save() and delete() methods of the class models. The
> override of the save() method works properly but unfortunately I'm in
> troubles trying to override models.delete method. For example, I try to do
> that in one of my dummy models:
>
> class test(models.model)
> name = models.CharField(max_length=20)
> value = models.IntegerField()
> active = models.BooleanField()
>
> def save(self, force_insert=False, force_update=False):
> if self.active:
> new = test_active(name=self.name, value=self.value)
> new.save()
> super(test, self).save(force_insert, force_update)
>
> def delete(self):
>  if self.active:
>   active=False
>
> class test_active(models.model)
> name = models.CharField(max_length=20)
> value = models.IntegerField()
>
> When I delete a test object, the object is deleted although I override the
> delete function :( What am I doing wrong?
>
> Thanks in advance!!
> Marc
>

I found the answer... http://code.djangoproject.com/ticket/11022

Django admin panel doesn't call delete() method :'(

--

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




overriding models.delete()

2010-01-01 Thread Marc Aymerich
I'm overriding save() and delete() methods of the class models. The override
of the save() method works properly but unfortunately I'm in troubles trying
to override models.delete method. For example, I try to do that in one of my
dummy models:

class test(models.model)
name = models.CharField(max_length=20)
value = models.IntegerField()
active = models.BooleanField()

def save(self, force_insert=False, force_update=False):
if self.active:
new = test_active(name=self.name, value=self.value)
new.save()
super(test, self).save(force_insert, force_update)

def delete(self):
 if self.active:
  active=False

class test_active(models.model)
name = models.CharField(max_length=20)
value = models.IntegerField()

When I delete a test object, the object is deleted although I override the
delete function :( What am I doing wrong?

Thanks in advance!!
Marc

--

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




Re: a request for some brain picking

2010-01-01 Thread aditya
Oh I see. I agree that learning how other people set up their
templates would be very interesting. I'll be interested to see where
this project goes.


On Jan 1, 6:27 pm, Will Dampier  wrote:
> I agree I'll be limiting things.  And I don't expect that you'd be
> able to download the templates from this website and plug it into your
> own without any modification what so ever.  The standardization comes
> from the limiting of what I actually put in the context-dictionary
> when I render the template.
>
> I hope this will become a resource for people to download templates
> that they can "tinker" into their own django programs.  I've noticed
> that everytime I start a django project I get the views, forms,
> models, etc. programmed easily but I stare at a blank editor screen
> trying to write the template.  If I had a place to go and find a
> "slick-looking" template to tinker with I'd be able to do things even
> faster.
>
> I'm hoping to make this into an ideal place for people to demonstrate
> the tricks they use in constructing their templates ... stuff like how
> they arrange the "blocks", which css items they use, whether they use
> lists or tables, how they implement 'nav-bars', etc.
>
> On Jan 1, 5:12 pm, aditya  wrote:
>
> > Will,
> > Django is much more flexible over template-based systems like
> > Wordpress or Tumblr. Wordpress standardizes a lot of things so generic
> > templates are easy to make and will work on just about any Wordpress
> > installation. It seems to me like to have templates in Django you'd
> > have to standardize things somehow...but that would result in loss of
> > flexibility.
>
> > Aditya
>
> > On Jan 1, 1:06 pm, Will Dampier  wrote:
>
> > > An open call,
>
> > > This is Will Dampier, I've been an avid python and django programmer for 
> > > the
> > > past two years or so.  I've worked on a few in-house django projects and
> > > I've been looking for a project to "give-back" to the community.  I've
> > > always worked on the "programming" side of projects and have only dabbled 
> > > on
> > > the "design" side.  Whenever I've started a new project I've scoured the
> > > internet for django templates that come complete with css, images, etc. 
> > > and
> > > always come up empty.
>
> > > So I was thinking of making a "meta"-django project.  I could make a site
> > > that allows designers to upload django-templates against a well defined 
> > > set
> > > of models, views, forms, etc.  Then users could switch between templates 
> > > and
> > > see how more "complex" examples function.  This would be useful for
> > > designers to advertise their skills and for newbies to get a richer set of
> > > functions.  Something akin to the CSS Zen Garden.
>
> > > I'm looking for a collaborator or two ... or even just a few people to 
> > > pick
> > > their brains about some of the details.  I have some code in a git-hub
> > > repositoryhttp://github.com/JudoWill/DjangoTemplateRepository/andI'vegot
> > > about a dozen google-wave invitations if people would like to try
> > > collaborating that way.  If you wouldn't mind either forwarding this to
> > > anyone you think would be interested or posting it on your blog.
>
> > > Thanks in advance,
> > > Will

--

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




Re: Just upgraded to 1.1, can't start development server, TypeError

2010-01-01 Thread davenaff
In my case, I had to remove mysql_replicated as our db backend.  We're
no longer using mysql_replicated so I haven't tried to find the source
of the incompatibility, but this was the source of this error message
for us.

On Nov 10 2009, 12:57 pm, Evgeny  wrote:
> I think I found a workaround:
> first completely delete previous django installation, then install
> 1.1.1
>
> the problem went away for me after this manipulation.
>
> On Nov 10, 12:39 pm, Evgeny  wrote:
>
> > Same problem here. Any ideas?
> > Thanks!
>
> > On Oct 14, 7:11 pm, eculver  wrote:
>
> > > Not so sure about that. Here are my installed apps:
>
> > > INSTALLED_APPS = (
> > >     'django.contrib.auth',
> > >     'django.contrib.contenttypes',
> > >     'django.contrib.sessions',
> > >     'django.contrib.sites',
> > >     'django.contrib.admin',
> > >     'myproject.api',
> > >     'myproject.pages',
> > >     'myproject.contact_form',
> > >     'myproject.albums',
> > >     'myproject.paypalcart',
> > >     'myproject.messaging',
> > > )
>
> > > None of them are being pulled from my python path? Am I missing
> > > something obvious?
>
> > > On Oct 14, 1:09 am, Lakshman Prasad  wrote:
>
> > > > Seems like, some of the apps that you have in settings.py 
> > > > INSTALLED_APPS are
> > > > there in the pythonpath for python2.5 and not for python2.6.
> > > > You will need to do a easy_install-2.6 (or a corresponding 
> > > > pip/distribute
> > > > equivalent) package_name
>
> > > > On Wed, Oct 14, 2009 at 11:48 AM, eculver  wrote:
>
> > > > > I just tried upgrade to django 1.1, ran ./manage.py runserver, but was
> > > > > promptly halted due to this exception:
>
> > > > > ...
>
> > > > > File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> > > > > site-packages/django/utils/translation/trans_real.py", line 180, in
> > > > > _fetch
> > > > >    app = import_module(appname)
> > > > >  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > > > > python2.6/site-packages/django/utils/importlib.py", line 35, in
> > > > > import_module
> > > > >    __import__(name)
> > > > >  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > > > > python2.6/site-packages/django/contrib/admin/__init__.py", line 1, in
> > > > > 
> > > > >    from django.contrib.admin.options import ModelAdmin, HORIZONTAL,
> > > > > VERTICAL
> > > > >  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > > > > python2.6/site-packages/django/contrib/admin/options.py", line 5, in
> > > > > 
> > > > >    from django.contrib.contenttypes.models import ContentType
> > > > >  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > > > > python2.6/site-packages/django/contrib/contenttypes/models.py", line
> > > > > 1, in 
> > > > >    from django.db import models
> > > > >  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> > > > > python2.6/site-packages/django/db/__init__.py", line 57, in 
> > > > >    'TIME_ZONE': settings.TIME_ZONE,
> > > > > TypeError: __init__() takes exactly 1 argument (2 given)
>
> > > > > Everything worked fine in 1.0.4 before the upgrade. Seems like it may
> > > > > be an obvious upgrade problem/oversight on my part. Any ideas?
>
> > > > --
> > > > Regards,
> > > > Lakshman
> > > > becomingguru.com
> > > > lakshmanprasad.com

--

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




Re: a request for some brain picking

2010-01-01 Thread Will Dampier
I agree I'll be limiting things.  And I don't expect that you'd be
able to download the templates from this website and plug it into your
own without any modification what so ever.  The standardization comes
from the limiting of what I actually put in the context-dictionary
when I render the template.

I hope this will become a resource for people to download templates
that they can "tinker" into their own django programs.  I've noticed
that everytime I start a django project I get the views, forms,
models, etc. programmed easily but I stare at a blank editor screen
trying to write the template.  If I had a place to go and find a
"slick-looking" template to tinker with I'd be able to do things even
faster.

I'm hoping to make this into an ideal place for people to demonstrate
the tricks they use in constructing their templates ... stuff like how
they arrange the "blocks", which css items they use, whether they use
lists or tables, how they implement 'nav-bars', etc.



On Jan 1, 5:12 pm, aditya  wrote:
> Will,
> Django is much more flexible over template-based systems like
> Wordpress or Tumblr. Wordpress standardizes a lot of things so generic
> templates are easy to make and will work on just about any Wordpress
> installation. It seems to me like to have templates in Django you'd
> have to standardize things somehow...but that would result in loss of
> flexibility.
>
> Aditya
>
> On Jan 1, 1:06 pm, Will Dampier  wrote:
>
> > An open call,
>
> > This is Will Dampier, I've been an avid python and django programmer for the
> > past two years or so.  I've worked on a few in-house django projects and
> > I've been looking for a project to "give-back" to the community.  I've
> > always worked on the "programming" side of projects and have only dabbled on
> > the "design" side.  Whenever I've started a new project I've scoured the
> > internet for django templates that come complete with css, images, etc. and
> > always come up empty.
>
> > So I was thinking of making a "meta"-django project.  I could make a site
> > that allows designers to upload django-templates against a well defined set
> > of models, views, forms, etc.  Then users could switch between templates and
> > see how more "complex" examples function.  This would be useful for
> > designers to advertise their skills and for newbies to get a richer set of
> > functions.  Something akin to the CSS Zen Garden.
>
> > I'm looking for a collaborator or two ... or even just a few people to pick
> > their brains about some of the details.  I have some code in a git-hub
> > repositoryhttp://github.com/JudoWill/DjangoTemplateRepository/andI've got
> > about a dozen google-wave invitations if people would like to try
> > collaborating that way.  If you wouldn't mind either forwarding this to
> > anyone you think would be interested or posting it on your blog.
>
> > Thanks in advance,
> > Will

--

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




A module for adding link suggestions to 404 pages

2010-01-01 Thread aditya
While redoing my website, I came up with a simple module that adds a
url suggestion if a user encounters a 404 page. For example, following
this link:
http://www.wefoundland.com/rresume

will lead you to a 404 page that points you to the right place. I'm
currently starting to rewrite this module so I can make it more widely
available. I'd like to have another pair of eyes on it (or another 2
pairs) to improve the speed and the module interface. Anyone
interested in contributing?

I've got a project page set up here with more details:
http://www.wefoundland.com/project/py404/



Aditya

--

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




Re: a request for some brain picking

2010-01-01 Thread aditya
Will,
Django is much more flexible over template-based systems like
Wordpress or Tumblr. Wordpress standardizes a lot of things so generic
templates are easy to make and will work on just about any Wordpress
installation. It seems to me like to have templates in Django you'd
have to standardize things somehow...but that would result in loss of
flexibility.

Aditya

On Jan 1, 1:06 pm, Will Dampier  wrote:
> An open call,
>
> This is Will Dampier, I've been an avid python and django programmer for the
> past two years or so.  I've worked on a few in-house django projects and
> I've been looking for a project to "give-back" to the community.  I've
> always worked on the "programming" side of projects and have only dabbled on
> the "design" side.  Whenever I've started a new project I've scoured the
> internet for django templates that come complete with css, images, etc. and
> always come up empty.
>
> So I was thinking of making a "meta"-django project.  I could make a site
> that allows designers to upload django-templates against a well defined set
> of models, views, forms, etc.  Then users could switch between templates and
> see how more "complex" examples function.  This would be useful for
> designers to advertise their skills and for newbies to get a richer set of
> functions.  Something akin to the CSS Zen Garden.
>
> I'm looking for a collaborator or two ... or even just a few people to pick
> their brains about some of the details.  I have some code in a git-hub
> repositoryhttp://github.com/JudoWill/DjangoTemplateRepository/and I've got
> about a dozen google-wave invitations if people would like to try
> collaborating that way.  If you wouldn't mind either forwarding this to
> anyone you think would be interested or posting it on your blog.
>
> Thanks in advance,
> Will

--

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




Re: User Sessions and Application Instances

2010-01-01 Thread dannyr

You can create a 'home' page (e.g. www.mysite.com/home).

>From there, you check is the user is authenticated
(request.user.is_authenticated).

If the user is, then display only projects related to them (e.g.
projects = Project.objects.filter(user=request.user). Make sure the
user is a foreign key in the Project table.

If the user is not authenticated, redirect them to the login page. You
can use the @login_required decorator. (see more at
http://docs.djangoproject.com/en/dev/topics/auth/)

On Jan 1, 8:14 am, Riku  wrote:
> I have created an application which works with users using the Django
> authentication system. Users can register and login.
>
> Now I'm unsure how I can make my application into a normal web
> application so that each user gets his own 'instance' of the
> application. I have projects in the application and each user should
> of course only see his own projects when logged in. Now every user can
> see all the projects of all users.
>
> How should this normally be accomplished?
> Should I send the user specific projects from the View to the
> template?
>
> Thanks for the help!

--

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




a request for some brain picking

2010-01-01 Thread Will Dampier
An open call,


This is Will Dampier, I've been an avid python and django programmer for the
past two years or so.  I've worked on a few in-house django projects and
I've been looking for a project to "give-back" to the community.  I've
always worked on the "programming" side of projects and have only dabbled on
the "design" side.  Whenever I've started a new project I've scoured the
internet for django templates that come complete with css, images, etc. and
always come up empty.

So I was thinking of making a "meta"-django project.  I could make a site
that allows designers to upload django-templates against a well defined set
of models, views, forms, etc.  Then users could switch between templates and
see how more "complex" examples function.  This would be useful for
designers to advertise their skills and for newbies to get a richer set of
functions.  Something akin to the CSS Zen Garden.

I'm looking for a collaborator or two ... or even just a few people to pick
their brains about some of the details.  I have some code in a git-hub
repository http://github.com/JudoWill/DjangoTemplateRepository/ and I've got
about a dozen google-wave invitations if people would like to try
collaborating that way.  If you wouldn't mind either forwarding this to
anyone you think would be interested or posting it on your blog.

Thanks in advance,
Will

--

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




Re: how to put html in __unicode__() ?

2010-01-01 Thread ev
I found the way - allow_tags=True !

#models.py
class Structure(models.Model):
...
def __unicode__(self):
return self.title

def titleWithOffset(self):
deep=Structure.getDeep(self)
result=deep*4*'' + self.title
return result
titleWithOffset.allow_tags=True

#admin.py
class StructureAdmin(admin.ModelAdmin):
list_display=('titleWithOffset',)
admin.site.register(Structure, StructureAdmin)

On Jan 1, 7:50 pm, Xia Kai(夏恺)  wrote:
> Hi,
>
> Strange question you have there, why would you like to put html code in
> model's __unicode__ method at all?
>
> I personally would only construct the __unicode__ method to display a model
> instance's information, which is meant to be shown on the commandline. As to
> html code, that is in the realm of Template, which is way too far from the
> Model(usually we have View in between).
>
> As html code would only make sense when it is displayed on a webpage, so
> maybe you could try some filter(safe) to allow your html code to be passed
> to the html without being transformed.
> 
> Xia Kai(夏恺)
> xia...@gmail.comhttp://blog.xiaket.org
>
> --
> From: "ev" 
> Sent: Saturday, January 02, 2010 12:35 AM
> To: "Django users" 
> Subject: how to put html in __unicode__() ?
>
>
>
> > I tryed to do:
>
> > class Structure(models.Model):
> > 
>
> > def __unicode__(self):
> > deep = Structure.getDeep(self)
> > return deep * "" + self.title
>
> > def getDeep(self):
> > ...
>
> > The result was:
> > Level 1
> > Level 2
> > Level 3
> > etc
>
> > So, how to put html entities in __unicode__() ?

--

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




Re: how to put html in __unicode__() ?

2010-01-01 Thread ev
I just wanted to change standard admin page view with model elements.
Now I understand, that I should find another way to achieve my goal.

On Jan 1, 7:50 pm, Xia Kai(夏恺)  wrote:
> Hi,
>
> Strange question you have there, why would you like to put html code in
> model's __unicode__ method at all?
>
> I personally would only construct the __unicode__ method to display a model
> instance's information, which is meant to be shown on the commandline. As to
> html code, that is in the realm of Template, which is way too far from the
> Model(usually we have View in between).
>
> As html code would only make sense when it is displayed on a webpage, so
> maybe you could try some filter(safe) to allow your html code to be passed
> to the html without being transformed.
> 
> Xia Kai(夏恺)
> xia...@gmail.comhttp://blog.xiaket.org
>
> --
> From: "ev" 
> Sent: Saturday, January 02, 2010 12:35 AM
> To: "Django users" 
> Subject: how to put html in __unicode__() ?
>
>
>
> > I tryed to do:
>
> > class Structure(models.Model):
> > 
>
> > def __unicode__(self):
> > deep = Structure.getDeep(self)
> > return deep * "" + self.title
>
> > def getDeep(self):
> > ...
>
> > The result was:
> > Level 1
> > Level 2
> > Level 3
> > etc
>
> > So, how to put html entities in __unicode__() ?

--

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




Re: Problems with "initial" parameter in form handling

2010-01-01 Thread Steven Arnold
Hi Daniel,

On Jan 1, 2010, at 7:31 AM, Daniel Roseman wrote:

>  er, you're not using Django to create the form HTML here. How are
> you expecting the values to be inserted?

I didn't really know.  I was following an example in a text that wasn't as 
clear as you are.  I figured it was magic or something.  However, your pointer 
worked perfectly; thanks!

steven

--

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




Re: how to put html in __unicode__() ?

2010-01-01 Thread 夏恺
Hi,

Strange question you have there, why would you like to put html code in 
model's __unicode__ method at all?

I personally would only construct the __unicode__ method to display a model 
instance's information, which is meant to be shown on the commandline. As to 
html code, that is in the realm of Template, which is way too far from the 
Model(usually we have View in between).

As html code would only make sense when it is displayed on a webpage, so 
maybe you could try some filter(safe) to allow your html code to be passed 
to the html without being transformed.

Xia Kai(夏恺)
xia...@gmail.com
http://blog.xiaket.org

--
From: "ev" 
Sent: Saturday, January 02, 2010 12:35 AM
To: "Django users" 
Subject: how to put html in __unicode__() ?

> I tryed to do:
>
> class Structure(models.Model):
> 
>
> def __unicode__(self):
> deep = Structure.getDeep(self)
> return deep * "" + self.title
>
> def getDeep(self):
> ...
>
> The result was:
> Level 1
> Level 2
> Level 3
> etc
>
> So, how to put html entities in __unicode__() ? 

--

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




Re: how to put html in __unicode__() ?

2010-01-01 Thread Daniel Roseman
On Jan 1, 4:35 pm, ev  wrote:
> I tryed to do:
>
> class Structure(models.Model):
>         
>
>         def __unicode__(self):
>                 deep = Structure.getDeep(self)
>                 return deep * "" + self.title
>
>         def getDeep(self):
>                 ...
>
> The result was:
> Level 1
> Level 2
> Level 3
> etc
>
> So, how to put html entities in __unicode__() ?

Autoescaping documentation: 
http://docs.djangoproject.com/en/dev/topics/templates/#id2
--
DR.

--

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




Re: ModelForm using ModelForm

2010-01-01 Thread Daniel Roseman
On Jan 1, 4:37 pm, Frédéric Burlet  wrote:
> Hi,
>
> I'm new in the python world and therefore in django.
>
> I'm using django 1.1.1.
>
> I started to write a small application and I have a question related to
> ModelForms.
>
> I defined two model objects:
>
> class Person(models.Model):
>         first_name = ...
>         last_name = ...
>         address = models.ForeignKey(Address)
>         ...
>
> class Address(models.Model):
>         street = ...
>         number = ...
>         ...
>
> I would like to know whether it is possible to write something like this with
> forms.ModelForm.
>
> class AddressForm(forms.ModelForm):
>         class Meta:
>                 model = Address
>
> class PersonForm(forms.ModelForm):
>         address = AddressForm
>
>         class Meta:
>                 model = Person
>
> I tested it but it doesn't seem to work. So I would like to know if we can do
> this or if I missed something to get it working.
>
> I didn't seen anything related to this in the documentation (or maybe I missed
> it).
>
> Thanks for your help.
>
> Fred.

Inline formsets: 
http://docs.djangoproject.com/en/1.1/topics/forms/modelforms/#inline-formsets
--
DR.

--

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




ModelForm using ModelForm

2010-01-01 Thread Frédéric Burlet

Hi,

I'm new in the python world and therefore in django.

I'm using django 1.1.1.

I started to write a small application and I have a question related to 
ModelForms.

I defined two model objects:

class Person(models.Model):
first_name = ...
last_name = ...
address = models.ForeignKey(Address)
...

class Address(models.Model):
street = ...
number = ...
...

I would like to know whether it is possible to write something like this with 
forms.ModelForm.

class AddressForm(forms.ModelForm):
class Meta:
model = Address

class PersonForm(forms.ModelForm):
address = AddressForm

class Meta:
model = Person

I tested it but it doesn't seem to work. So I would like to know if we can do 
this or if I missed something to get it working.

I didn't seen anything related to this in the documentation (or maybe I missed 
it).

Thanks for your help.

Fred.

--

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




how to put html in __unicode__() ?

2010-01-01 Thread ev
I tryed to do:

class Structure(models.Model):


def __unicode__(self):
deep = Structure.getDeep(self)
return deep * "" + self.title

def getDeep(self):
...

The result was:
Level 1
Level 2
Level 3
etc

So, how to put html entities in __unicode__() ?

--

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




User Sessions and Application Instances

2010-01-01 Thread Riku
I have created an application which works with users using the Django
authentication system. Users can register and login.

Now I'm unsure how I can make my application into a normal web
application so that each user gets his own 'instance' of the
application. I have projects in the application and each user should
of course only see his own projects when logged in. Now every user can
see all the projects of all users.

How should this normally be accomplished?
Should I send the user specific projects from the View to the
template?

Thanks for the help!

--

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




Re: obtaining sessionId(s) of logged in user by username

2010-01-01 Thread Subramanyam
Hi

Found a pointer which I feel is more relevant to my question
http://stackoverflow.com/questions/235950/how-to-lookup-django-session-for-a-particular-user

Will update on the solution after I get/develop one :)

Regards
Subramanyam


On Thu, Dec 31, 2009 at 9:37 AM, Subramanyam  wrote:

> Hi
>
> what is the most efficient way to get the sessionId(s) of a user by
> the username  (where in the same user can  log-in on mulitple
> systems)  , btw the I am using sessionID as the key for my cached
> objects
>
> Is there any middleware that I can use
>
> Thanks
> Subramanyam

--

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




Re: Problems with "initial" parameter in form handling

2010-01-01 Thread Daniel Roseman
On Jan 1, 7:00 am, Steven Arnold  wrote:
> Hi, my problem is that the "initial" parameter in forms.Form seems to
> have no effect.  I set the "subject" value in this code:
>
>         form = ContactForm(
>             initial={'subject': 'I love your site!'}
>         )
>
> ...yet this initialization string never makes it to the HTML as the
> default value for the "subject" input field.  My question is, why
> not?  What am I doing wrong?
>

>
>     
>         Subject: 
>         Your email (optional):  p>
>         Message:  textarea>
>         
>     

 er, you're not using Django to create the form HTML here. How are
you expecting the values to be inserted?

You need to use the template variables:
Subject: {{ form.subject }}
etc.

BTW it's good practice to use HTML label tags too: Subject - these help with accessibility and
styling.
--
DR.

--

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




Re: No such table:django_sesion error when using django with lighttpd + mod_fastcgi

2010-01-01 Thread sangho
yes, i`m sure
because if i run developserver , it's working

On 1월1일, 오후7시18분, rebus_  wrote:
> 2010/1/1 sangho :
>
>
>
>
>
> > hello, i`m korean, and english is the starter, so please understanding
>
> > i want access to admin page, if i run with developserver, it's working
> > but if i run with lighttpd + mod_fastcgi + manage.py runfcgi server,
> > it's not working
> > i can access tohttp://222.122.31.234:81, and it's working when using
> > lighttpd,
> > buthttp://222.122.31.234:81/adminpage is not working
>
> > how can i solve this problem?
>
> > Lighttpd Error log is here:
> >http://dpaste.com/139809/
>
> > Django settings.py is here:
> >http://dpaste.com/139810/
>
> > Django urls.py is here:
> >http://dpaste.com/139811/
>
> > Django panel(app name) models.py is here:
> >http://dpaste.com/139812/
>
> >http://222.122.31.234
> >http://222.122.31.234/admin
>
> > both url is work on lighttpd with django, not develop server
> > please help!
>
> > --
>
> Are you sure you ran pythom manage.py syncdb?
> Or set up database any other way?

--

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




Re: No such table:django_sesion error when using django with lighttpd + mod_fastcgi

2010-01-01 Thread rebus_
2010/1/1 sangho :
> hello, i`m korean, and english is the starter, so please understanding
>
> i want access to admin page, if i run with developserver, it's working
> but if i run with lighttpd + mod_fastcgi + manage.py runfcgi server,
> it's not working
> i can access to http://222.122.31.234:81, and it's working when using
> lighttpd,
> but http://222.122.31.234:81/admin page is not working
>
> how can i solve this problem?
>
>
> Lighttpd Error log is here:
> http://dpaste.com/139809/
>
> Django settings.py is here:
> http://dpaste.com/139810/
>
> Django urls.py is here:
> http://dpaste.com/139811/
>
> Django panel(app name) models.py is here:
> http://dpaste.com/139812/
>
>
> http://222.122.31.234
> http://222.122.31.234/admin
>
> both url is work on lighttpd with django, not develop server
> please help!
>
> --
>

Are you sure you ran pythom manage.py syncdb?
Or set up database any other way?

--

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




No such table:django_sesion error when using django with lighttpd + mod_fastcgi

2010-01-01 Thread sangho
hello, i`m korean, and english is the starter, so please understanding

i want access to admin page, if i run with developserver, it's working
but if i run with lighttpd + mod_fastcgi + manage.py runfcgi server,
it's not working
i can access to http://222.122.31.234:81, and it's working when using
lighttpd,
but http://222.122.31.234:81/admin page is not working

how can i solve this problem?


Lighttpd Error log is here:
http://dpaste.com/139809/

Django settings.py is here:
http://dpaste.com/139810/

Django urls.py is here:
http://dpaste.com/139811/

Django panel(app name) models.py is here:
http://dpaste.com/139812/


http://222.122.31.234
http://222.122.31.234/admin

both url is work on lighttpd with django, not develop server
please help!

--

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




Re: multidb workaround

2010-01-01 Thread Russell Keith-Magee
On Fri, Jan 1, 2010 at 5:26 AM, Continuation  wrote:
> From reading several posts here, it looks like it's not a good idea to
> try to have ForeignKey pointing from 1 DB to another DB.
>
> The problem for me is that pretty much every single model of mine has
> a link to User. And I suspect that's a very common case for most
> people.
>
> If I put in FK to User in my models, I wouldn't be able to have
> multidb.
>
> One workaround I can think of is to have an IntegerField pointing to
> User.id instead of a FK to User.
>
> Is that a good alternative? Or is it going to cause more problems that
> it's worth?

It is *an* alternative. On the plus side, it will let you store the PK
value of the remote object. On the negative side, it won't
automatically resolve related objects in the same way that a foreign
key will, and it won't display a helpful widget in forms.

There is at least one active thread discussing approaches to this
problem; I suggest you read up on the suggestions contained in that
thread.

Yours,
Russ Magee %-)

--

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




"JSON Template" language

2010-01-01 Thread mtnpaul
I've done a bit of JSON work on previous projects, but my new project
seems likely to use it in a lot of places. Has anyone used the "JSON
Template" language (http://json-template.googlecode.com/svn/trunk/doc/
Introducing-JSON-Template.html) ?  What are your thoughts on it?  Any
unit testing issues?

Thanks,

Paul

--

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




Re: sorl.thumbnail on apache2

2010-01-01 Thread Sam Lai
Are you missing a path in PythonPath, in your apache's conf file? Not
sure if the python path is returned in Django's error page; if not,
create a new view that returns the python path *as seen when launched
from apache* and see if it is correct there.

2009/12/30 Osiaq :
> INDEX.HTML:
> error message: 'thumbnail' is not a valid tag library: Could not load
> template library from django.templatetags.thumbnail, cannot import
> name defaults
>
> 1       {% extends 'website/base_website.html' %}
> 2       {% load thumbnail %} <--PROBLEM HERE
>
> on development server using 'python manage.py runserver' is working
> perfect
> the same machine using apache2 + mod-python fails
>
> thumbnail location: /home/osiaq/djangoprojects/myproject/sorl/
> thumbnail
> python path: ['/home/osiaq/djangoprojects/myproject/sorl/', '/home/
> osiaq/djangoprojects/', '/home/osiaq/djangoprojects/
> myproject',...]
>
> PYTHON:
import PIL  <--OK, no errors
import sorl  <--OK, no errors
>
> SETTINGS.PY:
> INSTALLED_APPS = (
>    'sorl.thumbnail',   (using myproject.sorl.thumbnail also doesnt
> work)
>    ...)
>
> Help, please.
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

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