admin caching querysets

2008-12-09 Thread lingrlongr

I have a function called get_urls that returns a list of absolute_urls
for various models in the same project.  This function is used for
another model in a way so that when a particular model appears on the
site, I can choose which part of the site this model links to.

# utils.py
def get_urls():
  urls = []
  for flatpage in FlatPage.objects.order_by('title')
urls.append(flatpage.url, '%s: %s' % ('Flatpage',
flatpage.title),))
  return urls

There are more objects, this is just a sample with the well-known
FlatPage model.

The particular model I use this with looks like this:

# models.py
from utils import get_urls
class BannerImage(models.Model):
  image = models.ImageField(etc)
  url = models.CharField(max_length=100, choices=get_urls())
  etc...

So it turned out that the admin seemed to be caching the choices.  So,
if I added a new flatpage, it would not be listed there until I
restarted the webserver.  So instead of referring to
Flatpage.objects.etc... directly in get_urls, I made a function that
returns the queryset instead:

# utils.py
def get_flatpages():
  return FlatPage.objects.order_by('title')

Problem still seemed to exist.  I tried making a custom ModelForm in
admin.py for this BannerImage model:

# admin.py
from utils import get_urls
class BannerImageForm(forms.ModelForm):
  url = forms.ChoiceField(choices=get_urls())
  class Meta:
model = BannerImage

  ...etc...

I tested with the Python shell to see if the get_urls function returns
an updated list after a new object and it does.  Its just the admin
that seems to have the problem.  Is there any way I can get this to
work?

Keith
--~--~-~--~~~---~--~~
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: admin caching querysets

2008-12-09 Thread lingrlongr

Thanks Karen.

I removed the custom form from admin.py and added a constructor to the
model:

def __init__(self, *args, **kwargs):
  super(BannerImage, self).__init__(*args, **kwargs)
  self._meta.get_field('url')._choices = get_urls()

It seems to work now.

Keith

On Dec 9, 2:52 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 1:58 PM, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > I have a function called get_urls that returns a list of absolute_urls
> > for various models in the same project.  This function is used for
> > another model in a way so that when a particular model appears on the
> > site, I can choose which part of the site this model links to.
>
> > # utils.py
> > def get_urls():
> >  urls = []
> >  for flatpage in FlatPage.objects.order_by('title')
> >    urls.append(flatpage.url, '%s: %s' % ('Flatpage',
> > flatpage.title),))
> >  return urls
>
> > There are more objects, this is just a sample with the well-known
> > FlatPage model.
>
> > The particular model I use this with looks like this:
>
> > # models.py
> > from utils import get_urls
> > class BannerImage(models.Model):
> >  image = models.ImageField(etc)
> >  url = models.CharField(max_length=100, choices=get_urls())
> >  etc...
>
> Here you have put your call to get_urls() in code that is executed only when
> the class is defined, not each time the class is instantiated.  You probably
> want to read the last paragraph of the description of choices here:
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#choices
>
> > So it turned out that the admin seemed to be caching the choices.  So,
> > if I added a new flatpage, it would not be listed there until I
> > restarted the webserver.  So instead of referring to
> > Flatpage.objects.etc... directly in get_urls, I made a function that
> > returns the queryset instead:
>
> Admin was not caching anything, it is Python that only executes the code
> once given where it had been placed.
>
> > # utils.py
> > def get_flatpages():
> >  return FlatPage.objects.order_by('title')
>
> > Problem still seemed to exist.  I tried making a custom ModelForm in
> > admin.py for this BannerImage model:
>
> > # admin.py
> > from utils import get_urls
> > class BannerImageForm(forms.ModelForm):
> >  url = forms.ChoiceField(choices=get_urls())
> >  class Meta:
> >    model = BannerImage
>
> Here you have still put the determination of choices into code that is only
> executed when the class (this time the form class) is defined.  You could
> fix it for the form case by moving the setting of choices into an __init__
> routine for the form.
>
> Karen
--~--~-~--~~~---~--~~
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: database relationships

2008-08-21 Thread lingrlongr

The only part you have that is redundant is the "artist" in your
"Track" class.  You can find out the artist because a track is related
to an album, which in turn, is related to an artist.

Some of the code you'd maybe see in a view would be:

# views.py
from django.shortcuts import get_object_or_404
from models import Album, Track

def album(request, slug):
  album = get_object_or_404(Album, slug=slug)
  artist = album.artist
  tracks = album.track_set.all()
  ...etc... return a response...

def track(request, slug):
  track = get_object_or_404(Track, slug=slug)
  album = track.album
  artist = album.artist
  ..etc..

HTH

Keith

On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
> I'm trying to set up my first Django application and I'm trying to
> figure out the database relationships.  I want to be able to list
> albums, with their corresponding tracks and album artwork.  Right now
> I only have foreign keys defined in the Track class and on the
> AlbumArt class pointing to the Album class.  I'm doing this so I can
> keep a record of which track or which album art goes to which album.
> However I also would like to add a ManyToManyField on my Album class
> so I can pull the album data in my view.  Defining this is both places
> seems redundant to me, but I'm not sure how else I can accomplish
> this.  What would be best practice in this situation and how should I
> proceed?
>
> class Album(models.Model):
>     title          = models.CharField(max_length=255)
>     prefix         = models.CharField(max_length=20, blank=True)
>     subtitle       = models.CharField(blank=True, max_length=255)
>     slug           = models.SlugField(unique=True)
>     artist         = models.ForeignKey('Artist')
>
> class AlbumArt(models.Model):
>     title          = models.CharField(max_length=200)
>     slug           = models.SlugField()
>     album          = models.ForeignKey('Album')
>
> class Track(models.Model):
>     title         = models.CharField(max_length=200)
>     slug          = models.SlugField(unique=True)
>     album         = models.ForeignKey('Album')
>     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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: database relationships

2008-08-21 Thread lingrlongr

One more note.  You wouldn't NEED to explicitly grab all those vars,
as you can get them in a template too.  I just wanted to show you the
relation.
If you sent the track to the template, you can get the artist by
using:

{{ track.album.artist }}

Keith

On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> The only part you have that is redundant is the "artist" in your
> "Track" class.  You can find out the artist because a track is related
> to an album, which in turn, is related to an artist.
>
> Some of the code you'd maybe see in a view would be:
>
> # views.py
> from django.shortcuts import get_object_or_404
> from models import Album, Track
>
> def album(request, slug):
>   album = get_object_or_404(Album, slug=slug)
>   artist = album.artist
>   tracks = album.track_set.all()
>   ...etc... return a response...
>
> def track(request, slug):
>   track = get_object_or_404(Track, slug=slug)
>   album = track.album
>   artist = album.artist
>   ..etc..
>
> HTH
>
> Keith
>
> On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to set up my first Django application and I'm trying to
> > figure out the database relationships.  I want to be able to list
> > albums, with their corresponding tracks and album artwork.  Right now
> > I only have foreign keys defined in the Track class and on the
> > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > keep a record of which track or which album art goes to which album.
> > However I also would like to add a ManyToManyField on my Album class
> > so I can pull the album data in my view.  Defining this is both places
> > seems redundant to me, but I'm not sure how else I can accomplish
> > this.  What would be best practice in this situation and how should I
> > proceed?
>
> > class Album(models.Model):
> >     title          = models.CharField(max_length=255)
> >     prefix         = models.CharField(max_length=20, blank=True)
> >     subtitle       = models.CharField(blank=True, max_length=255)
> >     slug           = models.SlugField(unique=True)
> >     artist         = models.ForeignKey('Artist')
>
> > class AlbumArt(models.Model):
> >     title          = models.CharField(max_length=200)
> >     slug           = models.SlugField()
> >     album          = models.ForeignKey('Album')
>
> > class Track(models.Model):
> >     title         = models.CharField(max_length=200)
> >     slug          = models.SlugField(unique=True)
> >     album         = models.ForeignKey('Album')
> >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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: noob: Where does print output go?

2008-08-22 Thread lingrlongr

Take a look at django-logging.  
http://code.google.com/p/django-logging/wiki/Overview

On Aug 22, 4:26 am, [EMAIL PROTECTED] wrote:
> Hi All,
>
> Can anybody tell me if there's a possibility to see output of the
> regular print command when used in a view? fo instance to a log file
> with a "tail -f"
>
> The code:
>
> def detail(request, id):
>     p = get_object_or_404(Customer, pk=customer_id)
>     product_list = p.product_set.all()
>     print product_list
>
> It's not going to stay there, but with commands like dir() and help()
> I can get a lot of usefull info on the objects I'm working
> (playing .. ;-) with.
>
> Thanx a lot!
>
> Regards,
>
> Gerard.
--~--~-~--~~~---~--~~
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: database relationships

2008-08-22 Thread lingrlongr

Super easy :)  Just to show you another way to implement generic
views, I used custom view that returns a generic view.

# urls.py
from myapp.views import artist
...
(r'^artist/(?P\w+)/$', artist),
...

#views.py
from django.views.generic.list_detail import object_detail
def artist(request, slug):
return object_detail(
request,
queryset=Artist.objects.all(),
slug = slug,
template_object_name = 'artist'
)

# //artist_list.html
{{ artist }}
Albums

{% for album in artist.album_set.all %}
   {{ album.name }}
   
   {% for track in album.track_set.all %}
 {{ track.name }}
   {% endfor %}
   
{% endfor %}


Django makes traversing relationships easy...

HTH

Keith


On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
> So if I sent the artist to the template and wanted to grab the list of
> albums with all the album tracks how would I go about that.  Would I
> have to pull in all the data with a custom view?  So far I've only
> been using generic views.  It definitely makes sense pulling in the
> information through the track back up through the album to the artist,
> how could I reverse the process so I can get all the artist vars plus
> the data I need from the track and album tables?  Thanks a bunch,
> you've been very helpful already.
>
> Charlie
>
> On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > as you can get them in a template too.  I just wanted to show you the
> > relation.
> > If you sent the track to the template, you can get the artist by
> > using:
>
> > {{ track.album.artist }}
>
> > Keith
>
> > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > The only part you have that is redundant is the "artist" in your
> > > "Track" class.  You can find out the artist because a track is related
> > > to an album, which in turn, is related to an artist.
>
> > > Some of the code you'd maybe see in a view would be:
>
> > > # views.py
> > > from django.shortcuts import get_object_or_404
> > > from models import Album, Track
>
> > > def album(request, slug):
> > >   album = get_object_or_404(Album, slug=slug)
> > >   artist = album.artist
> > >   tracks = album.track_set.all()
> > >   ...etc... return a response...
>
> > > def track(request, slug):
> > >   track = get_object_or_404(Track, slug=slug)
> > >   album = track.album
> > >   artist = album.artist
> > >   ..etc..
>
> > > HTH
>
> > > Keith
>
> > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > I'm trying to set up my first Django application and I'm trying to
> > > > figure out the database relationships.  I want to be able to list
> > > > albums, with their corresponding tracks and album artwork.  Right now
> > > > I only have foreign keys defined in the Track class and on the
> > > > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > > > keep a record of which track or which album art goes to which album.
> > > > However I also would like to add a ManyToManyField on my Album class
> > > > so I can pull the album data in my view.  Defining this is both places
> > > > seems redundant to me, but I'm not sure how else I can accomplish
> > > > this.  What would be best practice in this situation and how should I
> > > > proceed?
>
> > > > class Album(models.Model):
> > > >     title          = models.CharField(max_length=255)
> > > >     prefix         = models.CharField(max_length=20, blank=True)
> > > >     subtitle       = models.CharField(blank=True, max_length=255)
> > > >     slug           = models.SlugField(unique=True)
> > > >     artist         = models.ForeignKey('Artist')
>
> > > > class AlbumArt(models.Model):
> > > >     title          = models.CharField(max_length=200)
> > > >     slug           = models.SlugField()
> > > >     album          = models.ForeignKey('Album')
>
> > > > class Track(models.Model):
> > > >     title         = models.CharField(max_length=200)
> > > >     slug          = models.SlugField(unique=True)
> > > >     album         = models.ForeignKey('Album')
> > > >     artist        = models.ForeignKey('Artist')
--~--~-~--~~~---~--~~
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: database relationships

2008-08-22 Thread lingrlongr

Also note, if your intentions were to grab all that information and
just send the artist to the template, I think you'd get better
performance if your queryset in the view looked like this:

queryset=Artist.objects.select_related().all()

Keith

On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Super easy :)  Just to show you another way to implement generic
> views, I used custom view that returns a generic view.
>
> # urls.py
> from myapp.views import artist
> ...
> (r'^artist/(?P\w+)/$', artist),
> ...
>
> #views.py
> from django.views.generic.list_detail import object_detail
> def artist(request, slug):
>     return object_detail(
>         request,
>         queryset=Artist.objects.all(),
>         slug = slug,
>         template_object_name = 'artist'
>     )
>
> # //artist_list.html
> {{ artist }}
> Albums
> 
> {% for album in artist.album_set.all %}
>    {{ album.name }}
>    
>    {% for track in album.track_set.all %}
>      {{ track.name }}
>    {% endfor %}
>    
> {% endfor %}
> 
>
> Django makes traversing relationships easy...
>
> HTH
>
> Keith
>
> On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
>
> > So if I sent the artist to the template and wanted to grab the list of
> > albums with all the album tracks how would I go about that.  Would I
> > have to pull in all the data with a custom view?  So far I've only
> > been using generic views.  It definitely makes sense pulling in the
> > information through the track back up through the album to the artist,
> > how could I reverse the process so I can get all the artist vars plus
> > the data I need from the track and album tables?  Thanks a bunch,
> > you've been very helpful already.
>
> > Charlie
>
> > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > > as you can get them in a template too.  I just wanted to show you the
> > > relation.
> > > If you sent the track to the template, you can get the artist by
> > > using:
>
> > > {{ track.album.artist }}
>
> > > Keith
>
> > > On Aug 22, 12:24 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > The only part you have that is redundant is the "artist" in your
> > > > "Track" class.  You can find out the artist because a track is related
> > > > to an album, which in turn, is related to an artist.
>
> > > > Some of the code you'd maybe see in a view would be:
>
> > > > # views.py
> > > > from django.shortcuts import get_object_or_404
> > > > from models import Album, Track
>
> > > > def album(request, slug):
> > > >   album = get_object_or_404(Album, slug=slug)
> > > >   artist = album.artist
> > > >   tracks = album.track_set.all()
> > > >   ...etc... return a response...
>
> > > > def track(request, slug):
> > > >   track = get_object_or_404(Track, slug=slug)
> > > >   album = track.album
> > > >   artist = album.artist
> > > >   ..etc..
>
> > > > HTH
>
> > > > Keith
>
> > > > On Aug 21, 11:44 pm, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > > I'm trying to set up my first Django application and I'm trying to
> > > > > figure out the database relationships.  I want to be able to list
> > > > > albums, with their corresponding tracks and album artwork.  Right now
> > > > > I only have foreign keys defined in the Track class and on the
> > > > > AlbumArt class pointing to the Album class.  I'm doing this so I can
> > > > > keep a record of which track or which album art goes to which album.
> > > > > However I also would like to add a ManyToManyField on my Album class
> > > > > so I can pull the album data in my view.  Defining this is both places
> > > > > seems redundant to me, but I'm not sure how else I can accomplish
> > > > > this.  What would be best practice in this situation and how should I
> > > > > proceed?
>
> > > > > class Album(models.Model):
> > > > >     title          = models.CharField(max_length=255)
> > > > >     prefix         = models.CharField(max_length=20, blank=True)
> > > > >     subtitle       = models.CharField(blank=True, max_length=255)
> > > > >     slug           = m

Re: ANN: django-morsels

2008-08-22 Thread lingrlongr

I can't get this to work at all.  Seems to bomb here:

class MorselManager(models.Manager):
def get_for_current(self, context, name, inherit=False):
if not context.has_key('request'):  <-- key never
seems to exist
return None

I have a morsel defined with a URL of "/mypage/".

# urls.py
(r'^mypage/$', myview),

# views.py
def myview(request):
return object_list(
request,
queryset=Stuff.objects.all(),
)

I have this in my template:
{% load morsel_tags %}
{% morsel %}

Am I missing something?

Keith


On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:
> At first glance (and, quite possibly, second and third) django-morsels 
> might look like a clone of django-chunks 
> (http://code.google.com/p/django-chunks/
> ). Both apps attempt to solve the same problem, and in fact, I wrote  
> this app after seeing and trying out django-chunks (so thanks, Clint  
> Ecker!). But the feature set and functions differ enough to justify  
> the existence of a second implementation.
>
> These apps provide a way to store partial page content in the  
> database, and manage it in the admin app, when this content is  
> integrated in pages that also contain dynamic features. I always dealt  
> with this using FlatPages and templatetags (custom-written for each  
> new project) that included them in templates. Looking at django-
> chunks, I realized a few things:
>
> 1) The templatetags I've already written worked better, for my own  
> use, than the key-based approach of django-chunks.
> 2) Using a dedicated model for this type of content made a lot of sense.
> 3) Merging this model and all those custom templatetags I already had  
> into a reusable app also made sense.
> 4) I needed a name that didn't have "chunks" in it.
>
> The main features of django-morselsare:
>
> * Each morsel can be tied to a site page by specifying the page's URL  
> in the morsel.
>
> * Differentmorselscan be used in the same page by adding arbitrary  
> names to the morsel's URL.
>
> *Morselscan be inherited from higher levels in the site's URL  
> hierarchy. This allows the content of a single morsel to be displayed  
> in a whole site section, while being overriden by othermorselsin  
> specific pages within the section.
>
> *Morselscan include an optional title, which may be used to identify  
> the morsel and may also be displayed in templates using the morsel.
>
> * Two custom templatetags - morsel and withmorsel - allowmorselsto  
> be used in various, flexible ways.
>
> *Morselscan be locked, which prevents them from being deleted. This  
> is intended to prevent accidental deletion of requiredmorsels, as  
> having to explicitly unlock a morsel before deleting it should make  
> the user think twice about it.
>
> * If the typogrify app (http://code.google.com/p/typogrify/) is  
> installed, morsel content will be typogrified when rendered using the  
> morsel templatetag.
>
> You can find django-morselsat .
>
> Itai
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



FormWizard Problems

2008-08-22 Thread lingrlongr

I'm using the form wizard for a project.  All the field names in
models.py coincide with the field names in forms.py.  There is ONE
field that is consistently, yet sporadically, causing problems and I
cannot see why.

# models.py
class PurchaseApplication(BasicApplication):
down_payment_assets = models.IntegerField(help_text=u'Available
assets for down payment')

# forms.py
class PurchaseForm3_yes(forms.Form):
down_payment_assets = forms.IntegerField(label=u'Available assets
for down payment ($)')

So, as I said, all the field names for the model and the form, so to
save I use:

class PurchaseWizard(FormWizard):
def done(self, request, form_list):
data = {}
for f in form_list:
data.update(f.cleaned_data)

o = PurchaseApplication()

for f in data:
o.__setattr__(f, data[f])
o.site = Site.objects.get_current()
o.save()

So, its only the down_payment_assets field that is causing problems,
but only sporadically.  The error text looks like this:

Exception Type: OperationalError
Exception Value:(1048, "Column 'down_payment_assets' cannot be
null")

But the request.POST vars in actally show a value!!


VariableValue
1-credit_rating u'1'
2-purchase_home_typeu'1'
2-down_payment_assets   u'3'
<-
0-best_time u'1'
1-contact_meu'N'
wizard_step u'2'

Thoughts?

Keith
--~--~-~--~~~---~--~~
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: ANN: django-morsels

2008-08-22 Thread lingrlongr

If I change my view to this, it works:

# views.py
def myview(request):
return object_list(
request,
queryset=Stuff.objects.all(),
extra_context = {
  'request': request,
}
)

Is this supposed to be the right way to use morsels?

Keith


On Aug 22, 12:50 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I can't get this to work at all.  Seems to bomb here:
>
> class MorselManager(models.Manager):
>     def get_for_current(self, context, name, inherit=False):
>         if not context.has_key('request'):      <-- key never
> seems to exist
>             return None
>
> I have a morsel defined with a URL of "/mypage/".
>
> # urls.py
> (r'^mypage/$', myview),
>
> # views.py
> def myview(request):
>     return object_list(
>         request,
>         queryset=Stuff.objects.all(),
>     )
>
> I have this in my template:
> {% load morsel_tags %}
> {% morsel %}
>
> Am I missing something?
>
> Keith
>
> On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:
>
> > At first glance (and, quite possibly, second and third) django-morsels 
> > might look like a clone of django-chunks 
> > (http://code.google.com/p/django-chunks/
> > ). Both apps attempt to solve the same problem, and in fact, I wrote  
> > this app after seeing and trying out django-chunks (so thanks, Clint  
> > Ecker!). But the feature set and functions differ enough to justify  
> > the existence of a second implementation.
>
> > These apps provide a way to store partial page content in the  
> > database, and manage it in the admin app, when this content is  
> > integrated in pages that also contain dynamic features. I always dealt  
> > with this using FlatPages and templatetags (custom-written for each  
> > new project) that included them in templates. Looking at django-
> > chunks, I realized a few things:
>
> > 1) The templatetags I've already written worked better, for my own  
> > use, than the key-based approach of django-chunks.
> > 2) Using a dedicated model for this type of content made a lot of sense.
> > 3) Merging this model and all those custom templatetags I already had  
> > into a reusable app also made sense.
> > 4) I needed a name that didn't have "chunks" in it.
>
> > The main features of django-morselsare:
>
> > * Each morsel can be tied to a site page by specifying the page's URL  
> > in the morsel.
>
> > * Differentmorselscan be used in the same page by adding arbitrary  
> > names to the morsel's URL.
>
> > *Morselscan be inherited from higher levels in the site's URL  
> > hierarchy. This allows the content of a single morsel to be displayed  
> > in a whole site section, while being overriden by othermorselsin  
> > specific pages within the section.
>
> > *Morselscan include an optional title, which may be used to identify  
> > the morsel and may also be displayed in templates using the morsel.
>
> > * Two custom templatetags - morsel and withmorsel - allowmorselsto  
> > be used in various, flexible ways.
>
> > *Morselscan be locked, which prevents them from being deleted. This  
> > is intended to prevent accidental deletion of requiredmorsels, as  
> > having to explicitly unlock a morsel before deleting it should make  
> > the user think twice about it.
>
> > * If the typogrify app (http://code.google.com/p/typogrify/) is  
> > installed, morsel content will be typogrified when rendered using the  
> > morsel templatetag.
>
> > You can find django-morselsat <http://code.google.com/p/django-morsels/>.
>
> > Itai
--~--~-~--~~~---~--~~
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: FormWizard Problems

2008-08-22 Thread lingrlongr

Ah, so I guess ModelForm will work with the FormWizard?  I'll have to
look through that documentation.  Reading documentation is easier than
pulling my hair out!  =)

Thanks Rajesh.

On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi Keith,
>
>
>
> > I'm using the form wizard for a project.  All the field names in
> > models.py coincide with the field names in forms.py.  There is ONE
> > field that is consistently, yet sporadically, causing problems and I
> > cannot see why.
>
> > # models.py
> > class PurchaseApplication(BasicApplication):
> >     down_payment_assets = models.IntegerField(help_text=u'Available
> > assets for down payment')
>
> > # forms.py
> > class PurchaseForm3_yes(forms.Form):
> >     down_payment_assets = forms.IntegerField(label=u'Available assets
> > for down payment ($)')
>
> > So, as I said, all the field names for the model and the form, so to
> > save I use:
>
> > class PurchaseWizard(FormWizard):
> >     def done(self, request, form_list):
> >         data = {}
> >         for f in form_list:
> >             data.update(f.cleaned_data)
>
> >         o = PurchaseApplication()
>
> >         for f in data:
> >             o.__setattr__(f, data[f])
> >         o.site = Site.objects.get_current()
> >         o.save()
>
> > So, its only the down_payment_assets field that is causing problems,
> > but only sporadically.  The error text looks like this:
>
> > Exception Type:         OperationalError
> > Exception Value:        (1048, "Column 'down_payment_assets' cannot be
> > null")
>
> > But the request.POST vars in actally show a value!!
>
> > Variable        Value
> > 1-credit_rating         u'1'
> > 2-purchase_home_type    u'1'
> > 2-down_payment_assets   u'3'
> > <-
> > 0-best_time     u'1'
> > 1-contact_me    u'N'
> > wizard_step     u'2'
>
> > Thoughts?
>
> Looks like o.__setattr__(f, data[f]) is not doing it's job for the
> field down_payment_assets. You might want to print or log what's in
> 'data' before you iterate over it.
>
> Also, are you aware that Django's built-in ModelForm provides similar
> functionality to what you seem to be trying to achieve above?
>
> http://www.djangoproject.com/documentation/modelforms/
>
> -Rajesh D
--~--~-~--~~~---~--~~
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: ANN: django-morsels

2008-08-22 Thread lingrlongr

Recommended fix @ http://code.google.com/p/django-morsels/issues/detail?id=1

On Aug 22, 2:51 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> If I change my view to this, it works:
>
> # views.py
> def myview(request):
>     return object_list(
>         request,
>         queryset=Stuff.objects.all(),
>         extra_context = {
>           'request': request,
>         }
>     )
>
> Is this supposed to be the right way to use morsels?
>
> Keith
>
> On Aug 22, 12:50 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > I can't get this to work at all.  Seems to bomb here:
>
> > class MorselManager(models.Manager):
> >     def get_for_current(self, context, name, inherit=False):
> >         if not context.has_key('request'):      <-- key never
> > seems to exist
> >             return None
>
> > I have a morsel defined with a URL of "/mypage/".
>
> > # urls.py
> > (r'^mypage/$', myview),
>
> > # views.py
> > def myview(request):
> >     return object_list(
> >         request,
> >         queryset=Stuff.objects.all(),
> >     )
>
> > I have this in my template:
> > {% load morsel_tags %}
> > {% morsel %}
>
> > Am I missing something?
>
> > Keith
>
> > On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:
>
> > > At first glance (and, quite possibly, second and third) django-morsels 
> > > might look like a clone of django-chunks 
> > > (http://code.google.com/p/django-chunks/
> > > ). Both apps attempt to solve the same problem, and in fact, I wrote  
> > > this app after seeing and trying out django-chunks (so thanks, Clint  
> > > Ecker!). But the feature set and functions differ enough to justify  
> > > the existence of a second implementation.
>
> > > These apps provide a way to store partial page content in the  
> > > database, and manage it in the admin app, when this content is  
> > > integrated in pages that also contain dynamic features. I always dealt  
> > > with this using FlatPages and templatetags (custom-written for each  
> > > new project) that included them in templates. Looking at django-
> > > chunks, I realized a few things:
>
> > > 1) The templatetags I've already written worked better, for my own  
> > > use, than the key-based approach of django-chunks.
> > > 2) Using a dedicated model for this type of content made a lot of sense.
> > > 3) Merging this model and all those custom templatetags I already had  
> > > into a reusable app also made sense.
> > > 4) I needed a name that didn't have "chunks" in it.
>
> > > The main features of django-morselsare:
>
> > > * Each morsel can be tied to a site page by specifying the page's URL  
> > > in the morsel.
>
> > > * Differentmorselscan be used in the same page by adding arbitrary  
> > > names to the morsel's URL.
>
> > > *Morselscan be inherited from higher levels in the site's URL  
> > > hierarchy. This allows the content of a single morsel to be displayed  
> > > in a whole site section, while being overriden by othermorselsin  
> > > specific pages within the section.
>
> > > *Morselscan include an optional title, which may be used to identify  
> > > the morsel and may also be displayed in templates using the morsel.
>
> > > * Two custom templatetags - morsel and withmorsel - allowmorselsto  
> > > be used in various, flexible ways.
>
> > > *Morselscan be locked, which prevents them from being deleted. This  
> > > is intended to prevent accidental deletion of requiredmorsels, as  
> > > having to explicitly unlock a morsel before deleting it should make  
> > > the user think twice about it.
>
> > > * If the typogrify app (http://code.google.com/p/typogrify/) is  
> > > installed, morsel content will be typogrified when rendered using the  
> > > morsel templatetag.
>
> > > You can find django-morselsat <http://code.google.com/p/django-morsels/>.
>
> > > Itai
--~--~-~--~~~---~--~~
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: FormWizard Problems

2008-08-22 Thread lingrlongr

So by using a combination of fields and exclude in the Meta class, I
can choose what fields I want for that form.  Nice!   :)

Two questions though:

1.  Will fields be presented in the order specified in the fields
tuple?
2.  In my original model/form diagram, will there be a way for me to
use the model's help_text as the field label?

Keith

On Aug 22, 4:24 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Ah, so I guess ModelForm will work with the FormWizard?  I'll have to
> look through that documentation.  Reading documentation is easier than
> pulling my hair out!  =)
>
> Thanks Rajesh.
>
> On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > Hi Keith,
>
> > > I'm using the form wizard for a project.  All the field names in
> > > models.py coincide with the field names in forms.py.  There is ONE
> > > field that is consistently, yet sporadically, causing problems and I
> > > cannot see why.
>
> > > # models.py
> > > class PurchaseApplication(BasicApplication):
> > >     down_payment_assets = models.IntegerField(help_text=u'Available
> > > assets for down payment')
>
> > > # forms.py
> > > class PurchaseForm3_yes(forms.Form):
> > >     down_payment_assets = forms.IntegerField(label=u'Available assets
> > > for down payment ($)')
>
> > > So, as I said, all the field names for the model and the form, so to
> > > save I use:
>
> > > class PurchaseWizard(FormWizard):
> > >     def done(self, request, form_list):
> > >         data = {}
> > >         for f in form_list:
> > >             data.update(f.cleaned_data)
>
> > >         o = PurchaseApplication()
>
> > >         for f in data:
> > >             o.__setattr__(f, data[f])
> > >         o.site = Site.objects.get_current()
> > >         o.save()
>
> > > So, its only the down_payment_assets field that is causing problems,
> > > but only sporadically.  The error text looks like this:
>
> > > Exception Type:         OperationalError
> > > Exception Value:        (1048, "Column 'down_payment_assets' cannot be
> > > null")
>
> > > But the request.POST vars in actally show a value!!
>
> > > Variable        Value
> > > 1-credit_rating         u'1'
> > > 2-purchase_home_type    u'1'
> > > 2-down_payment_assets   u'3'
> > > <-
> > > 0-best_time     u'1'
> > > 1-contact_me    u'N'
> > > wizard_step     u'2'
>
> > > Thoughts?
>
> > Looks like o.__setattr__(f, data[f]) is not doing it's job for the
> > field down_payment_assets. You might want to print or log what's in
> > 'data' before you iterate over it.
>
> > Also, are you aware that Django's built-in ModelForm provides similar
> > functionality to what you seem to be trying to achieve above?
>
> >http://www.djangoproject.com/documentation/modelforms/
>
> > -Rajesh D
--~--~-~--~~~---~--~~
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: FormWizard Problems

2008-08-23 Thread lingrlongr

It looks like these ModelForms are going to work well for me.  I have
a lot less code now.  I actually created 2 other classes to help out
with the field ordering.  I haven't tested these yet...

class OrderedForm(ModelForm):
def __init__(self, ordered_fields, *args, **kwargs):
super(OrderedForm, self).__init__(*args, **kwargs)
self.fields.keyOrder = ordered_fields
for f in self.fields:
self.fields[f].label = self.fields[f].help_text
self.fields[f].help_text = None

class ApplicationForm(OrderedForm):
def __init__(self, *args, **kwargs):
try:
ordered_fields = list(self.Meta.fields)
except:
ordered_fields = []
super(ApplicationForm, self).__init__(ordered_fields, *args,
**kwargs)

I'll just inherit from ApplicationForm for all my forms.  I'm not sure
how its going to work with ModelForm inheritance yet though...

I don't understand how I'm going to use this forms with the form
wizard though, particularly in the done() function.  Each form in the
wizard contains some of the fields for the model.

o = MyObject()

for form in form_list:
  f = form_list[form](instance=o)
  f.save(commit=False)

o.site = Site.objects.get_current()
o.save()

Does this look right?   Thanks for everyone's help so far!!

Keith


On Aug 23, 3:45 am, coulix <[EMAIL PROTECTED]> wrote:
> 1. yes by overlriding the init
>
> class myForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
>     super(myForm, self).__init__(*args, **kwargs)
>     self.fields.keyOrder = ['foo', 'bar',...]
>
> 2. in the same way you could use
>     self.fields['foo'].label = self.fields['foo'].help_text
>
> On Aug 22, 10:40 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > So by using a combination of fields and exclude in the Meta class, I
> > can choose what fields I want for that form.  Nice!   :)
>
> > Two questions though:
>
> > 1.  Will fields be presented in the order specified in the fields
> > tuple?
> > 2.  In my original model/form diagram, will there be a way for me to
> > use the model's help_text as the field label?
>
> > Keith
>
> > On Aug 22, 4:24 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > Ah, so I guess ModelForm will work with the FormWizard?  I'll have to
> > > look through that documentation.  Reading documentation is easier than
> > > pulling my hair out!  =)
>
> > > Thanks Rajesh.
>
> > > On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Keith,
>
> > > > > I'm using the form wizard for a project.  All the field names in
> > > > > models.py coincide with the field names in forms.py.  There is ONE
> > > > > field that is consistently, yet sporadically, causing problems and I
> > > > > cannot see why.
>
> > > > > # models.py
> > > > > class PurchaseApplication(BasicApplication):
> > > > >     down_payment_assets = models.IntegerField(help_text=u'Available
> > > > > assets for down payment')
>
> > > > > # forms.py
> > > > > class PurchaseForm3_yes(forms.Form):
> > > > >     down_payment_assets = forms.IntegerField(label=u'Available assets
> > > > > for down payment ($)')
>
> > > > > So, as I said, all the field names for the model and the form, so to
> > > > > save I use:
>
> > > > > class PurchaseWizard(FormWizard):
> > > > >     def done(self, request, form_list):
> > > > >         data = {}
> > > > >         for f in form_list:
> > > > >             data.update(f.cleaned_data)
>
> > > > >         o = PurchaseApplication()
>
> > > > >         for f in data:
> > > > >             o.__setattr__(f, data[f])
> > > > >         o.site = Site.objects.get_current()
> > > > >         o.save()
>
> > > > > So, its only the down_payment_assets field that is causing problems,
> > > > > but only sporadically.  The error text looks like this:
>
> > > > > Exception Type:         OperationalError
> > > > > Exception Value:        (1048, "Column 'down_payment_assets' cannot be
> > > > > null")
>
> > > > > But the request.POST vars in actally show a value!!
>
> > > > > Variable        Value
> > > > > 1-credit_rating         u'1'
> > > > > 2-purchase_home_type    u'1'

Re: FormWizard Problems

2008-08-24 Thread lingrlongr

Looks like my models are working.  (YAY!)   My save routine failed
though, but I finally figured it out.  So the done() function looks
like this now:

def done(self, request, form_list):
  o = PurchaseApplication()
  for form in form_list:
form.instance = o
form.save(commit=False)

  o.site = Site.objects.get_current()
  o.save()

Inheriting from a form doesn't seem to work.  But I'll work on that...

class A(ApplicationForm)
class B(A)  <-- not working - fields don't populate from parent obj

On Aug 23, 9:40 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> It looks like these ModelForms are going to work well for me.  I have
> a lot less code now.  I actually created 2 other classes to help out
> with the field ordering.  I haven't tested these yet...
>
> class OrderedForm(ModelForm):
>     def __init__(self, ordered_fields, *args, **kwargs):
>         super(OrderedForm, self).__init__(*args, **kwargs)
>         self.fields.keyOrder = ordered_fields
>         for f in self.fields:
>             self.fields[f].label = self.fields[f].help_text
>             self.fields[f].help_text = None
>
> class ApplicationForm(OrderedForm):
>     def __init__(self, *args, **kwargs):
>         try:
>             ordered_fields = list(self.Meta.fields)
>         except:
>             ordered_fields = []
>         super(ApplicationForm, self).__init__(ordered_fields, *args,
> **kwargs)
>
> I'll just inherit from ApplicationForm for all my forms.  I'm not sure
> how its going to work with ModelForm inheritance yet though...
>
> I don't understand how I'm going to use this forms with the form
> wizard though, particularly in the done() function.  Each form in the
> wizard contains some of the fields for the model.
>
> o = MyObject()
>
> for form in form_list:
>   f = form_list[form](instance=o)
>   f.save(commit=False)
>
> o.site = Site.objects.get_current()
> o.save()
>
> Does this look right?   Thanks for everyone's help so far!!
>
> Keith
>
> On Aug 23, 3:45 am, coulix <[EMAIL PROTECTED]> wrote:
>
> > 1. yes by overlriding the init
>
> > class myForm(forms.ModelForm):
> > def __init__(self, *args, **kwargs):
> >     super(myForm, self).__init__(*args, **kwargs)
> >     self.fields.keyOrder = ['foo', 'bar',...]
>
> > 2. in the same way you could use
> >     self.fields['foo'].label = self.fields['foo'].help_text
>
> > On Aug 22, 10:40 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > So by using a combination of fields and exclude in the Meta class, I
> > > can choose what fields I want for that form.  Nice!   :)
>
> > > Two questions though:
>
> > > 1.  Will fields be presented in the order specified in the fields
> > > tuple?
> > > 2.  In my original model/form diagram, will there be a way for me to
> > > use the model's help_text as the field label?
>
> > > Keith
>
> > > On Aug 22, 4:24 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > Ah, so I guess ModelForm will work with the FormWizard?  I'll have to
> > > > look through that documentation.  Reading documentation is easier than
> > > > pulling my hair out!  =)
>
> > > > Thanks Rajesh.
>
> > > > On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi Keith,
>
> > > > > > I'm using the form wizard for a project.  All the field names in
> > > > > > models.py coincide with the field names in forms.py.  There is ONE
> > > > > > field that is consistently, yet sporadically, causing problems and I
> > > > > > cannot see why.
>
> > > > > > # models.py
> > > > > > class PurchaseApplication(BasicApplication):
> > > > > >     down_payment_assets = models.IntegerField(help_text=u'Available
> > > > > > assets for down payment')
>
> > > > > > # forms.py
> > > > > > class PurchaseForm3_yes(forms.Form):
> > > > > >     down_payment_assets = forms.IntegerField(label=u'Available 
> > > > > > assets
> > > > > > for down payment ($)')
>
> > > > > > So, as I said, all the field names for the model and the form, so to
> > > > > > save I use:
>
> > > > > > class PurchaseWizard(FormWizard):
> > > > > >     def done(self, request, form_list):
> > > > > >         data = {}

settings.TIME_ZONE

2008-08-25 Thread lingrlongr

I'm a little confused about the TIME_ZONE setting in settings.py.  I
originally had it set to 'America/New_York', because that's the time
zone where I'm located, but I noticed the times were ~4 hours off when
I would save an object that had a DateTimeField(auto_now_add=True)
field in the model.  Instead I tried to set the TIME_ZONE value to
where the web server was, Utah, so I used 'America/Denver'.

I saved an object while configured for Denver, timestamp was for
2:40am.  I changed the setting back to New_York and saved another
object, the the timestamp was for 2:52am.  Local time for me was
~10pm.

Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.today()
datetime.datetime(2008, 8, 25, 21, 9, 15, 497672)

$ date
Mon Aug 25 21:09:45 MDT 2008

I would like the times to shown as Eastern Time zone.  What should I
set the TIME_ZONE setting to?

Keith
--~--~-~--~~~---~--~~
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: settings.TIME_ZONE

2008-08-25 Thread lingrlongr

Here's more info:

$ ./manage.py shell
Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from datetime import datetime
>>> datetime.today()
datetime.datetime(2008, 8, 26, 3, 25, 47, 588753)


$ python
Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.today()
datetime.datetime(2008, 8, 25, 21, 26, 21, 383524)

Keith

On Aug 25, 11:11 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I'm a little confused about the TIME_ZONE setting in settings.py.  I
> originally had it set to 'America/New_York', because that's the time
> zone where I'm located, but I noticed the times were ~4 hours off when
> I would save an object that had a DateTimeField(auto_now_add=True)
> field in the model.  Instead I tried to set the TIME_ZONE value to
> where the web server was, Utah, so I used 'America/Denver'.
>
> I saved an object while configured for Denver, timestamp was for
> 2:40am.  I changed the setting back to New_York and saved another
> object, the the timestamp was for 2:52am.  Local time for me was
> ~10pm.
>
> Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> import datetime
> >>> datetime.datetime.today()
>
> datetime.datetime(2008, 8, 25, 21, 9, 15, 497672)
>
> $ date
> Mon Aug 25 21:09:45 MDT 2008
>
> I would like the times to shown as Eastern Time zone.  What should I
> set the TIME_ZONE setting to?
>
> Keith
--~--~-~--~~~---~--~~
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: ANN: django-morsels

2008-08-26 Thread lingrlongr

It makes me wonder now though.  If I can just include a bunch of
morsels on a page, why even bother using flatpages anymore??  That
just makes things more difficult to maintain.  Thoughts?

On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:
> At first glance (and, quite possibly, second and third) django-morsels 
> might look like a clone of django-chunks 
> (http://code.google.com/p/django-chunks/
> ). Both apps attempt to solve the same problem, and in fact, I wrote  
> this app after seeing and trying out django-chunks (so thanks, Clint  
> Ecker!). But the feature set and functions differ enough to justify  
> the existence of a second implementation.
>
> These apps provide a way to store partial page content in the  
> database, and manage it in the admin app, when this content is  
> integrated in pages that also contain dynamic features. I always dealt  
> with this using FlatPages and templatetags (custom-written for each  
> new project) that included them in templates. Looking at django-
> chunks, I realized a few things:
>
> 1) The templatetags I've already written worked better, for my own  
> use, than the key-based approach of django-chunks.
> 2) Using a dedicated model for this type of content made a lot of sense.
> 3) Merging this model and all those custom templatetags I already had  
> into a reusable app also made sense.
> 4) I needed a name that didn't have "chunks" in it.
>
> The main features of django-morselsare:
>
> * Each morsel can be tied to a site page by specifying the page's URL  
> in the morsel.
>
> * Differentmorselscan be used in the same page by adding arbitrary  
> names to the morsel's URL.
>
> *Morselscan be inherited from higher levels in the site's URL  
> hierarchy. This allows the content of a single morsel to be displayed  
> in a whole site section, while being overriden by othermorselsin  
> specific pages within the section.
>
> *Morselscan include an optional title, which may be used to identify  
> the morsel and may also be displayed in templates using the morsel.
>
> * Two custom templatetags - morsel and withmorsel - allowmorselsto  
> be used in various, flexible ways.
>
> *Morselscan be locked, which prevents them from being deleted. This  
> is intended to prevent accidental deletion of requiredmorsels, as  
> having to explicitly unlock a morsel before deleting it should make  
> the user think twice about it.
>
> * If the typogrify app (http://code.google.com/p/typogrify/) is  
> installed, morsel content will be typogrified when rendered using the  
> morsel templatetag.
>
> You can find django-morselsat .
>
> Itai
--~--~-~--~~~---~--~~
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: manage.py runserver > cannot import name models

2008-08-26 Thread lingrlongr

Start with urls.py.  Are you doing this anywhere?

   import models

If you have a lot of apps, you could remove all but one from
INSTALLED_APPS, test manage.py, repeat, until you find the offending
app.  The just go through the files in the app and make sure you are
properly defining any imports.

Keith

On Aug 26, 6:00 pm, Leaf <[EMAIL PROTECTED]> wrote:
> The subject line should be pretty self-explanatory. I try to run
> "manage.py runserver", and I get "Error: cannot import name models" in
> bold, red text. That's the only output I get. Does anyone know what
> causes such an error, or where it is referring to?
>
> Regards,
> Leaf
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ModelForm - Required Fields

2008-08-26 Thread lingrlongr

Is there a way for me to quickly make certain fields in a ModelForm
class required.  I know this looks back to the model for that
information...

In my case I'm using a FormWizard to display a series of forms.  The
fields shows in some steps are dependent on answers to previous
questions.  So, in my model, sometimes a field will be required,
sometimes not.  Therefore, I'm looking for the form to validate that
part.

I know I can just list the fields like this:

class MyForm(ModelForm):
  my_field = forms.CharField(max_length=80, choices=MY_CHOICES,
required=True)
  ...etc...

...but I don't want to have to repeat all the stuff that just
"happens" automatically...

Keith
--~--~-~--~~~---~--~~
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: Many to One Relationship

2008-08-27 Thread lingrlongr

The error is generated because you have two fields in the Swap model
that refer to the User model, and two that refer to the Shifts model.
As the error states you need to specify the related_name value for
those ForeignKeys.  Take a look at the documentation for related_name
here: 
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships

class Swaps(models.Model):
origin_shift = models.ForeignKey(Shifts,
related_name='origin_shift')
origin_user = models.ForeignKey(User,
related_name='origin_user')
destination_shift = models.ForeignKey(Shifts,
related_name='destination_shift')
state = models.CharField(maxlength=25)
swap_user = models.ForeignKey(User, related_name='swap_user')

HTH

Keith

On Aug 27, 11:42 am, "Daniel A." <[EMAIL PROTECTED]> wrote:
> Hi! I'm a switcher from Rails and I'm learning Django. I'm stuck with
> something I thing should be easy but for some reason I can't find the
> error.
>
> I'm trying to define a model to manage shifts for volunteers. I have
> three diferent models, Shifts, Users and Swaps. A User have many
> Shifts and a Shift have many Swaps, while a Shift only have one User,
> and a Swap only have one Shift. A Shift have two users. Well, then I
> wrote something like this:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> # Create your models here.
> class Shifts(models.Model):
>     date = models.DateField()
>     user_1 = models.ForeignKey(User)
>     user_2 = models.ForeignKey(User)
>     turno = models.IntegerField()
>
> class Swaps(models.Model):
>         origin_shift = models.ForeignKey(Shifts)
>         origin_user = models.ForeignKey(User)
>         destination_shift = models.ForeignKey(Shifts)
>         state = models.CharField(maxlength=25)
>         swap_user = models.ForeignKey(User)
>
> Does anybody knows what I'm doing wrong? I get messages of validation
> like this:
>
> turno.shifts: Accessor for field 'user_1' clashes with related field
> 'User.shifts_set'. Add a related_name argument to the definition for
> 'user_1'.
> turno.shifts: Accessor for field 'user_2' clashes with related field
> 'User.shifts_set'. Add a related_name argument to the definition for
> 'user_2'.
> turno.swaps: Accessor for field 'origin_shift' clashes with related
> field 'Shifts.swaps_set'. Add a related_name argument to the
> definition for 'origin_shift'.
> turno.swaps: Accessor for field 'origin_user' clashes with related
> field 'User.swaps_set'. Add a related_name argument to the definition
> for 'origin_user'.
> turno.swaps: Accessor for field 'destination_shift' clashes with
> related field 'Shifts.swaps_set'. Add a related_name argument to the
> definition for 'destination_shift'.
> turno.swaps: Accessor for field 'swap_user' clashes with related field
> 'User.swaps_set'. Add a related_name argument to the definition for
> 'swap_user'.
>
> Thanks in advance.
--~--~-~--~~~---~--~~
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: database relationships

2008-08-27 Thread lingrlongr

Try this is the template:

{% for albumart in album.albumart_set.all %}
{{ albumart.image }}
{% endfor %}

On Aug 27, 11:58 am, nek4life <[EMAIL PROTECTED]> wrote:
> Well this works great while using the generic detail view, but when I
> return a list view the relationships won't work.
>
> in my view
>
> def album_list(request, page=0):
>     return list_detail.object_list(
>        request,
>        queryset = Album.objects.select_related().all(),
>        paginate_by = 20,
>        page = page,
>        template_object_name = 'album',
>     )
>
> in my template
>
> {% for albumart in album.albumart_set.all %}
>     {{ album.albumart.image }}
> {% endfor %}
>
> Is this not supported in list_detail.object_list?  I can't find
> information on this anywhere, may have to change my database around.
>
> On Aug 22, 11:44 am, nek4life <[EMAIL PROTECTED]> wrote:
>
> > Awesome.  I got it to work using this code in my view.
>
> > def artist_detail(request, slug):
> >     album_list = Album.objects.all()
> >     return list_detail.object_detail(
> >         request,
> >         queryset = Artist.objects.all(),
> >         slug = slug,
> >         template_object_name = 'artist',
> >         extra_context={'album_list': album_list}
> >     )
>
> > But the way you're doing it only calls the database once instead of
> > twice.  Beautiful!  Thank you.  I'm going to try the query you
> > suggested.
>
> > queryset=Artist.objects.select_related().all()
>
> > I'd like to just pull in the albums, artwork, and tracks related to
> > the particular artist in the url slug, for 
> > instancehttp://www.example.com/artists/artist-name
>
> > You've been a huge help.  Thanks a ton!
>
> > Charlie
>
> > On Aug 22, 11:20 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > Also note, if your intentions were to grab all that information and
> > > just send the artist to the template, I think you'd get better
> > > performance if your queryset in the view looked like this:
>
> > > queryset=Artist.objects.select_related().all()
>
> > > Keith
>
> > > On Aug 22, 11:17 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > Super easy :)  Just to show you another way to implement generic
> > > > views, I used custom view that returns a generic view.
>
> > > > # urls.py
> > > > from myapp.views import artist
> > > > ...
> > > > (r'^artist/(?P\w+)/$', artist),
> > > > ...
>
> > > > #views.py
> > > > from django.views.generic.list_detail import object_detail
> > > > def artist(request, slug):
> > > >     return object_detail(
> > > >         request,
> > > >         queryset=Artist.objects.all(),
> > > >         slug = slug,
> > > >         template_object_name = 'artist'
> > > >     )
>
> > > > # //artist_list.html
> > > > {{ artist }}
> > > > Albums
> > > > 
> > > > {% for album in artist.album_set.all %}
> > > >    {{ album.name }}
> > > >    
> > > >    {% for track in album.track_set.all %}
> > > >      {{ track.name }}
> > > >    {% endfor %}
> > > >    
> > > > {% endfor %}
> > > > 
>
> > > > Django makes traversing relationships easy...
>
> > > > HTH
>
> > > > Keith
>
> > > > On Aug 22, 10:03 am, nek4life <[EMAIL PROTECTED]> wrote:
>
> > > > > So if I sent the artist to the template and wanted to grab the list of
> > > > > albums with all the album tracks how would I go about that.  Would I
> > > > > have to pull in all the data with a custom view?  So far I've only
> > > > > been using generic views.  It definitely makes sense pulling in the
> > > > > information through the track back up through the album to the artist,
> > > > > how could I reverse the process so I can get all the artist vars plus
> > > > > the data I need from the track and album tables?  Thanks a bunch,
> > > > > you've been very helpful already.
>
> > > > > Charlie
>
> > > > > On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > > > One more note.  You wouldn't NEED to explicitly grab all those vars,
> > > > > > as you can get them i

Re: running Django on a very small VPS

2008-08-27 Thread lingrlongr

You could also check out westhost.com.  They offer VPS pretty cheap
too.  I successfully set up Django there a number of times already.  I
usually use the development (SVN) version, but since an svn client
isn't installed there, I just "svn update" locally then FTP the
tarball up there when I want to update.  I have seen some forum posts
out there that discuss setting up an svn client there.  I just haven't
done it yet...  Other than that, works great.


On Aug 27, 4:14 pm, Edwin W <[EMAIL PROTECTED]> wrote:
> I was just wondering whether anyone out there has experience with
> running a Django application on a really small VPS.  I'm using Django
> for small personal projects and experimentation, and I found vpslink
> which has a plan with 2.5 GB of disk space but only 64 MB RAM.  I know
> that it won't work out of the box and that I'll have to do some tuning
> to Apache to get it to work, I found this link which suggests it's
> possible:
>
> http://brizzled.clapper.org/id/73
>
> I also came across this discussion in the group:
>
> http://groups.google.com/group/django-users/browse_thread/thread/19b9...
>
> So am I crazy to try to push the limits this low?  Any additional tips
> would be appreciated as well!
--~--~-~--~~~---~--~~
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: Problems With The Tutorial

2008-08-27 Thread lingrlongr

If manage.py is not in your PATH (it most likely isn't), you need to
qualify the location.  You can just use this command from within your
project directory:

./manage.py runserver

./ means current directory.

HTH

Keith

On Aug 27, 6:42 pm, Sonny <[EMAIL PROTECTED]> wrote:
> When I type ' python manage.py runserver' bash says no file or
> directory found.
> I'm running ubuntu 7.02?
> Thanks for any help you can give.
--~--~-~--~~~---~--~~
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: Dynamic URL

2008-08-27 Thread lingrlongr

Your problem is here:

def category_entry(request, category):
entries_in_cat = Entry.objects.filter(entry_cat=category)
return render_to_response('blog/index.html', locals())

Remember, the value of "category" is a string.  One way or another you
need adjust the filter.  Something like this should do the trick.

entries_in_cat = Entry.objects.filter(entry_cat__name=category)

-or-

thecat = Category.objects.get(cat_name=category)
entries_in_cat = Entry.objects.filter(entry_cat=thecat)

I prefer the first...

HTH

Keith

On Aug 27, 7:45 pm, djandrow <[EMAIL PROTECTED]> wrote:
> I'm trying to create a situation where you can bring up all the blog
> entries in a category through the URL. I've got this in my urls.py:
>
> from django.conf.urls.defaults import *
> from akonline.views import current_datetime
>
> urlpatterns = patterns('',
>
>     (r'^test/$', 'address.blog.views.blog'),
>     (r'^blog/(?P\w+)/$',
> 'address.blog.views.category_entry'),
> )
>
> -
>
> then this is the category_entry in my views:
>
> def category_entry(request, category):
>         entries_in_cat = Entry.objects.filter(entry_cat=category)
>         return render_to_response('blog/index.html', locals())
>
> -
>
> then this is my pretty simple template:
>
> 
> {% for object in entries_in_cat %}
> {{ object.entry_title }} {% endfor %}
> 
>
> -
>
> then these models:
>
> from django.db import models
>
> class Category(models.Model):
>         cat_id = models.AutoField(primary_key=True)
>         cat_name = models.CharField(max_length=20)
>         cat_desc = models.CharField(max_length=200)
>
>         def __unicode__(self):
>                 return self.cat_name
>
> class Entry(models.Model):
>
>         entry_id = models.AutoField(primary_key=True)
>         entry_date = models.DateField(auto_now_add=True)
>         entry_title = models.CharField(max_length=70)
>         entry_content = models.TextField(max_length=5000)
>         entry_cat = models.ManyToManyField(Category)
>
>         def __unicode__(self):
>                 return self.entry_title
>
> -
>
> I don't get an error, its just it returns a blank page, so i'd guess
> either category isn't being read in correctly or the filter statement
> is incorrect. I'd appericiate any help
>
> Thanks,
>
> Andrew
--~--~-~--~~~---~--~~
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: Dynamic URL

2008-08-27 Thread lingrlongr

Also, convention seems to be to spell out the field names.  Because of
a different namespaces, you shouldn't have to worry about too much
name clashing.  And if you don't provide an ID for your model, one is
automatically created for you.  For example:

class Category(models.Model):
name = models.CharField(max_length=20)
description = models.CharField(max_length=200)

def __unicode__(self):
return u'%s' % self.name


On Aug 27, 7:45 pm, djandrow <[EMAIL PROTECTED]> wrote:
> I'm trying to create a situation where you can bring up all the blog
> entries in a category through the URL. I've got this in my urls.py:
>
> from django.conf.urls.defaults import *
> from akonline.views import current_datetime
>
> urlpatterns = patterns('',
>
>     (r'^test/$', 'address.blog.views.blog'),
>     (r'^blog/(?P\w+)/$',
> 'address.blog.views.category_entry'),
> )
>
> -
>
> then this is the category_entry in my views:
>
> def category_entry(request, category):
>         entries_in_cat = Entry.objects.filter(entry_cat=category)
>         return render_to_response('blog/index.html', locals())
>
> -
>
> then this is my pretty simple template:
>
> 
> {% for object in entries_in_cat %}
> {{ object.entry_title }} {% endfor %}
> 
>
> -
>
> then these models:
>
> from django.db import models
>
> class Category(models.Model):
>         cat_id = models.AutoField(primary_key=True)
>         cat_name = models.CharField(max_length=20)
>         cat_desc = models.CharField(max_length=200)
>
>         def __unicode__(self):
>                 return self.cat_name
>
> class Entry(models.Model):
>
>         entry_id = models.AutoField(primary_key=True)
>         entry_date = models.DateField(auto_now_add=True)
>         entry_title = models.CharField(max_length=70)
>         entry_content = models.TextField(max_length=5000)
>         entry_cat = models.ManyToManyField(Category)
>
>         def __unicode__(self):
>                 return self.entry_title
>
> -
>
> I don't get an error, its just it returns a blank page, so i'd guess
> either category isn't being read in correctly or the filter statement
> is incorrect. I'd appericiate any help
>
> Thanks,
>
> Andrew
--~--~-~--~~~---~--~~
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: ModelForm - Required Fields

2008-08-28 Thread lingrlongr

Anyone else ever do anything like this?

On Aug 26, 10:13 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Is there a way for me to quickly make certain fields in a ModelForm
> class required.  I know this looks back to the model for that
> information...
>
> In my case I'm using a FormWizard to display a series of forms.  The
> fields shows in some steps are dependent on answers to previous
> questions.  So, in my model, sometimes a field will be required,
> sometimes not.  Therefore, I'm looking for the form to validate that
> part.
>
> I know I can just list the fields like this:
>
> class MyForm(ModelForm):
>   my_field = forms.CharField(max_length=80, choices=MY_CHOICES,
> required=True)
>   ...etc...
>
> ...but I don't want to have to repeat all the stuff that just
> "happens" automatically...
>
> Keith
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Inconsistencies/Bug in ModelForm

2008-08-28 Thread lingrlongr

Submitted ticket #8663 for the following:

When a ModelForm? is used to display a form for a Model, the fields
defined with a choices option insert a "---" value for the first
option when the form is rendered. If you override a field and manually
specify the choices for a Select widget, this "---" does not
appear as the first choice.

# models.py
from django.db import models

MY_CHOICES = (
  (0, 'Zero'),
  (1, 'One'),
)

class MyModel(models.Model):
  my_field = models.IntegerField(choices=MY_CHOICES)

# forms.py
from django import forms
from myapp.models import MyModel, MY_CHOICES

class MyModelForm(forms.ModelForm):
#my_field =
forms.IntegerField(widget=forms.Select(choices=MY_CHOICES))
class Meta:
model = MyModel

View the HTML for the form with my_field commented out:

>>> from myapp.forms import MyModelForm
>>> f = MyModelForm()
>>> print f
My field:
-
Zero
One


Now uncomment my_field in MyModelForm?:

>>> from myapp.forms import MyModelForm
>>> f = MyModelForm()
>>> print f
My field:
Zero
One


This value doesn't appear in the 2nd case: -

SVN-8643
--~--~-~--~~~---~--~~
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: Inconsistencies/Bug in ModelForm

2008-08-28 Thread lingrlongr

Yes, Malcolm.  You understood it correctly.  I'll probably just add a
quick MY_CHOICES_2 tuple that has these "-" values until I see
what the plan is.

On Aug 28, 9:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-08-28 at 21:32 -0400, Steve Holden wrote:
> > lingrlongr wrote:
> > > Submitted ticket #8663 for the following:
>
> > > When a ModelForm? is used to display a form for a Model, the fields
> > > defined with a choices option insert a "---" value for the first
> > > option when the form is rendered. If you override a field and manually
> > > specify the choices for a Select widget, this "---" does not
> > > appear as the first choice.
>
> > I believe this is by design, to allow you the option of forcing the user
> > to select a specific value.
>
> I understood the original poster's question to be about the difference
> between the auto-generated version and the version when he manually
> specified the field. My first reaction is that he's right and it should
> be the same in both cases (with the "" string), but I need to think
> about it a bit more.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



imports

2008-08-28 Thread lingrlongr

I had all my imports for my apps relative to the app, not the
project.  Since my last SVN checkout this evening, everything on the
site I'm working on is broken.  I would get an error stating (app
after app) that the module app_name.models (etc) could not be found.
The import syntax was:

from app_name.models import MyModel

So when I made them...

from project_name.app_name.models import MyModel

The error would clear and the next import with that style would
fail.

So, I saw some posts relating to gettext this evening, but those were
related to "from xxx.xxx import *" style imports.  So I don't think
that's related...

Another note... this is only when using Apache/mod_python.  If I run
the manage.py runserver from my webhost, the site works with the
original imports I had.

Has something changed?  Nothing popped out at me on the Backwards-
incompatible changes.

Keith
--~--~-~--~~~---~--~~
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: imports

2008-08-29 Thread lingrlongr

Thanks Malcolm.  How do I choose which version I want to use?

I just don't understand it.  Maybe some errors will help...

With DEBUG = True, I don't get any useful information.  So I turn that
off and now I get this traceback:

Traceback (most recent call last):

  File "/usr/local/python/lib/python2.5/site-packages/mod_python/
importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/local/python/lib/python2.5/site-packages/mod_python/
importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)

  File "/usr/local/python/lib/python2.5/site-packages/mod_python/
importer.py", line 1128, in _execute_target
result = object(arg)

  File "/usr/local/python/lib/python2.5/site-packages/django/core/
handlers/modpython.py", line 210, in handler
return ModPythonHandler()(req)

  File "/usr/local/python/lib/python2.5/site-packages/django/core/
handlers/modpython.py", line 183, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 128, in get_response

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 159, in handle_uncaught_exception

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 281, in resolve500

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 270, in _resolve_special

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 261, in _get_urlconf_module

  File "/home/modunique/proj/loan/urls.py", line 7, in 
from loan.amortization.forms import AmortizationForm

  File "/home/modunique/proj/loan/amortization/forms.py", line 3, in

from amortization.models import Amortization

ImportError: No module named amortization.models



Here's the relevant info in my apache conf:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE loan.settings
PythonDebug On
PythonPath "['/home/modunique/proj/'] + sys.path"
PythonInterpreter loan



My project is located in /home/modunique/proj/loan, as suggested by
part of the error above.  The offending import lines in the last two
traceback errors look like:

# /home/modunique/proj/loan/urls.py - line 7
from loan.amortization.forms import AmortizationForm

# /home/modunique/proj/loan/amortization/forms.py - line 3
from amortization.models import Amortization

Now if I change the import line (line 3) to from
loan.amortization.models import Amortization", the error will
disappear, but the next offending import in urls.py then fails.
"forms.py" and "models.py" live in the same module, "amortization".

According to my PYTHON_PATH, these things should be able to be found:
['/home/modunique/proj/', '/usr/local/python/lib/python2.5/site-
packages/MySQL_python-1.2.2-py2.5-linux-i686.egg', '/usr/local/python/
lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg', '/usr/local/
python/lib/python25.zip', '/usr/local/python/lib/python2.5', '/usr/
local/python/lib/python2.5/plat-linux2', '/usr/local/python/lib/
python2.5/lib-tk', '/usr/local/python/lib/python2.5/lib-dynload', '/
usr/local/python/lib/python2.5/site-packages', '/usr/local/python/lib/
python2.5/site-packages/PIL']

And like I said, what's strange is that if I run the development
server @ my web host, it works fine!

Keith




On Aug 29, 12:57 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-08-28 at 21:41 -0700, lingrlongr wrote:
>
> [...]
>
> > Has something changed?  Nothing popped out at me on the Backwards-
> > incompatible changes.
>
> Nothing should have changed that caused this if your code was correct
> earlier.
>
> The best way to work out where the problem is simple to start bisecting
> the subversion checkouts until you find the problem case. You know that
> the current checkout, r8693 is bad. So, suppose r8600 is good. Then try
> r8647 (halfway in between). If that's good, move forwards halfway again,
> otherwise, move back halfway. Keep repeating and you'll eventually hit
> the revision that caused the problem. Even if r8437 was the last good
> revision (256 revisions ago), this will take a maximum of 8 tests to
> find the version that changed things, so it's quite efficient.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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: problem with accessing django from apache2 & mod_python

2008-08-29 Thread lingrlongr

This sounds like the same problem I'm having  I have a post
going here too!
http://groups.google.com/group/django-users/browse_thread/thread/c30b4395f5153cf3/dad6e7a1ebef3175#dad6e7a1ebef3175



On Aug 29, 2:54 pm, Aaron <[EMAIL PROTECTED]> wrote:
> Hi, strange enough, I was having a similar problem as you just awhile
> ago (w/ mod_wsgi).  The cause as I discovered was that if you have an
> app inside your project, you'll have to include the project name
> before any import statements.  So, for your case, chances are, there
> may be references to books.views/books.urls/book.models that were
> suppose to be mysite.book.views/mysite.book.urls/mysite.book.models.
>
> Hope this help.
>
> Aaron
>
> On Aug 29, 4:53 am, cavebird <[EMAIL PROTECTED]> wrote:
>
> > No :(
>
> > I already tried that.
> > same results.
>
> > cavebird
>
> > On Aug 29, 4:47 pm, Aaron <[EMAIL PROTECTED]> wrote:
>
> > > Hi cavebird,
>
> > > Not sure if this has anything to do with the symbolic link, but I
> > > remember having some path issues on mod_python awhile back.  Try
> > > copying mysite inside htdocs and see if that has any effects.
>
> > > Aaron
>
> > > On Aug 29, 4:32 am, cavebird <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
> > > > I have been learning Django and came across thisproblem
> > > > I am trying to access django apps fromapache2but it just wont work :
> > > > (
> > > > Here is what i did:
> > > > added in /usr/local/apache2/conf/extra/httpd-info.conf:
> > > > 
> > > >     SetHandler python-program
> > > >     PythonHandler django.core.handlers.modpython
> > > >     PythonPath "['/usr/local/apache2/htdocs/'] + sys.path"
> > > >     SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> > > >     SetEnv PYTHON_EGG_CACHE "/var/cache/www/pythoneggs"
> > > >     PythonDebug Off
> > > >     PythonAutoReload Off
>
> > > > 
>
> > > > cd /usr/local/apache2/htdocs
> > > > ln -s /home/user/workspace/gui/src/mysite mysite
>
> > > > I started the server.
> > > > it can access url.py because if i give mysite/rubbish it says The
> > > > current URL, /mysite/rubbish/, didn't match any of these.
> > > > it can access functions in mysite.views because mysite/time works
> > > > fine.
> > > > However it cannot access mysite.books.views as even the simplest
> > > > functions returns nothing.
> > > > Meanwhile python manage.py runserver works perfectly fine.
> > > > Please help!!!
> > > > Regards,
> > > > cavebird
--~--~-~--~~~---~--~~
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: imports

2008-08-29 Thread lingrlongr

I can see some differences between the Python Path for the dev server
(manage.py runserver) and apache/mod_python.  I created an error in a
template using an invalid tag so the Django pretty error screen
appears.  Using the development server I see:

Python Path:['/home/django/proj/loan', '/usr/lib/python25.zip', '/
usr/lib/python2.5', etc...

When setting up my apache conf according to the documentation, the
Python path looks like this:

Python Path:['/home/django/proj/', '/usr/lib/python25.zip', '/usr/
lib/python2.5', etc...

If I set the PythonPath in my apache conf like this, ___the site
works_:

PythonPath "['/home/django/proj','/home/django/proj/loan'] + sys.path"

Thoughts?

On Aug 29, 11:51 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Thanks Malcolm.  How do I choose which version I want to use?
>
> I just don't understand it.  Maybe some errors will help...
>
> With DEBUG = True, I don't get any useful information.  So I turn that
> off and now I get this traceback:
>
> Traceback (most recent call last):
>
>   File "/usr/local/python/lib/python2.5/site-packages/mod_python/
> importer.py", line 1537, in HandlerDispatch
>     default=default_handler, arg=req, silent=hlist.silent)
>
>   File "/usr/local/python/lib/python2.5/site-packages/mod_python/
> importer.py", line 1229, in _process_target
>     result = _execute_target(config, req, object, arg)
>
>   File "/usr/local/python/lib/python2.5/site-packages/mod_python/
> importer.py", line 1128, in _execute_target
>     result = object(arg)
>
>   File "/usr/local/python/lib/python2.5/site-packages/django/core/
> handlers/modpython.py", line 210, in handler
>     return ModPythonHandler()(req)
>
>   File "/usr/local/python/lib/python2.5/site-packages/django/core/
> handlers/modpython.py", line 183, in __call__
>     response = self.get_response(request)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 128, in get_response
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 159, in handle_uncaught_exception
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 281, in resolve500
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 270, in _resolve_special
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 261, in _get_urlconf_module
>
>   File "/home/modunique/proj/loan/urls.py", line 7, in 
>     from loan.amortization.forms import AmortizationForm
>
>   File "/home/modunique/proj/loan/amortization/forms.py", line 3, in
> 
>     from amortization.models import Amortization
>
> ImportError: No module named amortization.models
>
> Here's the relevant info in my apache conf:
>
>         
>                 SetHandler python-program
>                 PythonHandler django.core.handlers.modpython
>                 SetEnv DJANGO_SETTINGS_MODULE loan.settings
>                 PythonDebug On
>                 PythonPath "['/home/modunique/proj/'] + sys.path"
>                 PythonInterpreter loan
>         
>
> My project is located in /home/modunique/proj/loan, as suggested by
> part of the error above.  The offending import lines in the last two
> traceback errors look like:
>
> # /home/modunique/proj/loan/urls.py - line 7
> from loan.amortization.forms import AmortizationForm
>
> # /home/modunique/proj/loan/amortization/forms.py - line 3
> from amortization.models import Amortization
>
> Now if I change the import line (line 3) to from
> loan.amortization.models import Amortization", the error will
> disappear, but the next offending import in urls.py then fails.
> "forms.py" and "models.py" live in the same module, "amortization".
>
> According to my PYTHON_PATH, these things should be able to be found:
> ['/home/modunique/proj/', '/usr/local/python/lib/python2.5/site-
> packages/MySQL_python-1.2.2-py2.5-linux-i686.egg', '/usr/local/python/
> lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg', '/usr/local/
> python/lib/python25.zip', '/usr/local/python/lib/python2.5', '/usr/
> local/python/lib/python2.5/plat-linux2', '/usr/local/python/lib/
> python2.5/lib-tk', '/usr/local/python/lib/python2.5/lib-dynload', '/
> usr/local/python/lib/python2.5/site-packages', '/usr/local/python/lib/
> python2.5/site-packages/PIL']
>
> And like I said, wh

Re: imports

2008-08-29 Thread lingrlongr

Thanks Malcolm.  That really cleared things up for me!  Now I can
relax, just a little, for the holiday weekend.  That was really
driving me nuts!


On Aug 29, 6:06 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-08-29 at 15:00 -0700, lingrlongr wrote:
> > I can see some differences between the Python Path for the dev server
> > (manage.py runserver) and apache/mod_python.  I created an error in a
> > template using an invalid tag so the Django pretty error screen
> > appears.  Using the development server I see:
>
> > Python Path:       ['/home/django/proj/loan', '/usr/lib/python25.zip', '/
> > usr/lib/python2.5', etc...
>
> > When setting up my apache conf according to the documentation, the
> > Python path looks like this:
>
> > Python Path:       ['/home/django/proj/', '/usr/lib/python25.zip', '/usr/
> > lib/python2.5', etc...
>
> > If I set the PythonPath in my apache conf like this, ___the site
> > works_:
>
> > PythonPath "['/home/django/proj','/home/django/proj/loan'] + sys.path"
>
> > Thoughts?
>
> Short version: the problems you were seeing are 100% related to this
> problem. Your Python path was incorrect and you started seeing problems.
>
> Longer version...
>
> This is something people really seem to struggle with in Python, but
> it's a very consistent rule: the parent directory of anything you are
> importing must be in the Python search path. So if you are writing
>
>         import foo
>
> and foo is inside the loan/ directory, then loan/ must in the Python
> path. If you are writing
>
>         from loan import foo
>
> then the parent directory of loan/ must be in the Python path. And so
> on. There are some subtleties with things like eggs and .pth files and
> so on, but you can ignore those and not be any worse off.
>
> This is documented in the Django documentation for setting up
> mod_python, but it's not something that is special to Django. It's how
> Python works.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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: How to show up tiny mce in admin textfield

2008-09-03 Thread lingrlongr

You are including the tiny_mce library after you reference it.  Try
switching the order to:

js = (
'/app_media/tiny_mce/tiny_mce.js',
'/app_media/textareas.js',
)

On Sep 3, 10:50 am, bin <[EMAIL PROTECTED]> wrote:
> Hi all
>
> i wanna embed a richtext field in my admin textfield.
> today, i try to use tiny mce. but no matter whatever i did, it didnt
> show up.
>
> i created a directory in my project folder, named appmedia, and copied
> the tiny mce files and textareas.js into it.
> this is my urls.py
>
>     (r'^app_media/(?P.*)$',\
>      'django.views.static.serve',\
>      {'document_root': './appmedia'}),
>
> textareas.js:
> tinyMCE.init({
> mode : “textareas”,
> theme : “advanced”
>
> });
>
> In my models.py:
> class test(models.Model):
>     #Fields
>     class Admin:
>         js = (
>             '/app_media/textareas.js',
>             '/app_media/tiny_mce/tiny_mce.js',
>             )
>
> all this done, nothing changed in my admin test's textfield, i dont
> know why, who could help out...
>
> when i put the url in my 
> explorer:http://localhost:8000/app_media/textareas.js,
> andhttp://localhost:8000/app_media/tiny_mce/tiny_mce.js, it can
> locate the files, i think it's nothing about the urls, so, what's the
> problem.
>
> thank you.
--~--~-~--~~~---~--~~
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: How to show up tiny mce in admin textfield

2008-09-03 Thread lingrlongr

# settings.py
MEDIA_ROOT = '/absolute/path/to/media/directory/'
MEDIA_URL = '/app_media/'

# urls.py (at the end)
import settings
if settings.DEBUG:
urlpatterns += patterns('',
(r'^app_media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)

Given the above, your *.js files should live in:

/absolute/path/to/media/directory/tiny_mce/tiny_mce.js
/absolute/path/to/media/directory/textareas.js

Don't use of the dot (.) for the URL, as in "./app_media/"

keith


On Sep 3, 11:45 am, bin <[EMAIL PROTECTED]> wrote:
> didn't work
>
> what should i fill in my MEDIA_URL in settings.py?
>
> is it like this: MEDIA_URL = './appmedia/'
>
> On 9月3日, 下午11时32分, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > woops try this:
>
> > js = (
> > 'tiny_mce/tiny_mce.js',
> > 'textareas.js',
> > )
>
> > I believe this automatically references the MEDIA_URL, so you don't
> > have to.
>
> > On Sep 3, 11:23 am, bin <[EMAIL PROTECTED]> wrote:
>
> > > I tried, but nothing happened at all.
>
> > > On 9月3日, 下午10时59分, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > > > You are including the tiny_mce library after you reference it.  Try
> > > > switching the order to:
>
> > > > js = (
> > > > '/app_media/tiny_mce/tiny_mce.js',
> > > > '/app_media/textareas.js',
> > > > )
>
> > > > On Sep 3, 10:50 am, bin <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi all
>
> > > > > i wanna embed a richtext field in my admin textfield.
> > > > > today, i try to use tiny mce. but no matter whatever i did, it didnt
> > > > > show up.
>
> > > > > i created a directory in my project folder, named appmedia, and copied
> > > > > the tiny mce files and textareas.js into it.
> > > > > this is my urls.py
>
> > > > > (r'^app_media/(?P.*)$',\
> > > > >  'django.views.static.serve',\
> > > > >  {'document_root': './appmedia'}),
>
> > > > > textareas.js:
> > > > > tinyMCE.init({
> > > > > mode : "textareas",
> > > > > theme : "advanced"
>
> > > > > });
>
> > > > > In my models.py:
> > > > > class test(models.Model):
> > > > > #Fields
> > > > > class Admin:
> > > > > js = (
> > > > > '/app_media/textareas.js',
> > > > > '/app_media/tiny_mce/tiny_mce.js',
> > > > > )
>
> > > > > all this done, nothing changed in my admin test's textfield, i dont
> > > > > know why, who could help out...
>
> > > > > when i put the url in my 
> > > > > explorer:http://localhost:8000/app_media/textareas.js,
> > > > > andhttp://localhost:8000/app_media/tiny_mce/tiny_mce.js, it can
> > > > > locate the files, i think it's nothing about the urls, so, what's the
> > > > > problem.
>
> > > > > thank you.
--~--~-~--~~~---~--~~
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: How to show up tiny mce in admin textfield

2008-09-03 Thread lingrlongr

woops try this:

js = (
'tiny_mce/tiny_mce.js',
'textareas.js',
)

I believe this automatically references the MEDIA_URL, so you don't
have to.



On Sep 3, 11:23 am, bin <[EMAIL PROTECTED]> wrote:
> I tried, but nothing happened at all.
>
> On 9月3日, 下午10时59分, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > You are including the tiny_mce library after you reference it.  Try
> > switching the order to:
>
> > js = (
> > '/app_media/tiny_mce/tiny_mce.js',
> > '/app_media/textareas.js',
> > )
>
> > On Sep 3, 10:50 am, bin <[EMAIL PROTECTED]> wrote:
>
> > > Hi all
>
> > > i wanna embed a richtext field in my admin textfield.
> > > today, i try to use tiny mce. but no matter whatever i did, it didnt
> > > show up.
>
> > > i created a directory in my project folder, named appmedia, and copied
> > > the tiny mce files and textareas.js into it.
> > > this is my urls.py
>
> > > (r'^app_media/(?P.*)$',\
> > >  'django.views.static.serve',\
> > >  {'document_root': './appmedia'}),
>
> > > textareas.js:
> > > tinyMCE.init({
> > > mode : "textareas",
> > > theme : "advanced"
>
> > > });
>
> > > In my models.py:
> > > class test(models.Model):
> > > #Fields
> > > class Admin:
> > > js = (
> > > '/app_media/textareas.js',
> > > '/app_media/tiny_mce/tiny_mce.js',
> > > )
>
> > > all this done, nothing changed in my admin test's textfield, i dont
> > > know why, who could help out...
>
> > > when i put the url in my 
> > > explorer:http://localhost:8000/app_media/textareas.js,
> > > andhttp://localhost:8000/app_media/tiny_mce/tiny_mce.js, it can
> > > locate the files, i think it's nothing about the urls, so, what's the
> > > problem.
>
> > > thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Form Wizard

2008-09-03 Thread lingrlongr

I'm desperate here.  I'm having serious problems with the form
wizard.

In url.py I have:

url(r'refinance/$', RefinanceWizard([RefinanceForm_1,
RefinanceForm_2, DummyForm, DummyForm]), name='refinance'),

So you can see that I have 4 steps.  The purpose of the DummyForm is
just a place holder.  They will be substituted depending on responses
within earlier steps.  So here's the process_step code for the wizard:

def process_step(self, request, form, step):
if isinstance(form, RefinanceForm_2) and
form.__dict__.has_key('cleaned_data'):
if form.cleaned_data['other_investments'] == 'Y':
self.form_list[2] = RefinanceForm_3_yes
else:
self.form_list[2] = RefinanceForm_3_no

if isinstance(form, (RefinanceForm_3_yes, RefinanceForm_3_no))
and form.__dict__.has_key('cleaned_data'):
if form.cleaned_data['mortgage_count'] == '1' or
form.cleaned_data['mortgage_count'] == 1:
self.form_list[3] = RefinanceForm_4_1
else:
self.form_list[3] = RefinanceForm_4_2

So, some notes...  I am using "Y/N" to represent bool values, because
that was broken a few weeks ago and I don't know if I should switch
back to bool values yet (should I - do they work now!?!)

Now the cleaned_data...  You'll notice that I test for a string and an
integer.  I found that using an integer ( = 1 instead of  =
'1') was NEVER triggered so I always went  to the else and
RefinanceForm_4_2 was added.

I thought one of the points of cleaned_data is that the value gets
normalized back to the proper data type.  If this field is an
IntegerField in my model/form, which it is, this should be an integer
when I access the value in cleaned_data.  Correct?

So, the problems I am seeing, which happen very sporadically, are:

1.  When step 4 is submitted (the last step), I get an traceback
telling me DummyForm has no save method, mind you, everything up to
and including the last step seemed to have worked fine and I already
substituted all the dummy forms with the proper ones.

2.  When I submit RefinanceForm_3, and look at the value of
mortgage_count, I'll often get a blank RefinanceForm_4, which I'm
assuming is the DummyForm that is actually being shown.  This will
also happen on occasion where RefinanceForm_3 is not displayed and the
DummyForm does.

Its to the point where I document every value I enter, for ~40 fields,
and try to recreate the problem.  Sometimes it works and sometimes it
doesn't.  I don't know where its failing - maybe the hashing and
validating stuff in the wizard??  No exceptions are getting raised...

I'm not even sure I'm using the process_step function correctly, as
there's no samples in the documentation...

Suggestions?

Keith
--~--~-~--~~~---~--~~
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: settings.TIME_ZONE

2008-09-03 Thread lingrlongr

It turns out its my stupid host that's not handling the dates
properly.  I wrote a Python script and tested:

#! /usr/bin/env python

import os
import datetime

def do_test(tz):
   if tz != '':
  os.environ['TZ'] = tz
   print '%20s:  %s' % (tz, datetime.datetime.today())

[do_test(tz) for tz in ('', 'America/New_York', 'America/Denver')]

This outputs:

:  2008-09-03 17:28:43.784919
America/New_York:  2008-09-03 23:28:43.784996
America/Denver:  2008-09-03 23:28:43.785047

As you can see, it don't workee.  I then discovered the timezone "EST
+05EDT,M4.1.0,M10.5.0", here: http://docs.python.org/lib/module-time.html
and gave that a try.  Here's the output now correctly showing 2 hours
difference:

:  2008-09-03 17:32:54.726285
America/New_York:  2008-09-03 23:32:54.726363
America/Denver:  2008-09-03 23:32:54.726409
EST+05EDT,M4.1.0,M10.5.0:  2008-09-03 19:32:54.726451

So if there's any Westhosters out there, you'll benefit from this.


On Aug 25, 11:30 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Here's more info:
>
> $ ./manage.py shell
> Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)>>> from datetime import datetime
> >>> datetime.today()
>
> datetime.datetime(2008, 8, 26, 3, 25, 47, 588753)
>
> $ python
> Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> from datetime import datetime
> >>> datetime.today()
>
> datetime.datetime(2008, 8, 25, 21, 26, 21, 383524)
>
> Keith
>
> On Aug 25, 11:11 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > I'm a little confused about theTIME_ZONEsetting in settings.py.  I
> > originally had it set to 'America/New_York', because that's the time
> > zone where I'm located, but I noticed the times were ~4 hours off when
> > I would save an object that had a DateTimeField(auto_now_add=True)
> > field in the model.  Instead I tried to set theTIME_ZONEvalue to
> > where the web server was, Utah, so I used 'America/Denver'.
>
> > I saved an object while configured for Denver, timestamp was for
> > 2:40am.  I changed the setting back to New_York and saved another
> > object, the the timestamp was for 2:52am.  Local time for me was
> > ~10pm.
>
> > Python 2.5 (r25:51908, Mar 23 2007, 14:22:20)
> > [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.>>> 
> > import datetime
> > >>> datetime.datetime.today()
>
> > datetime.datetime(2008, 8, 25, 21, 9, 15, 497672)
>
> > $ date
> > Mon Aug 25 21:09:45 MDT 2008
>
> > I would like the times to shown as Eastern Time zone.  What should I
> > set theTIME_ZONEsetting to?
>
> > Keith
--~--~-~--~~~---~--~~
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: Form Wizard

2008-09-03 Thread lingrlongr

Maybe I'm experiencing this?
http://code.djangoproject.com/ticket/8808

I don't even understand what that ticket is about.  And I'm not using
parse_params or get_template...



On Sep 3, 4:06 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I'm desperate here.  I'm having serious problems with the form
> wizard.
>
> In url.py I have:
>
>     url(r'refinance/$', RefinanceWizard([RefinanceForm_1,
> RefinanceForm_2, DummyForm, DummyForm]), name='refinance'),
>
> So you can see that I have 4 steps.  The purpose of the DummyForm is
> just a place holder.  They will be substituted depending on responses
> within earlier steps.  So here's the process_step code for the wizard:
>
>     def process_step(self, request, form, step):
>         if isinstance(form, RefinanceForm_2) and
> form.__dict__.has_key('cleaned_data'):
>             if form.cleaned_data['other_investments'] == 'Y':
>                 self.form_list[2] = RefinanceForm_3_yes
>             else:
>                 self.form_list[2] = RefinanceForm_3_no
>
>         if isinstance(form, (RefinanceForm_3_yes, RefinanceForm_3_no))
> and form.__dict__.has_key('cleaned_data'):
>             if form.cleaned_data['mortgage_count'] == '1' or
> form.cleaned_data['mortgage_count'] == 1:
>                 self.form_list[3] = RefinanceForm_4_1
>             else:
>                 self.form_list[3] = RefinanceForm_4_2
>
> So, some notes...  I am using "Y/N" to represent bool values, because
> that was broken a few weeks ago and I don't know if I should switch
> back to bool values yet (should I - do they work now!?!)
>
> Now the cleaned_data...  You'll notice that I test for a string and an
> integer.  I found that using an integer ( = 1 instead of  =
> '1') was NEVER triggered so I always went  to the else and
> RefinanceForm_4_2 was added.
>
> I thought one of the points of cleaned_data is that the value gets
> normalized back to the proper data type.  If this field is an
> IntegerField in my model/form, which it is, this should be an integer
> when I access the value in cleaned_data.  Correct?
>
> So, the problems I am seeing, which happen very sporadically, are:
>
> 1.  When step 4 is submitted (the last step), I get an traceback
> telling me DummyForm has no save method, mind you, everything up to
> and including the last step seemed to have worked fine and I already
> substituted all the dummy forms with the proper ones.
>
> 2.  When I submit RefinanceForm_3, and look at the value of
> mortgage_count, I'll often get a blank RefinanceForm_4, which I'm
> assuming is the DummyForm that is actually being shown.  This will
> also happen on occasion where RefinanceForm_3 is not displayed and the
> DummyForm does.
>
> Its to the point where I document every value I enter, for ~40 fields,
> and try to recreate the problem.  Sometimes it works and sometimes it
> doesn't.  I don't know where its failing - maybe the hashing and
> validating stuff in the wizard??  No exceptions are getting raised...
>
> I'm not even sure I'm using the process_step function correctly, as
> there's no samples in the documentation...
>
> Suggestions?
>
> Keith
--~--~-~--~~~---~--~~
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: View not passing MEDIA_URL to Template

2008-09-04 Thread lingrlongr

Take a look here: 
http://www.djangoproject.com/documentation/shortcuts/#render-to-response

keith

On Sep 4, 2:44 pm, Cortland Klein <[EMAIL PROTECTED]> wrote:
> I have two templates, one called via a Generic View and one via my own  
> View. They both extend a base.html view that has {{MEDIA_URL}} in it.
>
> When the generic view is hit, the base.html template gets it's 
> value,http://rtdev.apple.com/media/
>   , but when my own View hits MEDIA_URL blanks.
>
> I tried to get MEDIA_URL in my views.py to pass it in to my  
> render_to_response but it seems from there that global isn't defined.
>
> views.py:
>
> > from django.shortcuts import render_to_response, get_object_or_404
>
> > from models import Event
>
> > def results(request):
> >    event = get_object_or_404(Event, pk=request.REQUEST['event'])
> >    response = {}
> >    response['correct_answers'] = 0
> >    response['total_questions'] = 0
> >    response['passed'] = 0
> >    response['name'] = request.REQUEST['name']
>
> >    # ...
>
> >    return render_to_response('whatsnew/results.html', response)
>
> --
> Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791http://pixelcort.com/
> 2260 California Street #13
> Mountain View, CA, USA 94040
>
> Alumni, Business Management <[EMAIL PROTECTED]>
> San José State University
>
> Alumni Technical Advisor, Entrepreneurial Society <[EMAIL PROTECTED]
>  >http://e-society.org/
>
> Q&A Techie, Silicon Valley Mac User Grouphttp://svmug.org/
>
> Member, Silicon Valley Google Technology User Grouphttp://sv-gtug.org/
--~--~-~--~~~---~--~~
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: How to use generic view direct_to_template with extra_context

2008-09-08 Thread lingrlongr

slight change...

(r'^about/$', 'django.views.generic.simple.direct_to_template', {
  'template': 'main.html',
  'extra_context': {
'about': True,
  }
}),

On Sep 8, 3:44 pm, "Abdallah El Guindy" <[EMAIL PROTECTED]>
wrote:
> Hey all,
>
> I want to use the generic view direct_to_template and to pass to it extra
> parameters in the urls.py
>
> I tried doing the following but doesn't work
>
> (r'^about/$', 'django.views.generic.simple.direct_to_template', {'template':
> 'main.html'}, extra_context={'about': True}),
>
> What am I missing?
>
> Thanks
--~--~-~--~~~---~--~~
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: Unittest for Formwizard

2008-09-11 Thread lingrlongr

The Formwizard gave me MANY problems.  What exactly is happening?
Here's what I was experiencing:
http://groups.google.com/group/django-users/browse_thread/thread/764ddb2d1b5d92d8/7ae5c2633564bd49#7ae5c2633564bd49

keith

On Sep 11, 4:46 am, David Reynolds <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I am attempting to write a unit test for a Formwizard, but I can't
> seem to make it work.  Has anyone else attempted this or does anyone
> have any pointers?
>
> I think the problem might be the hash not matching, between the steps.
>
> --
> David Reynolds
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ImageField

2008-09-11 Thread lingrlongr

Can someone explain how to use the height_field and width_field for an
ImageField as it would relate to this model:

class ProductImage(models.Model):
  image = models.ImageField(upload_to='images')

The explanation in the documentation is:
Name of a model field which will be auto-populated with the height of
the image each time the model instance is saved.

I don't think that's 100% clear.  At least to me its not.  I tried
this:

class ProductImage(models.Model):
  height = models.IntegerField()
  width = models.IntegerField()
  image = models.ImageField(upload_to='images', height_field=height,
width_field=width)

Must I do anything else specific with my model or am I way off?
--~--~-~--~~~---~--~~
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: ImageField

2008-09-11 Thread lingrlongr

Ah, I figured it out.

class ProductImage(models.Model):
  image = models.ImageField(upload_to='images', height_field='height',
width_field='width')

Example:
>>> p = ProductImage.objects.all()[0]
>>> p.image.height
250
>>> p.image.width
100



On Sep 12, 12:06 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Can someone explain how to use theheight_fieldand width_field for an
> ImageField as it would relate to this model:
>
> class ProductImage(models.Model):
>   image = models.ImageField(upload_to='images')
>
> The explanation in the documentation is:
> Name of a model field which will be auto-populated with the height of
> the image each time the model instance is saved.
>
> I don't think that's 100% clear.  At least to me its not.  I tried
> this:
>
> class ProductImage(models.Model):
>   height = models.IntegerField()
>   width = models.IntegerField()
>   image = models.ImageField(upload_to='images',height_field=height,
> width_field=width)
>
> Must I do anything else specific with my model or am I way off?
--~--~-~--~~~---~--~~
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: ***SPAM*** A trick to force autoreloading, in case of changes in views.py

2008-09-14 Thread lingrlongr

Are we still on this!?!?  There are SPAM filters (like Spam Assassin)
that automatically add this in the subject if it this an email is
SPAM.  Relax!

On Sep 14, 9:19 pm, n00m <[EMAIL PROTECTED]> wrote:
> Next time you open your own thread
> let me know:
> I'll mark it as ***SPAM***
> and we'll see how tolerant *you* are.
>
> On Sep 15, 1:47 am, Martin Diers <[EMAIL PROTECTED]> wrote:
>
> > Chill out. It's a personal website - no product being sold or  
> > advertised.
>
> > If this group were moderated, you would no doubt be bounced for that  
> > comment. If you treat others here with such disdain, do not expect to  
> > be treated any better.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



django + apache + ssl

2008-09-17 Thread lingrlongr

I can't view my site over ssl.  If I go to http://www.mysite.com, the
site works.  If I go to https://www.mysite.com, I get a secure
connection, but my django app isn't get served, but rather /var/www/
index.html is.  Here's my apache config for mysite:


ServerName mysite.com
ServerAlias www.mysite.com

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug Off
PythonPath "['/home/django/django-projects/', '/home/django/
django-projects/mysite/'] + sys.path"
PythonInterpreter ssl_mysite




ServerName mysite.com
ServerAlias www.mysite.com

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug Off
PythonPath "['/home/django/django-projects/', '/home/django/
django-projects/mysite/'] + sys.path"
PythonInterpreter mysite



keith
--~--~-~--~~~---~--~~
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 + apache + ssl

2008-09-17 Thread lingrlongr

Hmmm   I played around a bit more.  I don't think this is a Django
problem.  I reduced the virtual host entry to:


ServerName mysite.com
ServerAliaswww.mysite.com
DocumentRoot "/home/django/test"


That fails too.  If I change that port to 80, it works.  Must be
something my host has set up somewhere in the config...

keith

On Sep 17, 10:34 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> I can't view my site over ssl.  If I go tohttp://www.mysite.com, the
> site works.  If I go tohttps://www.mysite.com, I get a secure
> connection, but my django app isn't get served, but rather /var/www/
> index.html is.  Here's my apache config for mysite:
>
> 
>     ServerName mysite.com
>     ServerAliaswww.mysite.com
>     
>         SetHandler python-program
>         PythonHandler django.core.handlers.modpython
>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>         PythonDebug Off
>         PythonPath "['/home/django/django-projects/', '/home/django/
> django-projects/mysite/'] + sys.path"
>         PythonInterpreter ssl_mysite
>     
> 
>
> 
>     ServerName mysite.com
>     ServerAliaswww.mysite.com
>     
>         SetHandler python-program
>         PythonHandler django.core.handlers.modpython
>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>         PythonDebug Off
>         PythonPath "['/home/django/django-projects/', '/home/django/
> django-projects/mysite/'] + sys.path"
>         PythonInterpreter mysite
>     
> 
>
> keith
--~--~-~--~~~---~--~~
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 + apache + ssl

2008-09-17 Thread lingrlongr

It turns out that it was because i have multiple domains hosted at
this current location.  The ssl.conf file for Apache was configured
for one of the other domains.  One I configured that file for the
domain I wanted it for, and moved the VirtualHost stuff from
httpd.conf to ssl.conf, it worked.

Steve... probably not the place for this, but since you seem to know
about (and maybe someone else will benefit from this one day)...  So
if I want to get an SSL cert for one of those other domains down the
road, I HAVE to get another web hosting account?  I notice that in the
ssl.conf file, the virtual hosts were defined with IPs:



... as opposed to httpd.conf where they are defined as:



You can't set up the virtual host in ssl.conf using a wildcard?

keith

On Sep 17, 7:20 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Note that you can only have one SSL server on an IP address: you can't
> have multiple virtual hosts running SSL because the connection has to be
> established (using the server's identity) before the Host: header can be
> read.
>
> I run the SSL server on my private server as a Virtual Host. This involves
>
>         SSLEngine On
>         SSLCertificateFile /etc/apache2/holdenweb.com.crt
>         SSLCertificateKeyFile /etc/apache2/holdenweb.com.key
>
> regards
>  Steve
>
> lingrlongr wrote:
> > Hmmm   I played around a bit more.  I don't think this is a Django
> > problem.  I reduced the virtual host entry to:
>
> > 
> >     ServerName mysite.com
> >     ServerAliaswww.mysite.com
> >     DocumentRoot "/home/django/test"
> > 
>
> > That fails too.  If I change that port to 80, it works.  Must be
> > something my host has set up somewhere in the config...
>
> > keith
>
> > On Sep 17, 10:34 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> >> I can't view my site over ssl.  If I go tohttp://www.mysite.com, the
> >> site works.  If I go tohttps://www.mysite.com, I get a secure
> >> connection, but my django app isn't get served, but rather /var/www/
> >> index.html is.  Here's my apache config for mysite:
>
> >> 
> >>     ServerName mysite.com
> >>     ServerAliaswww.mysite.com
> >>     
> >>         SetHandler python-program
> >>         PythonHandler django.core.handlers.modpython
> >>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> >>         PythonDebug Off
> >>         PythonPath "['/home/django/django-projects/', '/home/django/
> >> django-projects/mysite/'] + sys.path"
> >>         PythonInterpreter ssl_mysite
> >>     
> >> 
>
> >> 
> >>     ServerName mysite.com
> >>     ServerAliaswww.mysite.com
> >>     
> >>         SetHandler python-program
> >>         PythonHandler django.core.handlers.modpython
> >>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> >>         PythonDebug Off
> >>         PythonPath "['/home/django/django-projects/', '/home/django/
> >> django-projects/mysite/'] + sys.path"
> >>         PythonInterpreter mysite
> >>     
> >> 
>
> >> keith
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ImageField: upload_to

2008-09-18 Thread lingrlongr

According to the documentation, I can make the upload_to argument a
callable (which must receive 2 args):

class Product(models.Model):
number = models.CharField(max_length=20)
image = models.ImageField(upload_to='')

I want to build a path so it looks like this (with respect to
MEDIA_URL):
  images/products//

def get_image_path(instance, filename):
  return 'images/products/%s/%s' % (instance.number, filename)

I tried:
  upload_to='get_image_path'
  upload_to=get_image_path
  upload_to=get_image_path()
  upload_to=self.get_image_path

How can I accomplish that?
--~--~-~--~~~---~--~~
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: ImageField: upload_to

2008-09-18 Thread lingrlongr

worked like a charm.  thx.

On Sep 18, 5:21 pm, gnijholt <[EMAIL PROTECTED]> wrote:
> I had to define the callable function before it gets called.
> So in your case I'd put it right under class Product(models.model)
> Then you should be able to just do:
>   upload_to=get_image_path
>
> Cheers,
>
> On Sep 18, 10:20 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > According to the documentation, I can make the upload_to argument a
> > callable (which must receive 2 args):
>
> > class Product(models.Model):
> >     number = models.CharField(max_length=20)
> >     image = models.ImageField(upload_to='')
>
> > I want to build a path so it looks like this (with respect to
> > MEDIA_URL):
> >   images/products//
>
> > def get_image_path(instance, filename):
> >   return 'images/products/%s/%s' % (instance.number, filename)
>
> > I tried:
> >   upload_to='get_image_path'
> >   upload_to=get_image_path
> >   upload_to=get_image_path()
> >   upload_to=self.get_image_path
>
> > How can I accomplish that?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



IE Hell. Blank Page

2008-09-18 Thread lingrlongr

Strangest thing...

I primarily use and develop on Ubuntu and use Firefox.  So I went to
check out how many bugs IE was generous enough to give me to fix.
Using the Django development server, I can connect fine from a Windows
computer and view the site using Firefox.  When I use IE (tested 6 &
7), I get a blank page.  However I can view the source and see all the
HTML is there!  My connections to the development server were either
on the local network or over an SSH tunnel.

Anyone ever experience this?  Any chance its related to the Django
development server?
--~--~-~--~~~---~--~~
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: IE Hell. Blank Page

2008-09-18 Thread lingrlongr

Thank you both.  There WAS something I forgot in the .  I got so
absorbed in making the the  section its own block that I forgot
to close the tag.

On Sep 18, 7:13 pm, "Daniele Procida" <[EMAIL PROTECTED]>
wrote:
> On Thu, Sep 18, 2008, lingrlongr <[EMAIL PROTECTED]> wrote:
> >I primarily use and develop on Ubuntu and use Firefox.  So I went to
> >check out how many bugs IE was generous enough to give me to fix.
> >Using the Django development server, I can connect fine from a Windows
> >computer and view the site using Firefox.  When I use IE (tested 6 &
> >7), I get a blank page.  However I can view the source and see all the
> >HTML is there!  My connections to the development server were either
> >on the local network or over an SSH tunnel.
>
> What happens if you turn all the stylesheets off?
>
> Also, there are circumstances under which IE would render a blank page
> from XML - but I presume you're not serving up XML. But I think that
> other issues with similar consequnces arise when sending XHTML as XML.
>
> See <http://www.w3.org/MarkUp/2004/xhtml-faq#ie>. Are you sending XHTML 1.1?
>
> Does the page  appear in the browser window? If so, then it's
> parsing at least some of your code.
>
> Finally, have you run your code through the W3's validator:  validator.w3.org/>? Yes, I know it's very funny that IE should baulk at
> invalid code...
>
> Daniele
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



SlugField & prepopulate_from

2008-09-30 Thread lingrlongr

Before the new forms and admin came, I could've sworn that the
prepopulate_from (now prepopulated_fields) stuff worked when creating
a new object in the admin, __AND__ when you edit an existing object.

Can someone confirm if this should work for editing objects too?
Currently, it does not.

Keith
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



TabularInline Template

2008-10-01 Thread lingrlongr

I want to show a formset as just text in a table in the admin.  So I'm
trying to override the tabular.html template.  How can I just extract
the value of the field, instead of showing the widget.  Here's that
particular part of the template:

{% for fieldset in inline_admin_form %}
  {% for line in fieldset %}
{% for field in line %}
  
  {{ field.field.errors.as_ul }}
  {{ field.field }}
  
{% endfor %}
  {% endfor %}
{% endfor %}

In particular, its the {{ field.field }} part that draws the widget.
I tried {{ field.field.data }} but that just outputs "None".

Is this the wrong way to handle this?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



current user

2008-10-14 Thread lingrlongr

What's the best way to always set a User foreign key to the current
user using the admin site?  For example:

# models.py
class MyModel(models.Model):
my_data = models.CharField(max_length=50)
user = models.ForeignKey(User)

When this was saved/updated in the admin, "user" should always equal
the person saving/updating the object.  I'd also like for the user
field to not even show up...

thx.

keith
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



CheckBoxInput widget: check_test

2010-08-06 Thread lingrlongr
Having difficulty getting the check_test to work.  Can't find any
examples out there that help.  I'll probably have to give a little
background.  I simplified where able to...

class Cat:
  name = CharField

class Category:
  name = ForeignKey(Cat)
  weight = DecimalField
  item = ForeignKey('Item')

class Item:
  name = CharField

Basically Cat is a model of all categories and Category is a model of
which Cat's are assigned to an item.  I did it this way because I want
to have a "master list" of categories, then have the mapping done in
other models.

So now I want to build a form at run-time.

def get_form(item):
  fields = dict()
  cat_choices = [(c.id, c.name) for c in Cat.objects.all()]
  for c in cat_choices:
id, name = c
checked = bool(item.categoty_set.filter(pk=id).count())

fields['item_cat_%d' % id] = forms.ChoiceField(
  label = name,
  required = False,
  choices = cat_choices,
  widget = forms.CheckboxInput(
attrs={'value': checked},
check_test = lambda a: a == checked
  )
)
return type('CatSelectForm', (forms.BaseForm,), {'base_fields':
fields})

So how can I get the correct checkboxes checked at runtime when the
template is rendered?

Thx.

-- 
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: CheckBoxInput widget: check_test

2010-08-06 Thread lingrlongr
Forgo the most important part.  I want to be prompted with a
checkboxes that show which categories are selected, as well as the
ones that aren't.

On Aug 6, 2:13 pm, lingrlongr  wrote:
> Having difficulty getting the check_test to work.  Can't find any
> examples out there that help.  I'll probably have to give a little
> background.  I simplified where able to...
>
> class Cat:
>   name = CharField
>
> class Category:
>   name = ForeignKey(Cat)
>   weight = DecimalField
>   item = ForeignKey('Item')
>
> class Item:
>   name = CharField
>
> Basically Cat is a model of all categories and Category is a model of
> which Cat's are assigned to an item.  I did it this way because I want
> to have a "master list" of categories, then have the mapping done in
> other models.
>
> So now I want to build a form at run-time.
>
> def get_form(item):
>   fields = dict()
>   cat_choices = [(c.id, c.name) for c in Cat.objects.all()]
>   for c in cat_choices:
>     id, name = c
>     checked = bool(item.categoty_set.filter(pk=id).count())
>
>     fields['item_cat_%d' % id] = forms.ChoiceField(
>       label = name,
>       required = False,
>       choices = cat_choices,
>       widget = forms.CheckboxInput(
>         attrs={'value': checked},
>         check_test = lambda a: a == checked
>       )
>     )
>     return type('CatSelectForm', (forms.BaseForm,), {'base_fields':
> fields})
>
> So how can I get the correct checkboxes checked at runtime when the
> template is rendered?
>
> Thx.

-- 
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: CheckBoxInput widget: check_test

2010-08-06 Thread lingrlongr
@Bill

Thanks.  I just stumbled across that widget.  I know models.Model
weren't there, I was trying to simplify thinking we'd all know they
were there.  I guess, never assume ;)

Looks like I don't even have to worry about that check_test field
after all.  Using initial worked perfectly.

def get_form(item):
fields = {}
choices = [(c.id, c.name) for c in Cat.objects.all()]
selections = [c.name.id for c in item.category_set.all()]
fields['cat'] = forms.MultipleChoiceField(
label=item,
required=False,
choices = choices,
initial=selections,
widget = forms.CheckboxSelectMultiple()
)
return type('CatForm', (forms.BaseForm,), {'base_fields': fields})
()




On Aug 6, 3:09 pm, Bill Freeman  wrote:
> There is a CheckBoxSelectMultiple widget in django.forms, suitable
> for use with a forms.ModelMultipeChoiceField, and probably with
> other stuff.    Doesn't it do what you need?  Or are you just reinventing
> the wheel.
>
> And, of course, your code as shown doesn't work because Cat and
> Category are not based on django.db.models.Model .
>
> On Fri, Aug 6, 2010 at 2:41 PM, lingrlongr  wrote:
> > Forgo the most important part.  I want to be prompted with a
> > checkboxes that show which categories are selected, as well as the
> > ones that aren't.
>
> > On Aug 6, 2:13 pm, lingrlongr  wrote:
> >> Having difficulty getting the check_test to work.  Can't find any
> >> examples out there that help.  I'll probably have to give a little
> >> background.  I simplified where able to...
>
> >> class Cat:
> >>   name = CharField
>
> >> class Category:
> >>   name = ForeignKey(Cat)
> >>   weight = DecimalField
> >>   item = ForeignKey('Item')
>
> >> class Item:
> >>   name = CharField
>
> >> Basically Cat is a model of all categories and Category is a model of
> >> which Cat's are assigned to an item.  I did it this way because I want
> >> to have a "master list" of categories, then have the mapping done in
> >> other models.
>
> >> So now I want to build a form at run-time.
>
> >> def get_form(item):
> >>   fields = dict()
> >>   cat_choices = [(c.id, c.name) for c in Cat.objects.all()]
> >>   for c in cat_choices:
> >>     id, name = c
> >>     checked = bool(item.categoty_set.filter(pk=id).count())
>
> >>     fields['item_cat_%d' % id] = forms.ChoiceField(
> >>       label = name,
> >>       required = False,
> >>       choices = cat_choices,
> >>       widget = forms.CheckboxInput(
> >>         attrs={'value': checked},
> >>         check_test = lambda a: a == checked
> >>       )
> >>     )
> >>     return type('CatSelectForm', (forms.BaseForm,), {'base_fields':
> >> fields})
>
> >> So how can I get the correct checkboxes checked at runtime when the
> >> template is rendered?
>
> >> Thx.
>
> > --
> > 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 
> > athttp://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.



dynamic forms and custom methods

2010-08-10 Thread lingrlongr
I 'm trying to create a form dynamically.  This works just fine, but
there's no way for the form to offer any customized validation, by way
of the clean() method.

def get_dept_weight_form(store):
fields = {}
s = Store.objects.get(pk=store.id)
for d in store.department_set.all():
fields['id_%d' % d.id] = forms.DecimalField(
label = d.name,
initial = d.weight
)
return type('WeightForm', (forms.BaseForm,), {'base_fields':
fields})

Basically, this form spits out a label showing the department name and
the weight for you to enter in a textbox.  The weights for all
departments should total 1.0.  Should a clean() method handle this?

I already use an overridden version of save() on the store model, but
that just prints out a warning to stdout.  Also, I have this
validation for the admin part by overriding the clean method for my
declared ModelForm.

Perhaps I should just use the functionality I already created in
models.py and just raise a ValidationError?

Thx

-- 
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: dynamic forms and custom methods

2010-08-12 Thread lingrlongr
Hi Nick,

Thanks for the reply.  Yes, the department weights will be used in a
grading scheme.  One department may be 25% (0.25), etc...  But in the
end, the weights should total 1.0.  For example, in my Store model:

class Store(models.Model):
  #...etc...

  def _get_total_dept_weight(self):
return self.department_set.all().aggregate(Sum('weight'))
['weight_sum']

  def save(self, *args, **kwargs):
if self._get_total_dept_weight() <> Decimal('1.0'):
  # fail
super(Store, self).save(*args, **kwargs)

So in the case of my custom form, I was thinking about raising a
validation error if the totals submitted in the form don't total 1.0.
But I was thinking over the weekend, maybe this isn't the best place
for it after all. Maybe it should stay in the model because why does
the form care if the weights is 1.0?  The model does...  Perhaps
instead, raise a ValidationError exception from the Store's save()
method?

What are your thoughts?

On Aug 11, 3:58 pm, Nick  wrote:
> Are you trying to create a save function that evaluates all the
> weights and returns an error if they are more than 1?
>
> On Aug 10, 3:17 pm, lingrlongr  wrote:
>
> > I 'm trying to create a form dynamically.  This works just fine, but
> > there's no way for the form to offer any customized validation, by way
> > of the clean() method.
>
> > def get_dept_weight_form(store):
> >     fields = {}
> >     s = Store.objects.get(pk=store.id)
> >     for d in store.department_set.all():
> >         fields['id_%d' % d.id] = forms.DecimalField(
> >             label = d.name,
> >             initial = d.weight
> >         )
> >     return type('WeightForm', (forms.BaseForm,), {'base_fields':
> > fields})
>
> > Basically, this form spits out a label showing the department name and
> > the weight for you to enter in a textbox.  The weights for all
> > departments should total 1.0.  Should a clean() method handle this?
>
> > I already use an overridden version of save() on the store model, but
> > that just prints out a warning to stdout.  Also, I have this
> > validation for the admin part by overriding the clean method for my
> > declared ModelForm.
>
> > Perhaps I should just use the functionality I already created in
> > models.py and just raise a ValidationError?
>
> > Thx
>
>

-- 
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.



EncryptedField

2012-09-18 Thread lingrlongr
I'm trying to make an encrypted field.  I'm using some of the code from the 
book Pro Django.  Generally speaking, it works, but it fails when using 
Django's admin interface.  Here's the code:

class EncryptedTextFieldDescriptor(property):
def __init__(self, field):
self.field = field

def __get__(self, instance, owner):
if instance is None:
return self
if self.field.name not in instance.__dict__:
raw_data = getattr(instance, self.field.attname)
instance.__dict__[self.field.name] = 
self.field.decrypt(raw_data)
return instance.__dict__[self.field.name]

def __set__(self, instance, value):
instance.__dict__[self.field.name] = value
setattr(instance, self.field.attname, self.field.encrypt(value))

class EncryptedTextField(models.TextField):
def encrypt(self, data):
return binascii.b2a_hex(_magic.encrypt(data))

def decrypt(self, data):
return _magic.decrypt(binascii.a2b_hex(data))

def get_attname(self):
return '%s_encrypted' % self.name

def get_db_prep_lookup(self, lookup_type, value):
raise ValueError("Can't make comparisons against encrypted data.")

def contribute_to_class(self, cls, name):
super(EncryptedTextField, self).contribute_to_class(cls, name)
setattr(cls, name,  EncryptedTextFieldDescriptor (self))

When using a python shell:

>>> obj.enc_field = 'test'
>>> print obj.enc_field
'test'
>>> print obj.enc_field_encrypted
'4441f5378dbb0be1c5a84e32c8616295b739c0ca82e68sb8f230f0aab2c40c0561d2223c7534a563da727578852db7ac3dd1f9d289ffac34d5492d1c1cefeed771f97b45ad862166e67f2170856fd4bd'
>>> obj.save()

This all works fine.  When this object is loaded in the admin, the value 
for the enc_field will be the encrypted version, not the decrypted version. 
 So, if I were to save the object, the encrypted text gets encrypted again, 
then saved.

How can I stop this behavior?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/iXAJVIw90o0J.
To post to this group, send email to django-users@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: EncryptedField

2012-09-18 Thread lingrlongr
It looks like I solved it by doing this:

def __set__(self, instance, value):
instance.__dict__[self.field.name] = value
if value != getattr(instance, self.field.attname):
setattr(instance, self.field.attname, self.field.encrypt(value))

I figured I should be checking somewhere if I already encrypted, but 
couldn't figure out where.  Not sure if this is the best way though...


On Tuesday, September 18, 2012 9:51:23 AM UTC-4, lingrlongr wrote:
>
> I'm trying to make an encrypted field.  I'm using some of the code from 
> the book Pro Django.  Generally speaking, it works, but it fails when using 
> Django's admin interface.  Here's the code:
>
> class EncryptedTextFieldDescriptor(property):
> def __init__(self, field):
> self.field = field
>
> def __get__(self, instance, owner):
> if instance is None:
> return self
> if self.field.name not in instance.__dict__:
> raw_data = getattr(instance, self.field.attname)
> instance.__dict__[self.field.name] = 
> self.field.decrypt(raw_data)
> return instance.__dict__[self.field.name]
>
> def __set__(self, instance, value):
> instance.__dict__[self.field.name] = value
> setattr(instance, self.field.attname, self.field.encrypt(value))
>
> class EncryptedTextField(models.TextField):
> def encrypt(self, data):
> return binascii.b2a_hex(_magic.encrypt(data))
>
> def decrypt(self, data):
> return _magic.decrypt(binascii.a2b_hex(data))
>
> def get_attname(self):
> return '%s_encrypted' % self.name
>
> def get_db_prep_lookup(self, lookup_type, value):
> raise ValueError("Can't make comparisons against encrypted data.")
>
> def contribute_to_class(self, cls, name):
> super(EncryptedTextField, self).contribute_to_class(cls, name)
> setattr(cls, name,  EncryptedTextFieldDescriptor (self))
>
> When using a python shell:
>
> >>> obj.enc_field = 'test'
> >>> print obj.enc_field
> 'test'
> >>> print obj.enc_field_encrypted
>
> '4441f5378dbb0be1c5a84e32c8616295b739c0ca82e68sb8f230f0aab2c40c0561d2223c7534a563da727578852db7ac3dd1f9d289ffac34d5492d1c1cefeed771f97b45ad862166e67f2170856fd4bd'
> >>> obj.save()
>
> This all works fine.  When this object is loaded in the admin, the value 
> for the enc_field will be the encrypted version, not the decrypted version. 
>  So, if I were to save the object, the encrypted text gets encrypted again, 
> then saved.
>
> How can I stop this behavior?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/G9238VJeRKUJ.
To post to this group, send email to django-users@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: managing files, deleting file from file system with admin site

2012-11-15 Thread lingrlongr
I've use something like this:

class Car(models.Model):
#some fields
photo = models.ImageField(upload_to='cars')

def delete(self, *args, **kwargs):
storage, path = self.photo.storage, self.photo.path
super(Car, self).delete(*args, **kwargs)
storage.delete(path)


On Thursday, November 15, 2012 12:48:16 AM UTC-5, Sergey Seleznev wrote:
>
> Hi! I'm new to python and django(well, and web dev too).
> I'm using python 2.7 and django 1.4
> I went through the tutorial and then got issue with files managing.
> I have model like this:
>
> class Car(models.Model):
> #some fields
> photo = models.ImageField(upload_to='cars')
>
> and media url/root configured in settings.py.
> Also I have autogenerated django admin site.
> Its works well and I can upload files to MEDIA_ROOT/cars/ automaticaly 
> when adding new object to Car model, but when I delete or change that 
> object from admin site old file doesnt deletes.
> I need some easy and a good way to configure 
> model/admin_site/something_else to delete old files from file system when i 
> change/delete model object from admin site.
> I think admin 
> actions can 
> be solution, but dont think it helps in case of changes and it cant help 
> override "Delete" button from object edit page.
>
> Thanks for your help!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rWzjWwB7VhkJ.
To post to this group, send email to django-users@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.



class-based generic views and forms

2011-04-25 Thread lingrlongr
I have a view that subclasses uses django.views.generic UpdateView.
In my template, I'm trying to access a form field's required
property.  For example:

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

Nothing outputs when the template is rendered.  Does the "required"
attribute not get populated when using the class-based UpdateView
generic view?  I'm assuming that is correct, just looking for
confirmation as to yes, it's supposed to work like that.  Any reason
why this would not be an included attribute?

These documentation for the new class-based views seems very vague
ATM.

Keith

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: class-based generic views and forms

2011-04-25 Thread lingrlongr
A lifesaver you are!  Thx DR!

On Apr 25, 4:37 pm, Daniel Roseman  wrote:
> On Monday, April 25, 2011 9:16:18 PM UTC+1, lingrlongr wrote:
>
> > I have a view that subclasses uses django.views.generic UpdateView.
> > In my template, I'm trying to access a form field's required
> > property.  For example:
>
> > {% for field in form %}
> >    {{ field.required }}
> > {% endfor %}
>
> > Nothing outputs when the template is rendered.  Does the "required"
> > attribute not get populated when using the class-based UpdateView
> > generic view?  I'm assuming that is correct, just looking for
> > confirmation as to yes, it's supposed to work like that.  Any reason
> > why this would not be an included attribute?
>
> > These documentation for the new class-based views seems very vague
> > ATM.
>
> > Keith
>
> Forms work exactly the same in class-based views as they do in any other
> views. However you're using the form, the `required` attribute is not on the
> `field` object you get when doing `for field in forms`. It is, perhaps
> confusingly, on the field's `field` property, so you need to do {{
> field.field.required }}.
> --
> 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-users@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 model with application code

2011-05-24 Thread lingrlongr
Hi All,

Django comes with its own authentication scheme, which includes the
User model.  So let's say I created my Django app, and I connect some
of my models to the User model using the ForeignKey field type.  If I
delete a User object, I now have objects that used to refer to a valid
User, but now return None as the User.  Is there a preferred method
for handling this?  A real world example could be a corporate
timesheet system.  A user enters their time for their duration at the
company, say 8 months.  But when the user is terminated, their account
in Django is removed as well.  Now all the time entries would refer to
"None" as the user.  So what if, for historical purposes, you need to
keep the users there so your data still makes sense.

Is there a recommended way to design your application to accommodate
this?  Looking at the "on_delete" kwarg for the ForeignKey field
mentions some options, but nothing usable, to me.
http://docs.djangoproject.com/en/1.3/ref/models/fields/#django.db.models.ForeignKey.on_delete

Perhaps, use a save signal on the User model that will create a
duplicate of that User object as an instance of a similar model
(perhaps inherited from User??), and that similar model is what I
connect all my other models to.  I could then delete my User objects
and still keep the SimilarUser objects intact so my app still works.

Thanks for any ideas...

Keith

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



saving related objects in overridden save method on model

2011-06-21 Thread lingrlongr
I have these models:

class Widget(models.Model):
name

class Person(models.Model):
requested = models.ForeignKey(Widget, related_name='requested')
considered = models.ManyToManyField(Widget,
related_name='considered')

def save(self, *args, **kwargs):
if not self.considered.filter(id=self.requested.id):
self.considered.add(self.requested)

I'm trying to make sure that when a Person has requested a widget,
that value automatically gets selected added as a considered value
too.  I find that this does work if I do this when no considered
values are selected:

>>> p = Person.objects.get(pk=1)
>>> p.save()

The relationship gets saved.  But when I attempt in the Django admin,
the two fields are not sync'd.  Any reason why this would be?

Thx.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: saving related objects in overridden save method on model

2011-06-21 Thread lingrlongr
Woops, I forgot to include the super's save method call in my
example.  Just want to make sure no one thinks that was the problem...

def save(self, *args, **kwargs):
if not self.considered.filter(id=self.requested.id):
   self.considered.add(self.requested)
super(Person, self).save(*args, **kwargs)

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.