File upload and access properties

2008-08-25 Thread Julien Phalip

Hi,

I'm using the FileSystem storage to save uploaded files, in a very
basic way:

storage.save('/blah/test.mp3', uploaded_file)

Now, the resulting file has '600' file access properties. That file is
then served by apache, but because of those access properties, it
cannot be accessed as you get a '403 Forbidden' error.

Is there a way to force the properties for the stored file (e.g. 605
would be enough)?

Thanks!

Julien
--~--~-~--~~~---~--~~
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: Custom manager for many-to-many traversal

2008-08-25 Thread MrJogo

I could, but I need to do it in a template, and from what I
understand, passing variables to method calls in the template language
is a pain, or at least ugly. I think a custom manager is the elegant,
"proper" way to so it (someone can correct me if I'm wrong.

On Aug 25, 10:31 am, John M <[EMAIL PROTECTED]> wrote:
> Since my_book.auther_set.all() returns a QS, can't you just say
> something like ...all().filter(author__isalive=True) or something like
> that?  I've never tried, but I thought that django would figure it
> out?
>
> J
>
> On Aug 25, 12:11 am,MrJogo<[EMAIL PROTECTED]> wrote:
>
> > How do I create a custom manager for many-to-many traversal? An
> > example will illustrate what I want to do better. Suppose I have the
> > following models.py:
>
> > class Book(models.Model):
> >   title = models.CharField(max_length=100)
>
> > class Author(models.Model):
> >   books = models.ForeignKey(Book)
> >   name = models.CharField(max_length=100)
> >   is_alive = models.BooleanField()
>
> > This is a many-to-many relationship: a book can have multiple authors
> > and an author can have written multiple books.
>
> > If I have a book object my_book, and I want to get all the authors, I
> > do my_book.author_set.all(). How can I set up a custom manager to only
> > get living authors of that book, so I could do something like
> > my_book.livingauthor_set.all()?
>
> > 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: send_mail timeout

2008-08-25 Thread tm

Ok I figured it out.  Basically I changed the send port to something
other than 25.  Apparently my machine requires that.

On Aug 25, 11:27 pm, tm <[EMAIL PROTECTED]> wrote:
> Hello, I am trying to use django's send_email exactly as in the docs,
> and am receiving 10060, 'Operation timed out'.  I am developing on my
> local machine and using my webhost's email (the same settings I use in
> outlook send mail fine).  I have the my settings file populated with
> the right data and debug=True.  I know it is something very simple but
> can't seem to figure it out.  I'm on the latest from svn, windows xp,
> python 2.5, apache, mod_python.  Any ideas would be greatly
> appreciated.  Thanks, T
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



send_mail timeout

2008-08-25 Thread tm

Hello, I am trying to use django's send_email exactly as in the docs,
and am receiving 10060, 'Operation timed out'.  I am developing on my
local machine and using my webhost's email (the same settings I use in
outlook send mail fine).  I have the my settings file populated with
the right data and debug=True.  I know it is something very simple but
can't seem to figure it out.  I'm on the latest from svn, windows xp,
python 2.5, apache, mod_python.  Any ideas would be greatly
appreciated.  Thanks, T
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



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: disable admin log

2008-08-25 Thread chefsmart

Thanks Malcolm.

On Aug 25, 9:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-08-25 at 09:12 -0700,chefsmartwrote:
> > Can someone in the know please confirm the existence or otherwise of
> > an option to disable logging in admin?
>
> Such an option does not exist.
>
> 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: help implementing search in django

2008-08-25 Thread chefsmart

That's a really good suggestion. Will go over that code today. Still
would like to hear other opinions though.

On Aug 26, 1:48 am, Steve  Potter <[EMAIL PROTECTED]> wrote:
> I really don't have any experience with this.  However if I was trying
> to implement a search, the first thing I would do is look at the
> Django Admin code and see how it was done there.
>
> Steve
>
> On Aug 25, 1:15 pm, chefsmart <[EMAIL PROTECTED]> wrote:
>
> > Please seehttp://dpaste.com/hold/73759/Ineed some guidance
> > implementing search feature in django.
>
> > What I want to do is to be able to search for Regions. Let's suppose
> > we have: -
>
> > A page where the user will be able to specify (a) one or multiple
> > states from a list, (b) one user to match with "created_by", (c) one
> > user to match with "modified_by". All these three search criteria are
> > optional, that is, if all three are not specified, the search returns
> > all regions. If one or more criteria are specified, the search returns
> > Regions that match all criteria.
>
> > 1. how do I construct the search page?
> > 2. How do I perform a search based on the values obtained when the
> > search page is submitted?
> > 3. The values returned are not django models, of course. How do I
> > translate the values obtained so that they represent their
> > corresponding django models?
> > 4. How do I perform the query to search Regions?
> > 5. The Regions found in search are django models or python data types?
>
> > I know that's a long list, but I have been trying this for too long
> > now. I just couldn't figure out how to do this...
>
> > Your help is greatly appreciated.
>
> > 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
-~--~~~~--~~--~--~---



Best wiki for the "support" section of a ISV

2008-08-25 Thread mamcxyz

I'm working towards a relaunch of my website, with new focus &
products.

I have 1 main product for the consumer (the focus) & resell 6 for the
developers.

I wanna a simpler but profesional face. Also, as now, I'm a solo-
developer so need the more simple aproach. I hope get something like
in the django docs ;)

I'm deciding if go for a hosted Wiki plataform or use django thirdy-
party modules like http://sct.sphene.net.

I only need write acces for myself, and support for english & spanish.
If hosted, which is good enough and can use my templates?

What do you think?
--~--~-~--~~~---~--~~
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: Strategies for staying current with django development

2008-08-25 Thread Jay Parlar

Another good idea is to listen to the "This Week in Django" podcast
(www.thisweekindjango.com).

They cover all the major things that have happened to trunk in the
last week, as well as things happening in the community, snippets
they've run across, etc. It's put together really well, and fun to
listen to. This is what I use to keep up to date, esp. when I have to
take some time away from Django work.

Jay P.

--~--~-~--~~~---~--~~
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: Strategies for staying current with django development

2008-08-25 Thread Gremmie

On Aug 25, 8:06 pm, Gremmie <[EMAIL PROTECTED]> wrote:
> Karen, I am using a customized admin template, so perhaps my auth
> problem is related to that.

Indeed, my admin/index.html needed an update. The {%
get_admin_app_list as app_list %} stuff is now obsolete. 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
-~--~~~~--~~--~--~---



HowTo: Django view as a class

2008-08-25 Thread zvoase

Hey Django users, just a quick suggestion which might help a few
people.
I have come up with a way of writing a Django view as a class. I've
done this as part of an effort to write easier-to-understand RESTful
apps, as this allows the grouping of similar views as different types
of operation on a resource. Essentially, the solution goes something
like this:

* Views have to be callables which return HttpResponse objects.
* The problem with views as classes is that calling a view class
returns an instance of the view class, not HttpResponse.
* Solution: have the VC (view class) a subclass of HttpResponse.
This way, 'calling' the class will return a HttpResponse instance.

I've written a general class, Resource, which performs a dispatch on
the request method, so that a resource can be retrieved, created/
updated and deleted by writing 'get', 'put' and 'delete' methods on a
subclass of Resource.

A sample resource may look like this:

# CODE START #

class Book(Resource):
def get(self, request, book_name):
book = myapp.models.Book.objects.get(name=book_name)
return render_to_response('book_template.html', {'book':
book})

   def put(self, request, book_name):
new_book, created = get_or_create(myapp.models.Book,
name=book_name)
new_book.data = request.raw_post_data
if created:
return HttpResponse(status=201)
return HttpResponse(status=200)

def delete(self, request, book_name):
book = myapp.models.Book.objects.get(name=book_name)
book.delete()
return HttpResponse()

# CODE END #

You can see how these methods correspond to GET, PUT and DELETE
request methods, and the dispatch is performed in the __init__ method
defined in the Resource class. HttpResponse instances can be returned
from these methods, and their data will be merged with 'self' by
__init__.

Okay, so here's the code I've written:

# CODE START #

class Resource(HttpResponse):
def __init__(self, request, *args, **kwargs):
HttpResponse.__init__(self)
if hasattr(self, request.method.lower()):
value = getattr(self, request.method.lower())(request, 
*args,
**kwargs)
if isinstance(value, HttpResponse):
self.update(value)
elif hasattr(self, 'run'):
value = self.run(request, *args, **kwargs)
if isinstance(value, HttpResponse):
self.update(value)

def update(self, response):
self._charset = response._charset
self._is_string = response._is_string
self._container = response._container
self._headers.update(response._headers)
self.cookies.update(response.cookies)
self.status_code = response.status_code

def render_to_response(self, *args, **kwargs):
self.update(render_to_response(*args, **kwargs))

# CODE END #

I hope people find this useful.

Regards,
Zack

--~--~-~--~~~---~--~~
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: MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread dchandek

OK, this is interesting: I didn't mention that I also has
limit_choices_to set on the self-referential foreign key. When I
remove limit_choices_to the problem goes away! My model is listed
below. I had set limit_choices_to=PARENT_CHOICES on OrgUnit.parent.

[start code]
LIBRARY_ID = 1
SAP_ORG_UNITS = (string, string, ...)

class OrgUnit(models.Model):

DEFAULT_HEAD_TITLE = 'Head' # Default value for OrgUnit head_title
property
# Library `departments' are children of `administrative units',
which are
# children of the top-level org unit.
PARENT_CHOICES = models.Q(is_admin_unit=True) |
models.Q(id=LIBRARY_ID)
SAPORGUNIT_CHOICES = ((s, s) for s in SAP_ORG_UNITS)

name = models.CharField(max_length=255, unique=True)
description  = models.CharField(max_length=255, blank=True,
null=True)
sap_org_unit = models.CharField(max_length=20, blank=True,
null=True,
choices=SAPORGUNIT_CHOICES)
parent   = models.ForeignKey('self', null=True,
blank=True,
 related_name='children')
head = models.ForeignKey(Person, blank=True,
null=True,
 related_name='head_of')
head_title   = models.CharField(max_length=255,
default=DEFAULT_HEAD_TITLE, blank=True)
members  = models.ManyToManyField(Person, null=True,
blank=True,
 
related_name='member_of')
is_admin_unit= models.BooleanField(default=False, null=True,
editable=False)
# Contact Info
campus_box   = models.CharField(max_length=255, blank=True,
null=True)
physical_address = models.CharField(max_length=255, blank=True,
null=True)
email= models.EmailField(blank=True, null=True)
fax  = models.CharField(max_length=40, blank=True,
null=True)
phone= models.CharField(max_length=40, blank=True,
null=True)
phone2   = models.CharField(max_length=40, blank=True,
null=True)
url  = models.URLField(blank=True, null=True)
[end code]

Hope that help ...

Thanks,
David

> This is going to be infinitely easier to debug if have a small example
> model that reliably demonstrates the problem. At the moment, the single
> traceback is not really enough information to go on.
>
> 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: Strategies for staying current with django development

2008-08-25 Thread Gremmie

Thanks for the replies so far. I'm glad to hear someone thinks a dump
and reload of the auth tables isn't necessary. Can I also assume that
the model to database mapping hasn't changed, and I don't need to drop
my model tables and reload?

I did make a careful note of what rev I had django pinned at before I
did an update as a fall back. :-)

Karen, I am using a customized admin template, so perhaps my auth
problem is related to that. I am using admin.autodiscover(). I will
scan the docs for how to customize the new admin interface, perhaps my
template needs updating.

My own conversion to newforms-admin seemed to go pretty well. I
followed the advice on the wiki page, and also found this screencast
extremely helpful:

http://oebfare.com/blog/2008/jul/20/newforms-admin-migration-and-screencast/
--~--~-~--~~~---~--~~
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: MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread Malcolm Tredinnick


On Mon, 2008-08-25 at 17:44 -0700, dchandek wrote:
> To make this even stranger, the problem only occurs when the pk of the
> selected (self-)related object is 1. There's something deep going on
> in Django that I can't trace ...

This is going to be infinitely easier to debug if have a small example
model that reliably demonstrates the problem. At the moment, the single
traceback is not really enough information to go on.

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: MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread dchandek

To make this even stranger, the problem only occurs when the pk of the
selected (self-)related object is 1. There's something deep going on
in Django that I can't trace ...

--David

On Aug 25, 4:20 pm, dchandek <[EMAIL PROTECTED]> wrote:
> After upgrading from post-0.96 development version to 1.0-beta1, I now
> get a MultipleObjectsReturned when submitting a change via the Admin
> UI to an object, where the model has a many-to-one relationship with
> itself. From the Python interactive prompt I am not able to reproduce
> the error.
>
> Traceback athttp://dpaste.com/73791/
>
> Perplexed,
> David
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Setting the value of the select box for a ModelChoiceField

2008-08-25 Thread [EMAIL PROTECTED]

Hi,

I am using the ModelChoiceField to provide a filtered set of choices
on a profile form and I was wondering how I can set the initial value
of the select box.  In other words I want to set the initial value of
the form to the value retrieved from the database when a person is
editing or updating the form.
--~--~-~--~~~---~--~~
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: simple multiplication in models

2008-08-25 Thread Chris Amico

Awesome. That worked. Thanks all.


On Aug 25, 4:14 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-08-25 at 15:58 -0700, Chris Amico wrote:
> > Changed the variable names to make it a little more readable. Method
> > now returns "amount" (formerly "total"):
>
> > Class Item(models.Model):
> >     name = models.CharField(max_length=100)
> >     price = models.DecimalField(max_digits=9, decimal_places=2)
> >     quantity = models.IntegerField(default=1)
> >     total_cost = models.DecimalField(max_digits=12,
> >                                      decimal_places=2,
> >                                      blank=True,
> >                                      null=True,
> >                                      editable=False)
>
> >     def calc_total(self):
> >         amount = (self.price * self.quantity)
> >         return amount
>
> >     def save(self):
> >         self.total_cost = self.calc_total()
> >         super(Item, self).save()
>
> > Now I get a different error when I try to save an Item:
>
> > OperationalError at /admin/spending/item/add/
> > (1054, "Unknown column 'total_cost' in 'field list'")
>
> Your earlier model had a bug -- two things called total_cost. The second
> thing with that name (the method) completely hid the first thing. It
> wasn't just something that gave Karen a headache; it was a real bug. So
> when you ran "syncdb", there was no field called total_cost because the
> "total_cost" attribute was a method. Thus, you have added a new field to
> the model now that you have removed the method.
>
> You'll either have to update the database table manually, or drop and
> recreate that model's table (look at the sqlreset command for
> django-admin.py).
>
> 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: simple multiplication in models

2008-08-25 Thread Malcolm Tredinnick


On Mon, 2008-08-25 at 15:58 -0700, Chris Amico wrote:
> Changed the variable names to make it a little more readable. Method
> now returns "amount" (formerly "total"):
> 
> Class Item(models.Model):
> name = models.CharField(max_length=100)
> price = models.DecimalField(max_digits=9, decimal_places=2)
> quantity = models.IntegerField(default=1)
> total_cost = models.DecimalField(max_digits=12,
>  decimal_places=2,
>  blank=True,
>  null=True,
>  editable=False)
> 
> def calc_total(self):
> amount = (self.price * self.quantity)
> return amount
> 
> def save(self):
> self.total_cost = self.calc_total()
> super(Item, self).save()
> 
> 
> Now I get a different error when I try to save an Item:
> 
> OperationalError at /admin/spending/item/add/
> (1054, "Unknown column 'total_cost' in 'field list'")
> 

Your earlier model had a bug -- two things called total_cost. The second
thing with that name (the method) completely hid the first thing. It
wasn't just something that gave Karen a headache; it was a real bug. So
when you ran "syncdb", there was no field called total_cost because the
"total_cost" attribute was a method. Thus, you have added a new field to
the model now that you have removed the method.

You'll either have to update the database table manually, or drop and
recreate that model's table (look at the sqlreset command for
django-admin.py).

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: exporting apps and db from windows to ubuntu.

2008-08-25 Thread John M

from the command line / console / whatever...

./manage.py dumpdata

http://www.djangoproject.com/documentation/django-admin/#dumpdata-appname-appname


On Aug 25, 3:25 pm, KillaBee <[EMAIL PROTECTED]>
wrote:
> ok it is dumpdata and loaddata, but where does it go?  I searched for
> *.json but nothing came up. and there are alot of fixtures.
>
> On Aug 25, 4:05 pm, KillaBee wrote:
>
> > I am moving a app and db from a windows server to a Ubuntu server.  Is
> > there a easy way to export the data from the windows server and import
> > it into  the Ubuntu server.  I don't think that I can copy and paste,
> > then change the URLS.py file.  I looked for the files but the files I
> > did see looks different.  It pulls functions that I can't find in the
> > Django lib.
--~--~-~--~~~---~--~~
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: simple multiplication in models

2008-08-25 Thread Chris Amico

Changed the variable names to make it a little more readable. Method
now returns "amount" (formerly "total"):

Class Item(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=9, decimal_places=2)
quantity = models.IntegerField(default=1)
total_cost = models.DecimalField(max_digits=12,
 decimal_places=2,
 blank=True,
 null=True,
 editable=False)

def calc_total(self):
amount = (self.price * self.quantity)
return amount

def save(self):
self.total_cost = self.calc_total()
super(Item, self).save()


Now I get a different error when I try to save an Item:

OperationalError at /admin/spending/item/add/
(1054, "Unknown column 'total_cost' in 'field list'")



On Aug 25, 3:45 pm, nicksergeant <[EMAIL PROTECTED]> wrote:
> Should 'total_cost' simply:
>
> return total
>
> instead of:
>
> return total_cost(total)
>
> On Aug 25, 5:22 pm, Chris Amico <[EMAIL PROTECTED]> wrote:
>
> > This seems like it should be simple, but I'm getting errors.
>
> > I have a model tracking individual purchases. User inputs an item cost
> > and quantity; I want the total cost calculated. Here are the relevant
> > parts:
>
> > class Item(models.Model):
> >     name = models.CharField(max_length=100)
> >     price = models.DecimalField(max_digits=9, decimal_places=2)
> >     quantity = models.IntegerField(default=1)
> >     total_cost = models.DecimalField(max_digits=12,
> >                                      decimal_places=2,
> >                                      blank=True,
> >                                      null=True,
> >                                      editable=False)
>
> >     def total_cost(self):
> >        total = (self.price * self.quantity)
> >        return total_cost(total)
>
> >     def save(self):
> >         self.total_cost = self.total_cost()
> >         super(Item, self).save()
>
> > The error I get is:
>
> > NameError at /admin/spending/item/add/
> > global name 'total_cost' is not defined
>
> > Not sure what that means. Thoughts? Am I missing an exceedingly
> > obvious way to do 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
-~--~~~~--~~--~--~---



Re: simple multiplication in models

2008-08-25 Thread nicksergeant

Should 'total_cost' simply:

return total

instead of:

return total_cost(total)

On Aug 25, 5:22 pm, Chris Amico <[EMAIL PROTECTED]> wrote:
> This seems like it should be simple, but I'm getting errors.
>
> I have a model tracking individual purchases. User inputs an item cost
> and quantity; I want the total cost calculated. Here are the relevant
> parts:
>
> class Item(models.Model):
>     name = models.CharField(max_length=100)
>     price = models.DecimalField(max_digits=9, decimal_places=2)
>     quantity = models.IntegerField(default=1)
>     total_cost = models.DecimalField(max_digits=12,
>                                      decimal_places=2,
>                                      blank=True,
>                                      null=True,
>                                      editable=False)
>
>     def total_cost(self):
>        total = (self.price * self.quantity)
>        return total_cost(total)
>
>     def save(self):
>         self.total_cost = self.total_cost()
>         super(Item, self).save()
>
> The error I get is:
>
> NameError at /admin/spending/item/add/
> global name 'total_cost' is not defined
>
> Not sure what that means. Thoughts? Am I missing an exceedingly
> obvious way to do 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
-~--~~~~--~~--~--~---



Re: exporting apps and db from windows to ubuntu.

2008-08-25 Thread KillaBee

ok it is dumpdata and loaddata, but where does it go?  I searched for
*.json but nothing came up. and there are alot of fixtures.

On Aug 25, 4:05 pm, KillaBee wrote:
> I am moving a app and db from a windows server to a Ubuntu server.  Is
> there a easy way to export the data from the windows server and import
> it into  the Ubuntu server.  I don't think that I can copy and paste,
> then change the URLS.py file.  I looked for the files but the files I
> did see looks different.  It pulls functions that I can't find in the
> Django lib.
--~--~-~--~~~---~--~~
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: simple multiplication in models

2008-08-25 Thread Karen Tracey
On Mon, Aug 25, 2008 at 5:22 PM, Chris Amico <[EMAIL PROTECTED]> wrote:

>
> This seems like it should be simple, but I'm getting errors.
>
> I have a model tracking individual purchases. User inputs an item cost
> and quantity; I want the total cost calculated. Here are the relevant
> parts:
>
> class Item(models.Model):
>name = models.CharField(max_length=100)
>price = models.DecimalField(max_digits=9, decimal_places=2)
>quantity = models.IntegerField(default=1)
>total_cost = models.DecimalField(max_digits=12,
> decimal_places=2,
> blank=True,
> null=True,
> editable=False)
>
>def total_cost(self):
>   total = (self.price * self.quantity)
>   return total_cost(total)
>
>def save(self):
>self.total_cost = self.total_cost()
>super(Item, self).save()
>
> The error I get is:
>
> NameError at /admin/spending/item/add/
> global name 'total_cost' is not defined
>
> Not sure what that means. Thoughts? Am I missing an exceedingly
> obvious way to do this?
>

You're making my brain explode trying to use the single name 'total_cost'
for both a model field and a method.  I'd name the method that computes the
values of the 'total_cost' field something else, like 'compute_total_cost'.
Then, within it, be very careful to preface all references to model field
values with 'self.'.  The error message you are getting usually happens when
you forget a 'self.' in front of a reference to a model field.

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



prepopulated_fields with generic relations

2008-08-25 Thread Donovan

Hi,

I am trying to get this model and admin declaration working:

#models.py

class SeoUrl(models.Model):
seotitle = models.SlugField(max_length = 100)
priority = models.PositiveIntegerField(blank=False, null=False)

content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type',
'object_id')

class Content(models.Model):
seo_urls = generic.GenericRelation(SeoUrl)
def get_absolute_url(self):
return ('/%s/' % self.seo_urls[0])

class Meta:
abstract = True

class Author(Content):
firstname = models.CharField(max_length = 1000)
lastname = models.CharField(max_length = 1000)


#admin.py

class SeoUrlInline(generic.GenericStackedInline):
model = SeoUrl

class AuthorAdmin(admin.ModelAdmin):
inlines = [ SeoUrlInline,]
prepopulated_fields = {'seotitle':("firstname", "lastname",) } #This
line should pre-populate the first seo_url

I want the first inline of SeoUrl to be populated when the user types
something in to the firstname and lastname fields. The last line of
AuthorAdmin is the problem. It causes this error:

`AuthorAdmin.prepopulated_fields` refers to field `seotitle` that is
missing from model `Author`.

which is correct! Is there a way to make this possible? I know I could
resort to some jQuery and admin template modification, but was
wondering if the prepopulate_fields code has some awareness of the
eventual id's of inline form fields.

Cheers in advance,
Donovan.


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



simple multiplication in models

2008-08-25 Thread Chris Amico

This seems like it should be simple, but I'm getting errors.

I have a model tracking individual purchases. User inputs an item cost
and quantity; I want the total cost calculated. Here are the relevant
parts:

class Item(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=9, decimal_places=2)
quantity = models.IntegerField(default=1)
total_cost = models.DecimalField(max_digits=12,
 decimal_places=2,
 blank=True,
 null=True,
 editable=False)

def total_cost(self):
   total = (self.price * self.quantity)
   return total_cost(total)

def save(self):
self.total_cost = self.total_cost()
super(Item, self).save()

The error I get is:

NameError at /admin/spending/item/add/
global name 'total_cost' is not defined

Not sure what that means. Thoughts? Am I missing an exceedingly
obvious way to do 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
-~--~~~~--~~--~--~---



Re: Strategies for staying current with django development

2008-08-25 Thread Karen Tracey
On Mon, Aug 25, 2008 at 5:01 PM, Steve Potter <[EMAIL PROTECTED]>wrote:

> If you look in the django-users archive I think I remember a few other
> people having the same auth problems you are describing, however I
> don't remember the solution.
>

As I recall a lot of people reported this error, but it ultimately turned
out to be due to either
1 - not calling admin.autodiscover()
2 - not updating customized admin templates
3 - perhaps other incomple admin migrations

There certainly was not any requirement to dump/reload tables.

As for strategies to migrate forward, beyond carefully following the
instructions in backwards-incompatible changes, searching the user's group
for similar error messages will likely turn up people who ran into and
solved the problem before you hit it, especially for any changes that are
more than a few days old.

Also, when you're doing a big jump forward, note the revision you are
updating from.  That way you can 'svn -r up' back to that if you run
into a temporarily unsurmountable problem.

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: Empty template_name for login

2008-08-25 Thread Karen Tracey
2008/8/25 Ludwig <[EMAIL PROTECTED]>

> I am using the 1.0 beta 1 release.
>
> I think I am following the documentation, when I set
>
> ('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),
>
> in my urls.py
>
> But then I get a TemplateDoesNotExist exception when opening
> /accounts/login.
>
> The template (standard registration/login.html) does exist, but somehow the
> template name gets lost in Django and it looks for an empty template name
> u''.
> Below is the relevant snippet from the error page:
>
[snip]

The snippet is a bit too abbreviated to be of use.  It would be better if
you selected the "Switch to copy-and-paste view" link and then the "Share
this traceback on a public web site" button to post the traceback to
dpaste.com and then post the link.


> If I set the template name explicitly, I get the error that the kw arg is
> doubly defined.
> (If in auth.views.login I set the template_name explictly to my template,
> overriding the empty string, it works, so my template is ok)
>
>
 You should be able to set the template name explicitly like so:

('^accounts/login/(.*)', 'django.contrib.auth.views.login',
{'template_name': 'path/login_template_name'}),

If that is what you tried and you got some error about a kwarg being doubly
defined that is rather mysterious.

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



exporting apps and db from windows to ubuntu.

2008-08-25 Thread KillaBee

I am moving a app and db from a windows server to a Ubuntu server.  Is
there a easy way to export the data from the windows server and import
it into  the Ubuntu server.  I don't think that I can copy and paste,
then change the URLS.py file.  I looked for the files but the files I
did see looks different.  It pulls functions that I can't find in the
Django lib.
--~--~-~--~~~---~--~~
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: Strategies for staying current with django development

2008-08-25 Thread Steve Potter

Personally when the newforms-admin was merged I quit updateing django
so I wouldn't have to make multiple changes to my code before the 1.0
release.  Then I planned to move everything to 1.0 and stay with it
until another major release (or until there was a new feature I
couldn't live without :-).

Since the date for the 1.0 release is nearing I decided yesterday to
try to port some of my code to the current SVN to see how hard it was
going to be.  It turns out it wasn't bad at all.

To answer some of your other questions below;  I don't think there are
any changed to the auth table.

To get he newforms admin working I just removed all of my Admin
classes from the models.py and created new ones in the admin.py as per
the Django documentation.  As well as updating the urls.py to the new
format for admin and adding the admin to the installed apps list.
Then is just worked.

If you look in the django-users archive I think I remember a few other
people having the same auth problems you are describing, however I
don't remember the solution.

Steve


On Aug 25, 3:43 pm, Gremmie <[EMAIL PROTECTED]> wrote:
> I checked out the latest django from SVN some 14 weeks ago and built a
> site with it. It rocks. :-). Yesterday, I decided to port my code to
> the latest to take advantage of the newforms-admin. I had to update my
> Photologue app also. A lot of stuff has changed! I am not quite there
> yet, but I can finally get my admin page to come up, but django is now
> saying my user doesn't have permission to edit anything. I am aware of
> the backwards incompatible change list on the wiki, but to be honest,
> a lot of it is over my head as a newbie. I don't speak django-
> developer (yet). Nothing jumped out at me regarding authorization
> changes. So my current theory is that there must be some auth database
> table changes. I am thinking that I should save off all my site
> database data, then drop all my tables and syncdb again. Or perhaps
> point my site to a blank database and syncdb. Then use mysqldiff to
> compare old and new databases and see what changed. I can possibly re-
> import my data by re-running the old SQL, although I may need to
> rename fields and do other fiddling, etc.
>
> I was able to save my Photologue data by saving it with phpMyAdmin,
> dropping the tables, syncdb, then studying the new structures. I could
> then re-run my saved SQL to get my data back, but I did have to make a
> few tweaks. In one case, I had to add back 2 columns to a table, re-
> import, then dropped those 2 columns to avoid fiddling with the saved
> SQL.
>
> What strategies do people use to keep up with the moving target that
> is django? Are there easier ways than what I am doing?
>
> Updating more often than once every 14 weeks is a good idea. :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: help implementing search in django

2008-08-25 Thread Steve Potter

I really don't have any experience with this.  However if I was trying
to implement a search, the first thing I would do is look at the
Django Admin code and see how it was done there.

Steve


On Aug 25, 1:15 pm, chefsmart <[EMAIL PROTECTED]> wrote:
> Please seehttp://dpaste.com/hold/73759/I need some guidance
> implementing search feature in django.
>
> What I want to do is to be able to search for Regions. Let's suppose
> we have: -
>
> A page where the user will be able to specify (a) one or multiple
> states from a list, (b) one user to match with "created_by", (c) one
> user to match with "modified_by". All these three search criteria are
> optional, that is, if all three are not specified, the search returns
> all regions. If one or more criteria are specified, the search returns
> Regions that match all criteria.
>
> 1. how do I construct the search page?
> 2. How do I perform a search based on the values obtained when the
> search page is submitted?
> 3. The values returned are not django models, of course. How do I
> translate the values obtained so that they represent their
> corresponding django models?
> 4. How do I perform the query to search Regions?
> 5. The Regions found in search are django models or python data types?
>
> I know that's a long list, but I have been trying this for too long
> now. I just couldn't figure out how to do this...
>
> Your help is greatly appreciated.
>
> 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
-~--~~~~--~~--~--~---



Strategies for staying current with django development

2008-08-25 Thread Gremmie

I checked out the latest django from SVN some 14 weeks ago and built a
site with it. It rocks. :-). Yesterday, I decided to port my code to
the latest to take advantage of the newforms-admin. I had to update my
Photologue app also. A lot of stuff has changed! I am not quite there
yet, but I can finally get my admin page to come up, but django is now
saying my user doesn't have permission to edit anything. I am aware of
the backwards incompatible change list on the wiki, but to be honest,
a lot of it is over my head as a newbie. I don't speak django-
developer (yet). Nothing jumped out at me regarding authorization
changes. So my current theory is that there must be some auth database
table changes. I am thinking that I should save off all my site
database data, then drop all my tables and syncdb again. Or perhaps
point my site to a blank database and syncdb. Then use mysqldiff to
compare old and new databases and see what changed. I can possibly re-
import my data by re-running the old SQL, although I may need to
rename fields and do other fiddling, etc.

I was able to save my Photologue data by saving it with phpMyAdmin,
dropping the tables, syncdb, then studying the new structures. I could
then re-run my saved SQL to get my data back, but I did have to make a
few tweaks. In one case, I had to add back 2 columns to a table, re-
import, then dropped those 2 columns to avoid fiddling with the saved
SQL.

What strategies do people use to keep up with the moving target that
is django? Are there easier ways than what I am doing?

Updating more often than once every 14 weeks is a good idea. :-)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Better way that _meta to alter Admin?

2008-08-25 Thread Jay Parlar

I'm starting to port my projects, from a version of Django before NFA.
In the past, I had something like this:

User._meta.admin.list_display = User._meta.admin.list_display + ('is_active',)
User._meta.get_field('is_staff').help_text = u"Select this if you want
this user to be able to log into the Admin site."
User._meta.get_field('is_staff').verbose_name = u"Site Administrator"

It seems that using inheritance in NFA, there should be a better way.
I was able to replace the list_display stuff with:

class MyUserAdmin(UserAdmin):
pass
site.register(User, MyUserAdmin)


That works nicely, but I can't find the "right" way to do the
_meta.get_field() stuff in NFA.

Any thoughts?

Thanks,
Jay P.

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



MultipleObjectsReturned with get() on 1.0-beta1 admin UI

2008-08-25 Thread dchandek

After upgrading from post-0.96 development version to 1.0-beta1, I now
get a MultipleObjectsReturned when submitting a change via the Admin
UI to an object, where the model has a many-to-one relationship with
itself. From the Python interactive prompt I am not able to reproduce
the error.

Traceback at http://dpaste.com/73791/

Perplexed,
David
--~--~-~--~~~---~--~~
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: urlpatterns and generic views cheatsheet

2008-08-25 Thread maeck

I have printed this from scribd into a PDF and use it as such, no need
for login.
Works somewhat, cannot select the text from it (could have run some
text recognition on it), but expect to find the original code or pdf
somewhere soon (Google code maybe).

maeck
--~--~-~--~~~---~--~~
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: Random NoReverseMatch

2008-08-25 Thread koenb

I guess you are seeing the bug reported in #6379. You probably have an
import error somewhere, but it is being hidden by the NoReverseMatch
exception that is raised for anything that goes wrong.

Koen

On 25 aug, 16:13, Robin <[EMAIL PROTECTED]> wrote:
> Hello,
>
> i have the same exception and exactly as Julien explained in the dev
> server works fine ... and also works fine with fast_cgi, but I am
> using apache + mod_wsgi and it didn't work with the same problem:
> NoReverseMatch
>
> Has any of you any clue to this error ?
>
> thanks in advance,
>         r
>
> On Aug 16, 8:16 pm, Alberto Piai <[EMAIL PROTECTED]> wrote:
>
> > On Aug 16, 12:01 am, Julien Phalip <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > It's likely that there is a typo somewhere in your templates, either
> > > you didn't write the view name properly, or you didn't provide the
> > > right parameters.
> > > In the error message, there should be the name of the view. Look up
> > > every occurrence et double check that you haven't made any typo.
>
> > I'm checking everything again. But actually I don't think the
> > problem's there, as everything works fine when run from django's dev
> > server, and now it's been working fine for some hours even on lighttpd
> > +fcgi. When the problem appears again I'll send the traceback.
>
> > Thanks for you help,
>
> > Alberto
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Create/update/delete generic views and user

2008-08-25 Thread mccomas . chris

Is is possible with Create/update/delete generic views to get the user
that's logged in's ID and use? I have a field with a FK for user, I'd
really just like to use the generic views for this, since it's a
simple thrown together internal site, instead of writing out other
views/forms/etc.

So, when someone creates a new entry it automatically inserts their
user_id in the table in the 'user' field? Then they can only edit
their own entries?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Empty template_name for login

2008-08-25 Thread Ludwig
I am using the 1.0 beta 1 release.

I think I am following the documentation, when I set

('^accounts/login/(.*)', 'django.contrib.auth.views.login', {}),

in my urls.py

But then I get a TemplateDoesNotExist exception when opening
/accounts/login.

The template (standard registration/login.html) does exist, but somehow the
template name gets lost in Django and it looks for an empty template name
u''.
Below is the relevant snippet from the error page:

for middleware_method in self._view_middleware:
response = middleware_method(request, callback, callback_args,
callback_kwargs)
if response:
return response
try:

response = callback(request, *callback_args, **callback_kwargs) ...

except Exception, e:
# If the view raised an exception, run it through exception
# middleware, and if the exception middleware returns a
# response, use that. Otherwise, reraise the exception.
for middleware_method in self._exception_middleware:
response = middleware_method(request, e)

▼ Local vars
Variable Value
callback

callback_args
(u'',)
callback_kwargs
{}
e
TemplateDoesNotExist(u'',)


If I set the template name explicitly, I get the error that the kw arg is
doubly defined.
(If in auth.views.login I set the template_name explictly to my template,
overriding the empty string, it works, so my template is ok)

Any idea what is going on here?

Ludwig

--~--~-~--~~~---~--~~
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: email not being sent from within unit tests

2008-08-25 Thread Andrew D. Ball

It turns out that this is by design:

http://docs.djangoproject.com/en/dev/topics/testing/#e-mail-services

This behavior is fine -- even better than the SMTP
"black hole" setup that I have.

Peace,
Andrew

On Tue, Aug 19, 2008 at 07:21:52PM -0400, Andrew D. Ball wrote:
> I've noticed that email isn't being sent during unit tests
> in Django 1.0 beta 1.  The django.core.mail.EmailMessage.send
> method returns '1' as if it had sent 1 message successfully,
> but the SMTP server doesn't get contacted at all.  The
> same thing happens with django.core.mail.send_mail.
> 
> Is this expected behavior?  Is it documented somewhere?
> 
> In versions 0.96.1 and 0.96.2 sending email with
> django.core.mail.send_mail works the same within unit
> tests and in regular views.  This is the behavior I want.
> 
> I've uploaded a small project to demonstrate what I'm talking
> about at
> http://www.ibiblio.org/adball/debugging/django/email_test.tar.bz2
> 
> If you do 
> 
> python manage.py test
> 
> no email would be sent, even though it contains a unit test that
> does
> 
>  email = EmailMessage('[unit test] subject', 'body', '[EMAIL 
> PROTECTED]', ['[EMAIL PROTECTED]'])
>  email.send(fail_silently=False)
> 
> In a view that corresponds to the ^test_email/ URL pattern,
> I have nearly identical code.  The only difference is that '[unit test]'
> is replaced with '[not unit test]'.  Email gets sent just
> fine when I run this view through a web browser.
> 
> What gives?  I'd like my unit tests to send emails.  It's fine
> if I have to add a setting or something, but it's not okay that
> I'm currently unable to get emails to be sent by unit tests.
> 
> I have a really nice "SMTP black hole" -- an SMTP server on
> a VM that delivers mail to any email address to a local mail
> spool, so the unit tests' sending emails won't hurt anything.
> 
> Peace,
> Andrew
> -- 
> ===
> Andrew D. Ball
> [EMAIL PROTECTED]
> Software Engineer
> American Research Institute, Inc.
> http://www.americanri.com/

-- 
===
Andrew D. Ball
[EMAIL PROTECTED]
Software Engineer
American Research Institute, Inc.
http://www.americanri.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Modules path when importing models

2008-08-25 Thread Norman Harman

Alexis Bellido wrote:
> I'm reading the Django book and playing with the  'mysite' test site,
> in many parts I've noticed something like this in views.py:
> 
> from mysite.models import Event, BlogEntry
> 
> I was wondering if it's good practice using 'mysite.models' (which
> seems to be an 'absolute path' for importing) or if it would be better
> using just:
> 
> from models import Event, BlogEntry
> 
> (which seems to be a 'relative path' because usually views.py is in
> the same directory than models.py).
> 
> Could somebody explain a little about the best way to do the imports?

I believe, nay I know, relative imports are evil.  It's easy to get 
confused which models "from models" represents.  Esp when/if there are 
multiple models.py in your Python path.  Maybe not with models.py but it 
happens, believe me I've wasted too much time on it.  Just don't do it.

But it's also wrong to tie apps to a particular site.  This is bad:

   from mysite.myapp.models import

Your models views, etc should be under myapp not mysite.  and the 
directory(ies) were all your apps are should be on python path. Then

   from myapp.models import blah.

For maximun portability and flexibility mysite should not appear in any 
import.

For my projects I create a directory like /web/www.example.com/python, I 
put that directory on the Python Path and put all my apps plus 
settings.py file in that directory.


some reading http://www.b-list.org/weblog/2007/nov/09/projects/
and 
http://www.pointy-stick.com/blog/2007/11/09/django-tip-developing-without-projects/
-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
It's August!  Keep your cool with the Statesman.  Check out our hot
deals in print and online for back-to-school savings and more!

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



help implementing search in django

2008-08-25 Thread chefsmart

Please see http://dpaste.com/hold/73759/ I need some guidance
implementing search feature in django.

What I want to do is to be able to search for Regions. Let's suppose
we have: -

A page where the user will be able to specify (a) one or multiple
states from a list, (b) one user to match with "created_by", (c) one
user to match with "modified_by". All these three search criteria are
optional, that is, if all three are not specified, the search returns
all regions. If one or more criteria are specified, the search returns
Regions that match all criteria.

1. how do I construct the search page?
2. How do I perform a search based on the values obtained when the
search page is submitted?
3. The values returned are not django models, of course. How do I
translate the values obtained so that they represent their
corresponding django models?
4. How do I perform the query to search Regions?
5. The Regions found in search are django models or python data types?

I know that's a long list, but I have been trying this for too long
now. I just couldn't figure out how to do this...

Your help is greatly appreciated.

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: how to get {% url %} working with {% blocktrans %}?

2008-08-25 Thread David Larlet


Le 23 août 08 à 13:45, Viktor Nagy a écrit :

>
> Hi!
>
> I need a url in a blocktrans message, but I have no clue how to do it.
>
> it would be intuitive to use
>
> {% blocktrans url app.views.add as createurl %}
> and then {{ createurl }}
>
> but it didn't work for me.
>
> could someone help me, please!

Hi Viktor,

You can have a look at this patch http://code.djangoproject.com/ticket/7239 
  the latest comment point to the discussion on the devel mailing- 
list, there is no decision yet about the right way to do this™.

Hope it helps,
David
--~--~-~--~~~---~--~~
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: Processing multiple forms in same page

2008-08-25 Thread timc3

Well then you just test to see what fields are pulled back, but its
fine, its possible.

I am doing it for a forum.

On Aug 24, 2:51 am, Rodolfo <[EMAIL PROTECTED]> wrote:
> Just for curiosity, why would one have two forms in a single page?
> I don't think it is possible to submit the two in a shot.
>
> Maybe only of them is intended to be filled per access?
>
> []s
>
> Rodolfo
>
> On Aug 23, 4:38 pm, Archis <[EMAIL PROTECTED]> wrote:
>
> > Hi Everyone,
>
> > I am new to Django. I have page in which I have two forms. I am not
> > able to find a way how to differentiate between the post of the two
> > forms. I have separate functions to be called for post action of each
> > of these two forms. Can anyone provide a solution ?
>
> > Thanks
>
> > Archis
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Making time sheet program.

2008-08-25 Thread KillaBee

How do I get started making a time sheet program?
I have did the polls on the Django websie, but I can't get it to do
what I want it to.
I just need a username, radio, and number fields to go into a table.
yes I a new to this django.

--~--~-~--~~~---~--~~
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: Widget rendering working as intended?

2008-08-25 Thread Malcolm Tredinnick


On Mon, 2008-08-25 at 10:35 -0700, Alex G wrote:
> Hi there,
> 
> I have been trying to get a function call into a widget argument, but
> have not been able to at the template level, because it would appear
> that my safe_strings are being escaped somewhere down in the
> framework.  I have created a widget and mark_safe'd an attribute
> value, but no matter what, since it's pre-escaped by the time it
> bubbles up to the template level, I can't not escape it (well... I
> could use an html library to de-escape it, but that seems kludgy).
> 
> I've traced the execution and found the culprit to be the
> django.forms.util.flatatt function.  That is:
> 
> from django import forms
> from django.utils.safestring import mark_safe
> 
> class MyWidget(forms.TextInput):
> def __init__(self, *args, **kwargs):
> attrs = kwargs.setdefault('attrs', {})
> attrs['safe_string'] = "will o' the wisp"
> attrs['normal_string'] = "cat o' nine tails"
> super(MyWidget, self).__init__(*args, **kwargs)
> 
> w = MyWidget()
> w.render("field_name", "")
> 
> #=> u' name="field_name" safe_string="will o the wisp" />'
> 
> You can see that both the unsafe and safe strings were escaped. 

But since we can't see the render() method for your widget, we have no
way to know how it determines the difference between safe and unsafe
strings. Neither of the strings in your __init__ method will be treated
as "safe", so you must be doing something special in render(). This is
mostly just a tip for the future, since you've actually identified a bug
lower down -- but we need to be able to see the relevant parts to debug
a problem.

[...]
>   Anyway, like I said, the culprit is:
> 
> # django.forms.util
> 
> def flatatt(attrs):
>  
> """
> Convert a dictionary of attributes to a single
> string.
> The returned string will contain a leading space followed by
> key="value",
> XML-style pairs.  It is assumed that the keys do not need to be
> XML-
> escaped.
> If the passed dictionary is empty, then return an empty
> string.
> """
> return u''.join([u' %s="%s"' % (k, escape(v)) for k, v in
> attrs.items()])  # <-- right there, the escape(v) call... should this
> be conditional_escape?

Yes. This is a bug. Please open a ticket for it.

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: Widget rendering working as intended?

2008-08-25 Thread Alex G

Whoops, I forgot the actual call to mark_safe in the above example,
but everything holds...

class MyWidget(forms.TextInput):
def __init__(self, *args, **kwargs):
attrs = kwargs.setdefault('attrs', {})
attrs['safe_string'] = mark_safe("will o' the wisp")
attrs['normal_string'] = "cat o' nine tails"
super(MyWidget, self).__init__(*args, **kwargs)

w = MyWidget()
w.render("field_name", "")
#=> u''



On Aug 25, 1:35 pm, Alex G <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I have been trying to get a function call into a widget argument, but
> have not been able to at the template level, because it would appear
> that my safe_strings are being escaped somewhere down in the
> framework.  I have created a widget and mark_safe'd an attribute
> value, but no matter what, since it's pre-escaped by the time it
> bubbles up to the template level, I can't not escape it (well... I
> could use an html library to de-escape it, but that seems kludgy).
>
> I've traced the execution and found the culprit to be the
> django.forms.util.flatatt function.  That is:
>
> from django import forms
> from django.utils.safestring import mark_safe
>
> class MyWidget(forms.TextInput):
>     def __init__(self, *args, **kwargs):
>         attrs = kwargs.setdefault('attrs', {})
>         attrs['safe_string'] = "will o' the wisp"
>         attrs['normal_string'] = "cat o' nine tails"
>         super(MyWidget, self).__init__(*args, **kwargs)
>
> w = MyWidget()
> w.render("field_name", "")
>
> #=> u' name="field_name" safe_string="will o the wisp" />'
>
> You can see that both the unsafe and safe strings were escaped.  I
> don't know if this is intentional or not, but it prevents me from
> making something like:
>
> 
>
> because it is always escaping my single-quotes.  Is this the desired
> behavior?  Anyway, like I said, the culprit is:
>
> # django.forms.util
>
> def flatatt(attrs):
>
> """
>     Convert a dictionary of attributes to a single
> string.
>     The returned string will contain a leading space followed by
> key="value",
>     XML-style pairs.  It is assumed that the keys do not need to be
> XML-
> escaped.
>     If the passed dictionary is empty, then return an empty
> string.
>     """
>     return u''.join([u' %s="%s"' % (k, escape(v)) for k, v in
> attrs.items()])  # <-- right there, the escape(v) call... should this
> be conditional_escape?
>
> Since there are a lot of calls to mark_safe scattered through the
> widget and form-level calls used in rendering, I assume you're meant
> to be able to mark something as safe down here and have it get to the
> top level unaltered...  no?
>
> -Alex
--~--~-~--~~~---~--~~
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 inheritance

2008-08-25 Thread fax8

Hi guys,

anyone can tell me why the following does not works as expected?

I mean why, when displaying the form with:

  form = RenderForm()
  return render_to_response('add_render.html', {'form': form},
context_instance=RequestContext(request))

the subject field is not displayed?

And why the 'clean_simple_bitrate' method, given that simple_bitrate
is a field of the Render model, is not executed?


Thanks for your help,

Fabio Varesano



forms.py:

from django import forms
from django.forms import ModelForm
from django.forms import ValidationError
from models import Render

#RenderForm = form_for_model(Render)

class BasicRenderForm(ModelForm):
  class Meta:
model = Render


class RenderForm(BasicRenderForm):
  #raise ValidationError('Enter at least one e-mail address.')

  subject = forms.CharField(max_length=100)

  def clean_simple_bitrate(self):
raise ValidationError('Enter at least one e-mail address.')
print value + 'ciao'



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



Widget rendering working as intended?

2008-08-25 Thread Alex G

Hi there,

I have been trying to get a function call into a widget argument, but
have not been able to at the template level, because it would appear
that my safe_strings are being escaped somewhere down in the
framework.  I have created a widget and mark_safe'd an attribute
value, but no matter what, since it's pre-escaped by the time it
bubbles up to the template level, I can't not escape it (well... I
could use an html library to de-escape it, but that seems kludgy).

I've traced the execution and found the culprit to be the
django.forms.util.flatatt function.  That is:

from django import forms
from django.utils.safestring import mark_safe

class MyWidget(forms.TextInput):
def __init__(self, *args, **kwargs):
attrs = kwargs.setdefault('attrs', {})
attrs['safe_string'] = "will o' the wisp"
attrs['normal_string'] = "cat o' nine tails"
super(MyWidget, self).__init__(*args, **kwargs)

w = MyWidget()
w.render("field_name", "")

#=> u''

You can see that both the unsafe and safe strings were escaped.  I
don't know if this is intentional or not, but it prevents me from
making something like:



because it is always escaping my single-quotes.  Is this the desired
behavior?  Anyway, like I said, the culprit is:

# django.forms.util

def flatatt(attrs):
 
"""
Convert a dictionary of attributes to a single
string.
The returned string will contain a leading space followed by
key="value",
XML-style pairs.  It is assumed that the keys do not need to be
XML-
escaped.
If the passed dictionary is empty, then return an empty
string.
"""
return u''.join([u' %s="%s"' % (k, escape(v)) for k, v in
attrs.items()])  # <-- right there, the escape(v) call... should this
be conditional_escape?

Since there are a lot of calls to mark_safe scattered through the
widget and form-level calls used in rendering, I assume you're meant
to be able to mark something as safe down here and have it get to the
top level unaltered...  no?

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



Re: Template path for new admin doc broken in revision 8520?

2008-08-25 Thread Shadow

Hi, not an expert!

but I think I had this same problem. The admin docs were fairly
recently moved into a separate app. So you'll need to update your urls
to something like:
--
from django.conf.urls.defaults import *
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
# Admin
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),
)
--

I think that's right?
--~--~-~--~~~---~--~~
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: urlpatterns and generic views cheatsheet

2008-08-25 Thread rex

Tim Chase <[EMAIL PROTECTED]> [2008-08-25 08:43]:
>
>> It's not terribly obvious from the scribd layout, but at the
>> top (above the document) there's a "download" link or similar,
>> and there you can download the original PDF.
>
>...which expects that I create login...

Copy & paste doesn't work. Trying to email it to myself results in
nothing happening. 

>Given that the source is likely just a PDF, posting a link to it 
>somewhere is a lot less painful than using Scribd.  It's like 
>they (Scribd) asked the question "how can we best come between 
>site-visitors and the content our users want visitors to view?" 
>resulting in this solution.  It's not like they're charging for 
>the content (AFAIK) so forcing me to create a login fails to net 
>them anything but useless marketing data, a plonk in my 
>cookie-jar, and a seething user that will now decry them at any 
>convenient opportunity.

Exactly my thoughts. This company has a solution to a non-existent
problem. 

>From the FAQ:

My account has been suspended/terminated for abuse! Will I get access to my 
documents?

All documents belonging to users that we have terminated for abuse
are deleted at the point of termination. Scribd will not provide
backups or access to these deleted documents.

How does Scribd define "abuse?"

Abuse is any activity that detracts from Scribd, or Scribd's
community. 

IOW, your documents may vanish at the whim of Scribd, and they
cannot be recovered.

-rex

--~--~-~--~~~---~--~~
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: photologue installation

2008-08-25 Thread Karen Tracey
On Mon, Aug 25, 2008 at 12:39 PM, Briohny <[EMAIL PROTECTED]> wrote:

>
> I'm using the Django-1.0-alpha_2 version and I'm trying to install the
> photologue application.  When i run my database sync it's coming up
> with the following error:
>
>
> File "C:\Documents and Settings\TR\Sample
> > Projects\newsite\photologue\models.p
> > y", line 95, in Gallery
> >help_text='A "Slug" is a unique URL-friendly title for an object.')
> > File
> > "c:\python25\Lib\site-packages\django\db\models\fields\__init__.py",
> > line
> >  920, in __init__
> >super(SlugField, self).__init__(*args, **kwargs)
> > TypeError: __init__() got an unexpected keyword argument
> 'prepopulate_from'
>
>
>
> I think this may be due to the alpha version.  Is there an easy fix or
> should i just wait for the more stable version to be released?
>
>
You're apparently using a version of photologue that was written to run on a
version of Django from before newforms-admin was merged to trunk.  Looking
at the google code page for photologue and browsing its current svn code it
is clear the current photologe code has been updated to work with current
Django, so you need to get a more recent photologue.  If they don't have a
prepackaged version that works with current Django you may have to pull
photologue directly from its svn repository.

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: ANN: An unofficial companion to Practical Django Projects

2008-08-25 Thread [EMAIL PROTECTED]

Thanks for the update, Brett. I just did a "svn up" on the django code
last night and found the code in the book no longer work. I will keep
track of your blog.

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



photologue installation

2008-08-25 Thread Briohny

I'm using the Django-1.0-alpha_2 version and I'm trying to install the
photologue application.  When i run my database sync it's coming up
with the following error:


File "C:\Documents and Settings\TR\Sample
> Projects\newsite\photologue\models.p
> y", line 95, in Gallery
>help_text='A "Slug" is a unique URL-friendly title for an object.')
> File
> "c:\python25\Lib\site-packages\django\db\models\fields\__init__.py",
> line
>  920, in __init__
>super(SlugField, self).__init__(*args, **kwargs)
> TypeError: __init__() got an unexpected keyword argument 'prepopulate_from'



I think this may be due to the alpha version.  Is there an easy fix or
should i just wait for the more stable version to be released?

Cheers,
Briohny

--~--~-~--~~~---~--~~
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 know which fields a model contains?

2008-08-25 Thread Jim D.

I'm pretty new to python myself, but my favorite way to inspect
objects that I have found so far is the builtin method dir(). As in:

dir(Publisher.objects.get(pk=1))

dir() tells you all of the methods and attributes for a given object,
though it doesn't display the value of attributes.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Issue with serializing a queryset that includes a custom SQL field defined by extra()

2008-08-25 Thread Jim D.

I think this might be a bug in source code, but before I report a
ticket I thought I would ask just to ensure it's not me doing
something wrong/stupid.

In brief, I have a (MySQL) database table containing latitude and
longitude columns. I am finding records from this table and sorting
them based on distance, and to do this I'm adding a custom column in
the select statement using the extra() QuerySet function.

So here's the relevant code for this part:

entries = Entry.objects.filter(type='country')
entries = entries.extra(select={'distance': "SQRT(POW((locations.lat-
%s),2) + POW((locations.lon-%s),2))"}, select_params=(str(centerLat),
str(centerLng)))
entries = entries.extra(order_by = ['distance'])[:100]

In a nutshell, this code defines a custom column "distance" and uses
some MySQL numeric functions to calculate a hypotenuse to get the
distance value. The result set is ordered by this column. This works
great.

Now for the issue...when I serialize this code as follows:

from django.core import serializers

json_serializer = serializers.get_serializer("json")()
json_serializer.serialize(entries, ensure_ascii=False,
stream=response, fields=('title','lat','lon','distance'))

The problem being that the "distance" column does not end up getting
included in the json output. The other columns are included, however,
no problem.

I have even inspected the queryset in entries an confirmed that each
object does in fact contain a distance attribute, as a float, which is
set properly.

Sofinally to my question...is there an issue of some kind with the
way the serializer handles extra fields, or am i just doing it wrong?

FYI i'm on the latest release Django version 1.0-beta_1-SVN-8539.

Thanks for any help or suggestions you guys can provide!


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



ANN: Django group in Israel

2008-08-25 Thread Ahik Man
Hi All,

We have an Israeli group for web-app development with Python. Well, it is
mostly Django.
We are going to have our second meeting in two weeks for now.
The meeting will be title is: Django and Google-app.

If you are interesting:
   come join us at: http://groups.google.com/group/pyweb-il
else:
   please ignore


Cheers,
Ahik Man




--~--~-~--~~~---~--~~
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 know which fields a model contains?

2008-08-25 Thread Alexis Bellido

Thanks everybody, using  __dict__ and meta_fields helped but the most
complete data came from the documentation in admin, that's exactly
what I needed :)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Modules path when importing models

2008-08-25 Thread Alexis Bellido

I'm reading the Django book and playing with the  'mysite' test site,
in many parts I've noticed something like this in views.py:

from mysite.models import Event, BlogEntry

I was wondering if it's good practice using 'mysite.models' (which
seems to be an 'absolute path' for importing) or if it would be better
using just:

from models import Event, BlogEntry

(which seems to be a 'relative path' because usually views.py is in
the same directory than models.py).

Could somebody explain a little about the best way to do the imports?

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



Foreign key on forms

2008-08-25 Thread chewynougat

Hi,

I need to display a form such that the foreign key fields are
displayed exactly like that in djangoproject.com/documentation/
tutorial02, where up to 3 entries can be made using the fk fields. It
would be nice to have the same functionality provided in this tutorial
for normal forms, not just the admin. Any pointers on how to do this
would be much appreciated.

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: Changing Login Page for Admin

2008-08-25 Thread Tim Sawyer

On Sunday 24 Aug 2008, Tim Sawyer wrote:
> Hi,
>
> I'm using the newforms admin stuff, and I'd like to use my own URL for the
> login page for the admin site.
>
> So, if someone goes to /admin on my site (which is where the admin site is
> located), I'd like to redirect to /private/login/?next=/admin.
>
> (The reason I want to do that is that I have some custom code on the login
> that looks for and removes a suffix before passing through to the user
> authentication code.)
>
> Is this straightforward?

Probably not the neatest solution, but it works.

1) in urls.py, set the login template after autodiscover:

admin.autodiscover()
admin.site.login_template = 'registration/login_redirect.html'

In the registration/login_redirect.html template, redirect to the login page 
you want:








Tim.

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



DATE_WITH_TIME_FULL bug in multiple i18n???

2008-08-25 Thread est

Hi guys! This is my first time submitting a ticket to a OSS project.
So if I did something wrong plz tell me :-)

http://code.djangoproject.com/ticket/8541

I discovered in history of a custom model's auto-admin interface. that
the date/time displays wrong. in zh_CN locale is shows

SunPMChina Standard TimeE_340China Standard Time19_China Standard Time0
八月E_八月1221304880TrueTrue

when I look into django source it was this file

C:\Python25\Lib\site-packages\django\contrib\admin\templates\admin
\object_history.html
  24: {{ action.action_time|
date:_("DATE_WITH_TIME_FULL") }}

but in zh_CN locale file \django\conf\locale\zh_CN\LC_MESSAGES
\django.po

#: contrib/admin/templates/admin/object_history.html:26
msgid "DATE_WITH_TIME_FULL"
msgstr "DATE_WITH_TIME_FULL"

I think this is wrong? Translator might not get what
DATE_WITH_TIME_FULL is really for?

Also in many other locale file e.g. C:\Python25\Lib\site-packages
\django\conf\locale\ar\LC_MESSAGES\django.po

#: .\contrib\admin\templates\admin\object_history.html.py:26
msgid "DATE_WITH_TIME_FULL"
msgstr ""

This will make auto-admin's history page, date/time row to be blank.

When I changed it to Y-m-d H:M:S

it displays

2008-08-24 19:八月:th

Which is also wrong.

Is there a way to change it to: "2008-08-25 23:49:21"? Which is the
most common way ppl see datetime here in China. I do not know how to
write date/time strings corretly sorry :-(

I see there's a similar ticket here http://code.djangoproject.com/ticket/880

btw When does djangoproject.com start i18n of docs.djangoproject.com?
I will participate :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to use Django + Postgresql on leopard?

2008-08-25 Thread Theme Park Photo, LLC

Thanks for the tips! I'll try again. I have to admit, I'm one of those
new "Switchers" (despite being a former Apple employee, I never ran
Mac at home!) and exepct all Unix-y things to "just work".

I'm going to clean out everything I tried to install and then attempt
the Fink and the MacPorts suggestion. I have Django with MySQL running
on the Mac, but I prefer Postgresql

On Aug 23, 3:36 pm, Jon Brisbin <[EMAIL PROTECTED]> wrote:
> I do *all* my development on OS X Leopard! I just used the version in  
> MacPorts. You have to compile psycopg2 against the same architecture  
> as the server libraries (64 or 32-bit, depending on what you're on). I  
> use a MacBook Pro and I had to add the 64-bit flags. I was going to  
> post what I changed in the Makefile, but I've deleted it.
>
> I've used Cygwin a lot and I don't find it easier to use than the Mac  
> at all. Of course, I would say that since I'm a die-hard Mac user.
>
> Are you using MacPorts? If so, there's a version in there that will  
> compile fine. I use Postgres 8.3 and I had to make sure my CFLAGS and  
> LDFLAGS were set such that /Library/PostgreSQL8 was found by psycopg's  
> configure. It's called py25-psycopg2.
>
> Thanks!
>
> Jon Brisibnhttp://jbrisbin.com
>
> On Aug 23, 2008, at 1:08 PM, Theme Park Photo, LLC wrote:
>
>
>
> > I have been unable to get Django + Postgres to run on Leopard.
>
> > (Works fine on Windows and Linux. Personally, I find it much easier to
> > get most open source stuff to run on Windows or Windows+Cygwin than on
> > the Mac!)
>
> > Anyway, the problem isn't Django, and it isn't Postgres. It's
> > psycopg2! I can't get it to build! And the "MacPorts" version that
> > everyone tells me to use is for Python 2.4, and I'm on Python 2.5.
>
> > Has anyone gotten Django + Postgres + Python 2.5 + psycopg2 to run on
> > Leopard? Or should I just use the mac as a pretty box to browse the
> > web with?
--~--~-~--~~~---~--~~
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: Calling attributes from other models

2008-08-25 Thread Norman Harman

Matt Berg wrote:
> I apologize, I realize this is probably documented somewhere.
> 
> Say I have 2 models.
> 
> Artist and Album
> 
> Album has a foreign key to Artist.
> 
> I want to do a list_display of Albums something like this...
> 
>   list_display = ('album','release_date','artist')
> 
> This works fine and displays the info under the key for Artist.  What
> I would like to do is access some of the other attributes of Artist.
> Trying artist.hometown and artist[hometown] doesn't work.

One way to do this is to create helper functions.

def _get_artist_hometown(self):
return self.artist.hometown


list_display = ('album','release_date',_get_artist_hometown)

There're different options see 
http://www.djangoproject.com/documentation/admin/#list-display

-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
It's August!  Keep your cool with the Statesman.  Check out our hot
deals in print and online for back-to-school savings and more!

--~--~-~--~~~---~--~~
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: disable admin log

2008-08-25 Thread Malcolm Tredinnick


On Mon, 2008-08-25 at 09:12 -0700, chefsmart wrote:
> Can someone in the know please confirm the existence or otherwise of
> an option to disable logging in admin?

Such an option does not exist.

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: disable admin log

2008-08-25 Thread chefsmart

Can someone in the know please confirm the existence or otherwise of
an option to disable logging in admin?

On Aug 14, 12:52 pm, chefsmart <[EMAIL PROTECTED]> wrote:
> In my case I don't require the admi log. To save trips to the database
> server, is there a way to disable logging in admin?
--~--~-~--~~~---~--~~
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 creation of model with geodjango ?

2008-08-25 Thread guillaume

Hi Justin,

Glad to hear you too actually ! Your analysis is completely right !
I've already build an app which allows to feed a postgis database with
Django. But geodata is completely disconnected from the app itself. So
yes, the idea would be to automatically build a geodjango model from
that table, and publish it on the admin site to let people manage the
data from there. And I definitely understand it is not trivial at
all !

Regards,

Guillaume

On 19 août, 16:57, Justin Bronn <[EMAIL PROTECTED]> wrote:
> > Yes, actually I didn't hope anything else.
> > I'll try to catch somegeodjangoguys up in Cape Town FOSS4G to have a
> > chat about this. It can be something I can find funding for, as it is
> > extremely critical in deploying Spatial data infrastructures.
>
> Guillaume,
>
> Howdy -- nice hearing from you again.  Unfortunately, I won't be in
> Cape Town, but Travis Pinney and Josh Livni will be there 
> representingGeoDjango.
>
> I've successfully created dynamic models in private, production code
> usingGeoDjango, but not quite to the full extent I think you want.
> If I understand, you wish to go from spatial data source (e.g.,
> shapefile) -> admin automatically, with the intermediate step of
> creating spatial database tables and importing.  I believe this is
> possible, but not trivial.
>
> Regards,
> -Justin
--~--~-~--~~~---~--~~
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 validation

2008-08-25 Thread julianb

On Aug 23, 11:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> This seems to have done the trick. Thanks for your help.
>
> def index(request):
>     if request.method == 'POST':
>         form = pasteForm(request.POST)
>         if form.is_valid():
>             name = form.cleaned_data['name']
>             log = form.cleaned_data['log']
>             return HttpResponseRedirect('/success/')
>         else:
>             return render_to_response('pastebin.html', {'form': form})
>     else:
>         form = pasteForm()
>         return render_to_response('pastebin.html', {'form': form})

Why not

def index(request):
if request.method == 'POST':
form = pasteForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
log = form.cleaned_data['log']
return HttpResponseRedirect('/success/')
else:
form = pasteForm()
return render_to_response('pastebin.html', {'form': form})

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



ANN: An unofficial companion to Practical Django Projects

2008-08-25 Thread Brett H

I'm really enjoying learning Django through Practical Django Projects
(thanks James), but obviously with the newforms admin in 1.0 the
examples needed a bit of re-working.

After seeing a few people asking similar questions in this group I
decided to just write it up for others who may have picked up the
book, and hopefully save the odd person from puzzling over things like
the opaque 'Improperly Configured' error - though it is simpler to
resolve when the examples are uncomplicated to begin with.

I'm only half way through the book and have only written up comments
on the first 3 chapters but I figured there was enough content to put
it out there at this point.

http://blog.haydon.id.au/2008/08/notes-on-practical-django-projects.html

Obviously most technical books have a limited lifespan but I felt this
one really deserves a while in the sun before it becomes buried under
the post 1.0 development.

--~--~-~--~~~---~--~~
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: urlpatterns and generic views cheatsheet

2008-08-25 Thread Tim Chase

> It's not terribly obvious from the scribd layout, but at the
> top (above the document) there's a "download" link or similar,
> and there you can download the original PDF.

...which expects that I create login...

Given that the source is likely just a PDF, posting a link to it 
somewhere is a lot less painful than using Scribd.  It's like 
they (Scribd) asked the question "how can we best come between 
site-visitors and the content our users want visitors to view?" 
resulting in this solution.  It's not like they're charging for 
the content (AFAIK) so forcing me to create a login fails to net 
them anything but useless marketing data, a plonk in my 
cookie-jar, and a seething user that will now decry them at any 
convenient opportunity.



-tim






--~--~-~--~~~---~--~~
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: Outputting PDF

2008-08-25 Thread saeb

 forgot to mention, that I did HttpResponse(response)
and there was just gibberish displayed...



On Aug 25, 10:00 am, saeb <[EMAIL PROTECTED]> wrote:
> Thanks, I did use form validation as inhttp://dpaste.com/73704/but I
> couldn't get the validation to work. I wasn't sure what I was doing
> wrong, so I resorted to the ad hoc method you are seeing, hoping to
> resolve it once I get the view working. In regards to PDF generation,
> I wasn't sure what I am supposed to do with the response object. I
> want it to be a 2- click process, where user may or may not generate
> the PDF. Can you point me to an example for better idea? I couldn't
> get much out of the documentation.
>
> On Aug 25, 9:02 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Mon, Aug 25, 2008 at 9:01 AM, saeb <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > Following is my view.http://dpaste.com/73677/
> > > In the template I have 2 buttons, one is to retrieve results for the
> > > id typed in the input box and other is to generate a PDF of the
> > > results (if user desires). The results are generated fine, but when I
> > > click the generatePDF button it gives a DataError saying -- " invalid
> > > input syntax for integer: ""  ". Can anyone give me a better idea to
> > > achieve this?
>
> > First, you appear to be using Django forms a little but not really.
> > Specifically you are not using them to validate the input, and your ad-hoc
> > checking of  len(request.POST) to see if you have input is likely not doing
> > what you think.  Even if the "user_id" field of your form is left blank, it
> > will be present in request.POST with a value of an empty string.  Your
> > routine would be much cleaner if you take advantage of the built-in
> > validation support of Django forms.
>
> > The DataError "invalid input syntax for integer" is likely coming from the
> > database.  Note when you call gen_pdf (which returns an HttpResponse) you do
> > nothing with the return value and just fall through to the subsequent code.
> > You set deal_avail to true because it's a post and len(request.POST) >= 0
> > (request_id is there, it's an empty string).  When you call:
>
> > deals = Deals.my_manager.get_open_deals(requested_id)
>
> > with requested_id set to the empty string the database complains that an
> > empty string is not a valid integer.
>
> > 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: i18 returns me an UnicodeDecodeError

2008-08-25 Thread Malcolm Tredinnick


On Sun, 2008-08-24 at 23:29 -0700, Jose Jiménez wrote:
> Hello,
> 
> i'm using the stable version (0.96.2) of Django.
> When newforms library try to returns a field's validation error, if
> his translation contains any accent, it returns me an
> UnicodeDecodeError. If i deactivate i18n in settings.py all runs
> correctly (showing the messages in english).
> The error occurs in line 387 of fields.py:
> 
> raise ValidationError(gettext(u'Select a valid choice. %s is not one
> of the available choices.') % val)

Django 0.96.2 has a lot of problems with non-ASCII support. In this
case, the problem is that gettext() returns an bytestring which contains
non-ASCII data and things go wrong.

The solution is "don't do that" for that release. We've put a lot of
effort into making non-ASCII support work transparently, out of the box,
since the 0.96 release, so in 1.0 this will work without problems.

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: Write Caching

2008-08-25 Thread TiNo
Maybe this could be a solution:
http://www.stardata.it/articoli_en/triggers_on_select_articoli_en.html

No idea how much overhead that would create though.

On Sun, Aug 24, 2008 at 5:43 AM, Steve Potter <[EMAIL PROTECTED]>wrote:

>
> I am working on a project that involves logging every time an object
> is displayed, and I can have anywhere from tens to hundreds of objects
> displayed per page.
>
> So needless to say I can quickly be generating very large numbers of
> queries to the database to log all of these displays.
>
> What I am looking for is some method of write caching these logs so I
> only write to the database every 'n' times the object is displayed, or
> when the cache gets too old.
>
> Has anyone done anything like this?
>
> Maybe someone just has a better suggestion for how to log this data
> with less DB queries?
>
>
> Thanks,
>
> Steve
>
> >
>

--~--~-~--~~~---~--~~
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: custom widget necessary?

2008-08-25 Thread peter_g


Thank you, Norman!

> > Do you have links to examples?
>
> http://www.djangosnippets.org/snippets/937/

--~--~-~--~~~---~--~~
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: Boosting your productivity when debugging Django apps

2008-08-25 Thread Wes Winham

I use Wing IDE (not free, wingide.com). It contains a full debugger
that worked for me with Django with minimal fuss. I can step through
the whole thing by debugging the manage.py runserver --noreload

The thing I find most valuable about their debugger is that it gives
you a full python shell (with autocomplete) that evaluates to wherever
your debugger is at the time. So you can set a breakpoint in a
function that's giving you trouble and then run whatever python
commands you'd like to in order to figure out what's going on. Pretty
solid. I used Eclipse with pydev for 4 months and it was causing some
stability issues with my machine. I was also having some trouble with
the autocomplete terms and it doesn't have a debugger that I could get
working. Eclipse + pydev is the best free option I found, but throwing
down the cash for Wing IDE has been a good investment in my particular
situation.

Hope that helps
-wes

On Aug 22, 2:20 pm, Delta20 <[EMAIL PROTECTED]> wrote:
> This question is aimed at those of you who, like me, come from a Java
> and C++ background and are used to being able to debug things with a
> debugger - setting breakpoints, stepping through code, evaluating
> expressions, etc. What do you find to be the most productive approach
> to debugging Django apps?
>
> Personally, I've been trying to get PyDev to work but attempting to
> run a Django app crashes Eclipse every time for me so I haven't been
> able to evaluate its debugger. I don't much like Eclipse anyway and am
> hoping the NetBeans Python debugger will provide a viable
> alternative.
>
> I'm new to both Python and Django, and right now I feel horribly
> unproductive without an efficient way to debug things.
--~--~-~--~~~---~--~~
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: urlpatterns and generic views cheatsheet

2008-08-25 Thread Idan Gazit

Tim,

It's not terribly obvious from the scribd layout, but at the top
(above the document) there's a "download" link or similar, and there
you can download the original PDF.

-I

On Aug 25, 5:50 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Here is a summary of all the tutorials and docs that I have
> > read on urlpatterns and generic views. It is a 2 page,
> > concise, example code based cheat sheet.
>
> >http://www.scribd.com/doc/4975790/urlpatterns-for-django-cheatsheet
>
> Nifty, but scribd is annoying as heck.  Printing from scribd was
> also an abysmal failure.  Whatever happened to just posting HTML
> or a PDF somewhere?
>
> -tim
--~--~-~--~~~---~--~~
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: urlpatterns and generic views cheatsheet

2008-08-25 Thread Tim Chase

> Here is a summary of all the tutorials and docs that I have
> read on urlpatterns and generic views. It is a 2 page,
> concise, example code based cheat sheet.
> 
> http://www.scribd.com/doc/4975790/urlpatterns-for-django-cheatsheet

Nifty, but scribd is annoying as heck.  Printing from scribd was 
also an abysmal failure.  Whatever happened to just posting HTML 
or a PDF somewhere?

-tim




--~--~-~--~~~---~--~~
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: Outputting PDF

2008-08-25 Thread saeb


Thanks, I did use form validation as in http://dpaste.com/73704/ but I
couldn't get the validation to work. I wasn't sure what I was doing
wrong, so I resorted to the ad hoc method you are seeing, hoping to
resolve it once I get the view working. In regards to PDF generation,
I wasn't sure what I am supposed to do with the response object. I
want it to be a 2- click process, where user may or may not generate
the PDF. Can you point me to an example for better idea? I couldn't
get much out of the documentation.



On Aug 25, 9:02 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Aug 25, 2008 at 9:01 AM, saeb <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Following is my view.http://dpaste.com/73677/
> > In the template I have 2 buttons, one is to retrieve results for the
> > id typed in the input box and other is to generate a PDF of the
> > results (if user desires). The results are generated fine, but when I
> > click the generatePDF button it gives a DataError saying -- " invalid
> > input syntax for integer: ""  ". Can anyone give me a better idea to
> > achieve this?
>
> First, you appear to be using Django forms a little but not really.
> Specifically you are not using them to validate the input, and your ad-hoc
> checking of  len(request.POST) to see if you have input is likely not doing
> what you think.  Even if the "user_id" field of your form is left blank, it
> will be present in request.POST with a value of an empty string.  Your
> routine would be much cleaner if you take advantage of the built-in
> validation support of Django forms.
>
> The DataError "invalid input syntax for integer" is likely coming from the
> database.  Note when you call gen_pdf (which returns an HttpResponse) you do
> nothing with the return value and just fall through to the subsequent code.
> You set deal_avail to true because it's a post and len(request.POST) >= 0
> (request_id is there, it's an empty string).  When you call:
>
> deals = Deals.my_manager.get_open_deals(requested_id)
>
> with requested_id set to the empty string the database complains that an
> empty string is not a valid integer.
>
> 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: Segmentation fault (postgresql - psycopg2)

2008-08-25 Thread kire

Just to mention: it's appearantly a psycopg2 error. with psycopg1
everything worked fine.

On Aug 25, 10:18 am, kire <[EMAIL PROTECTED]> wrote:
> My site works fine locally mysql, sqlite and postgresql. On the server
> it worked fine om mysql - myisam (well, as long you can speak about
> fine for that database). I'm trying to convert to postgresql,
> everything is configured correct and when i execute 'python manage.py
> syncdb --noinput' I just nicely receive Segmentation fault.
>
> Since I have 3 django installations (don't ask, we're converting other
> apps right now) I thought it could be manage.py using an outdated
> django distribution, so I ran 'python manage.py --version', which
> gives me nicely '1.0-beta_1-SVN-8534'. So, no problem there (also
> tried with older revisions to make sure).
>
> I have to say: the database is 'remote' (2 different virtual machines,
> one for database, one for apache). But this works since our phppgadmin
> is doing it's job.
>
> Any ideas?
--~--~-~--~~~---~--~~
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: Custom manager for many-to-many traversal

2008-08-25 Thread John M

Since my_book.auther_set.all() returns a QS, can't you just say
something like ...all().filter(author__isalive=True) or something like
that?  I've never tried, but I thought that django would figure it
out?

J

On Aug 25, 12:11 am, MrJogo <[EMAIL PROTECTED]> wrote:
> How do I create a custom manager for many-to-many traversal? An
> example will illustrate what I want to do better. Suppose I have the
> following models.py:
>
> class Book(models.Model):
>   title = models.CharField(max_length=100)
>
> class Author(models.Model):
>   books = models.ForeignKey(Book)
>   name = models.CharField(max_length=100)
>   is_alive = models.BooleanField()
>
> This is a many-to-many relationship: a book can have multiple authors
> and an author can have written multiple books.
>
> If I have a book object my_book, and I want to get all the authors, I
> do my_book.author_set.all(). How can I set up a custom manager to only
> get living authors of that book, so I could do something like
> my_book.livingauthor_set.all()?
>
> 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: custom widget necessary?

2008-08-25 Thread Norman Harman

peter_g wrote:
> Hi!
> 
> I have datetime fields like "createdate" or "modified" in some of my
> models.
> Do I need to create custom widgets if i want their time and date to
> be displayed in the admin area (change-form) and not the default
> editable representation (text fields, with "now" etc. shortcuts)?
> 
> Like, e.g.
> 
> Created: 08/25/2008 09:20am
> 
> Do you have links to examples?

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


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
It's August!  Keep your cool with the Statesman.  Check out our hot
deals in print and online for back-to-school savings and more!

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



Calling attributes from other models

2008-08-25 Thread Matt Berg

I apologize, I realize this is probably documented somewhere.

Say I have 2 models.

Artist and Album

Album has a foreign key to Artist.

I want to do a list_display of Albums something like this...

list_display = ('album','release_date','artist')

This works fine and displays the info under the key for Artist.  What
I would like to do is access some of the other attributes of Artist.
Trying artist.hometown and artist[hometown] doesn't work.

Thanks for the help!

Matt




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



Hosting with support for Satchmo webstore

2008-08-25 Thread Benedict Verheyen

Hi,

i need to develop a website with a webstore and i thought it was
the perfect time to use Django & more specific Satchmo.
However, Satcho has a big list of requirements and i'm not sure
if this will work with the usual providers that have Django enabled.
These are the requirements:
* Elementtree (included in Python 2.5+)
* Python cryptography toolkit (Windows binary)
* ReportLab
* Tiny RML2PDF (download link)
* Django Threaded Multihost
* Django Registration

If these aren't installed, i would need to look at a VPS then?
Anyone running Satchmo?

Regards,
Benedict


--~--~-~--~~~---~--~~
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: Random NoReverseMatch

2008-08-25 Thread Robin

Hello,

i have the same exception and exactly as Julien explained in the dev
server works fine ... and also works fine with fast_cgi, but I am
using apache + mod_wsgi and it didn't work with the same problem:
NoReverseMatch

Has any of you any clue to this error ?

thanks in advance,
r

On Aug 16, 8:16 pm, Alberto Piai <[EMAIL PROTECTED]> wrote:
> On Aug 16, 12:01 am, Julien Phalip <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > It's likely that there is a typo somewhere in your templates, either
> > you didn't write the view name properly, or you didn't provide the
> > right parameters.
> > In the error message, there should be the name of the view. Look up
> > every occurrence et double check that you haven't made any typo.
>
> I'm checking everything again. But actually I don't think the
> problem's there, as everything works fine when run from django's dev
> server, and now it's been working fine for some hours even on lighttpd
> +fcgi. When the problem appears again I'll send the traceback.
>
> Thanks for you help,
>
> Alberto
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



return django models using custom sql

2008-08-25 Thread chefsmart

I found a solution called djselect on this group. But is there a
django-istic way of running custom sql queries and returning the
results as django models?
--~--~-~--~~~---~--~~
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: Outputting PDF

2008-08-25 Thread Karen Tracey
On Mon, Aug 25, 2008 at 9:01 AM, saeb <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> Following is my view. http://dpaste.com/73677/
> In the template I have 2 buttons, one is to retrieve results for the
> id typed in the input box and other is to generate a PDF of the
> results (if user desires). The results are generated fine, but when I
> click the generatePDF button it gives a DataError saying -- " invalid
> input syntax for integer: ""  ". Can anyone give me a better idea to
> achieve this?
>
>
First, you appear to be using Django forms a little but not really.
Specifically you are not using them to validate the input, and your ad-hoc
checking of  len(request.POST) to see if you have input is likely not doing
what you think.  Even if the "user_id" field of your form is left blank, it
will be present in request.POST with a value of an empty string.  Your
routine would be much cleaner if you take advantage of the built-in
validation support of Django forms.

The DataError "invalid input syntax for integer" is likely coming from the
database.  Note when you call gen_pdf (which returns an HttpResponse) you do
nothing with the return value and just fall through to the subsequent code.
You set deal_avail to true because it's a post and len(request.POST) >= 0
(request_id is there, it's an empty string).  When you call:

deals = Deals.my_manager.get_open_deals(requested_id)

with requested_id set to the empty string the database complains that an
empty string is not a valid integer.

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



Outputting PDF

2008-08-25 Thread saeb

Hi,

Following is my view. http://dpaste.com/73677/
In the template I have 2 buttons, one is to retrieve results for the
id typed in the input box and other is to generate a PDF of the
results (if user desires). The results are generated fine, but when I
click the generatePDF button it gives a DataError saying -- " invalid
input syntax for integer: ""  ". Can anyone give me a better idea to
achieve this?

thanks
saeb


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



custom widget necessary?

2008-08-25 Thread peter_g

Hi!

I have datetime fields like "createdate" or "modified" in some of my
models.
Do I need to create custom widgets if i want their time and date to
be displayed in the admin area (change-form) and not the default
editable representation (text fields, with "now" etc. shortcuts)?

Like, e.g.

Created: 08/25/2008 09:20am

Do you have links to examples?

Thanks!
Peter.


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



Re: Template path for new admin doc broken in revision 8520?

2008-08-25 Thread Eric VW

I opened the ticket and I have a patch out there to fix the problem.
The real problem is 'django.contrib.admindocs' doesn't really deserve
its own contrib app page in the documents.  It is more of a helper
application than anything.  It just needs to be enabled via
INSTALLED_APPS and adding a one-liner in the urls.py when you open a
project would seem like a suitable location.

On Aug 24, 2:18 pm, Ulf Kronman <[EMAIL PROTECTED]> wrote:
> Thanks Karen and Shadow,
>
> > > > urlpatterns = patterns('',
> > > >    #Admin
> > > >    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > > >    (r'^admin/(.*)',admin.site.root),
> > > > )
> > > You need that in urls.py,  plus you need  'django.contrib.admindocs' added
> > > to your INSTALLED_APPS.  There's a ticket open 
> > > (http://code.djangoproject.com/ticket/8496) for getting this last bit
> > > mentioned somewhere in the docs, at the moment I don't believe it's
> > > mentioned anywhere.
>
> I had the urlpatterns mentioned by Shadow already installed, but I
> missed the django.contrib.admindocs app that Karen mentioned.
>
> I have installed the admindocs app now, andadmindocs are working
> fine for me again.
>
> Thanks for quick help,
> Ulf
--~--~-~--~~~---~--~~
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: Hosting with support for Satchmo webstore

2008-08-25 Thread Benedict Verheyen

David Zhou wrote:
> On Aug 25, 2008, at 8:02 AM, Chris Moffitt wrote:
> 
>> On Mon, Aug 25, 2008 at 5:17 AM, Benedict Verheyen <[EMAIL PROTECTED] 
>>> wrote:
>> Hi,
>>
>> i need to develop a website with a webstore and i thought it was
>> the perfect time to use Django & more specific Satchmo.
>> However, Satcho has a big list of requirements and i'm not sure
>> if this will work with the usual providers that have Django enabled.
>>
>> I don't know of any web hosts that have Satchmo running out of the  
>> box. While there are certainly ways to get it running on a standard  
>> host, I think a VPS is definitely the way to go. The upfront setup  
>> may be a little  bit longer but my opinion is that the long term  
>> hassle factor is a lot less.
> 
> The post may not be relevant anymore, but Brian appears to have gotten  
> Satchmo working on WebFaction:
> 
> http://brianmckinney.net/blog/2007/aug/22/installing-satchmo-webfaction/

Chris, David,

thanks for the info. I'll have a look at the link
and otherwise, i will suggest a VPS to the customer.

Thanks
Benedict


--~--~-~--~~~---~--~~
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: Making Custom Model Methods to Work

2008-08-25 Thread David Zhou


On Aug 24, 2008, at 8:19 AM, rmschne wrote:

> 4.  calling render_to_response is differnt than I thought!
> print render_to_response('mtg_summary.html',{'my_meeting':my_meeting})
>
> Question: in the context of this example, in
> {'my_meeting':my_meeting}), what are these two things opposite of the
> colon?

That's a Python dictionary, with 'my_meeting' as the key, and the  
my_meeting object as the value.  See:

http://docs.python.org/dev/tutorial/datastructures.html#dictionaries

---
David Zhou
[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
-~--~~~~--~~--~--~---



Re: Hosting with support for Satchmo webstore

2008-08-25 Thread David Zhou

On Aug 25, 2008, at 8:02 AM, Chris Moffitt wrote:

> On Mon, Aug 25, 2008 at 5:17 AM, Benedict Verheyen <[EMAIL PROTECTED] 
> > wrote:
>
> Hi,
>
> i need to develop a website with a webstore and i thought it was
> the perfect time to use Django & more specific Satchmo.
> However, Satcho has a big list of requirements and i'm not sure
> if this will work with the usual providers that have Django enabled.
>
> I don't know of any web hosts that have Satchmo running out of the  
> box. While there are certainly ways to get it running on a standard  
> host, I think a VPS is definitely the way to go. The upfront setup  
> may be a little  bit longer but my opinion is that the long term  
> hassle factor is a lot less.

The post may not be relevant anymore, but Brian appears to have gotten  
Satchmo working on WebFaction:

http://brianmckinney.net/blog/2007/aug/22/installing-satchmo-webfaction/

---
David Zhou
[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
-~--~~~~--~~--~--~---



Re: Hosting with support for Satchmo webstore

2008-08-25 Thread Chris Moffitt
On Mon, Aug 25, 2008 at 5:17 AM, Benedict Verheyen <
[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> i need to develop a website with a webstore and i thought it was
> the perfect time to use Django & more specific Satchmo.
> However, Satcho has a big list of requirements and i'm not sure
> if this will work with the usual providers that have Django enabled.
> These are the requirements:
> * Elementtree (included in Python 2.5+)
> * Python cryptography toolkit (Windows binary)
> * ReportLab
> * Tiny RML2PDF (download link)
> * Django Threaded Multihost
> * Django Registration
>
> If these aren't installed, i would need to look at a VPS then?
> Anyone running Satchmo?
>
>
I don't know of any web hosts that have Satchmo running out of the box.
While there are certainly ways to get it running on a standard host, I think
a VPS is definitely the way to go. The upfront setup may be a little  bit
longer but my opinion is that the long term hassle factor is a lot less.

-Chris

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



More advanced test runner available?

2008-08-25 Thread Peter Bengtsson

Is there an alternative to the test runner that comes by defauly with
Django (svn version)? The one that you get doesn't have colour coding
and it doesn't have the option to stop all other tests after the first
failure.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Not displaying data...

2008-08-25 Thread mccomas . chris

I have the following code, http://dpaste.com/73388/

For some reason the data in the rows is not displaying, there are the
correct number of rows in each table so the for tag is working
correctly. Any ideas why the content is not displaying?
--~--~-~--~~~---~--~~
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: S3 tutorial for File Storage Refactor?

2008-08-25 Thread David Larlet


Le 20 août 08 à 17:56, shadfc a écrit :

>
> With the code from the django-storages you referenced installed
> somewhere on PYTHONPATH, its as easy as setting a few things in your
> settings.py.  You can see the docs for the code at
> http://code.larlet.fr/doc/django-s3-storage.html.  Put the Required
> and Optional (if you want it, obviously) stuff in your settings.py and
> fill in the appropriate values for your S3 account.
>
> Now, assuming those settings are all correct, all of your FileFields
> (and thus, ImageFields) should store to S3 into the bucket you set.
> You can continue to use upload_to to prefix the filename within the
> bucket.
>
> Now, I've noticed a few bugs, both of which I've notified David (the
> author) of:
> 1) if you call object.filefield.size, this code will download the
> entire file from S3 just to calculate the size. This happens because
> of the construction of the _open() method on the S3Storage class.  It
> should not make the S3 get call (which downloads the file).  The
> workaround for now is not to use the size property with this code, but
> the more permanent fix is to delay reading of the file from S3 until
> read() is called on a S3StorageFile object.
> 2) I cannot get images to store correctly to S3 when using an
> ImageField. They appear in the bucket with a small filesize change,
> but no software I have will recognize them as valid images.  Storing
> images (and any other file) via a FileField works just fine and the
> files are not corrupted.  Strangely, storing images via ImageField on
> the FileSystemStorage backend works just fine, so it only seems to be
> the combination of an ImageField while using this S3 backend that is
> the problem.  I am not sure where the bug in this is.  If you give it
> a try, see if you can verify this bug for me.
>
> Jay

Hi Jay,

I plan to work on this tonight because that's clearly a blocking  
point. Thanks for reporting those bugs.

Best,
David



--~--~-~--~~~---~--~~
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: FileStorage S3Storage Error importing storage module S3Storage

2008-08-25 Thread David Larlet

Hi Tom,

The DEFAULT_FILE_STORAGE setting need to be set with a (python) path  
to your S3Storage location, the example is a bit confusing because the  
first part is the path and the second one is the class name (which is  
the same). Where did you put the S3Storage.py file? Let's you've got  
this tree:

example.com/
   myproject/
   myapps/
   mylibs/
 S3Storage.py

with example.com as part of your PYTHONPATH environment var, you  
should use 'mylibs.S3Storage.S3storage' as your DEFAULT_FILE_STORAGE  
setting. I hope it's more clear now(?) Do not hesitate to contact me  
with more details if you need help.

Django do not require anymore to be patched for the use of storages  
since the merge of file storage refactoring (r8244).

Best,
David

Le 23 août 08 à 23:42, tom a écrit :

>
> Hi,
>
> I am trying to move all my FileFields and ImageFields Items to S3.
> Therefore I changed the settings DEFAULT_FILE_STORAGE =
> 'S3Storage.S3Storage'. I tried to follow the steps described on
> http://code.larlet.fr/doc/django-s3-storage.html but I get a Error
> importing storage module S3Storage: "No module named S3Storage" error.
> I am currently running on this revision:
> URL: http://code.djangoproject.com/svn/django/trunk
> Repository Root: http://code.djangoproject.com/svn
> Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
> Revision: 8499
> Node Kind: directory
> Schedule: normal
> Last Changed Author: mtredinnick
> Last Changed Rev: 8499
> Last Changed Date: 2008-08-23 20:34:32 +0200 (Sa, 23 Aug 2008)
>
> and I am not sure if I still have to patch django with the patches
> form this ticket http://code.djangoproject.com/ticket/5361.
>
> If a patch would be needed, does anyone know if this particular change
> will be included within django some times?
>
> Many thanks! tom
> >


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



Segmentation fault (postgresql - psycopg2)

2008-08-25 Thread kire

My site works fine locally mysql, sqlite and postgresql. On the server
it worked fine om mysql - myisam (well, as long you can speak about
fine for that database). I'm trying to convert to postgresql,
everything is configured correct and when i execute 'python manage.py
syncdb --noinput' I just nicely receive Segmentation fault.

Since I have 3 django installations (don't ask, we're converting other
apps right now) I thought it could be manage.py using an outdated
django distribution, so I ran 'python manage.py --version', which
gives me nicely '1.0-beta_1-SVN-8534'. So, no problem there (also
tried with older revisions to make sure).

I have to say: the database is 'remote' (2 different virtual machines,
one for database, one for apache). But this works since our phppgadmin
is doing it's job.

Any ideas?

--~--~-~--~~~---~--~~
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: limiting choices in admin.ModelAdmin based on request.user

2008-08-25 Thread krylatij

> There is no longer any reason whatsoever to use this in any way in the
> admin. It was an ugly, fragile hack before and it's unnecessary now
> because ModelAdmin has a get_form() method -- which receives the
> HttpRequest object as an argument -- that you can override to tweak
> the form on a per-request basis.
thanx! good news!
--~--~-~--~~~---~--~~
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: QuerySets are scary!

2008-08-25 Thread V

thanks for the exhausting answer!

I thought that something similar is going on under the hood, and just
wanted to point it out to other ignorant people like myself.

thanks once again!
V

On Aug 23, 12:27 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Sat, Aug 23, 2008 at 3:57 AM, Viktor Nagy <[EMAIL PROTECTED]> wrote:
> > is this true or both my test and real code are simply wrong? I was
> > kinda shocked from this
>
> The problem here is basically conceptual. You've assumed that, because
> it supports some of the same operations as a list, a QuerySet must
> *be* a list -- in other words, that it's a container which holds a
> collection of objects.
>
> So while the things you're trying would work with a list (and would
> work if you used Python's built-in 'list()' function to turn your
> QuerySet's results into a list) because a list is simply a static
> collection of objects, they *won't* work on a QuerySet because a
> QuerySet is actually a representation of some way you're interacting
> with your database, and as a result has to walk some fine lines
> between not hitting your DB too often and not giving you stale
> results.
>
> As a general rule, then, whenever you want this sort of behavior, either:
>
> 1. Use list() to force your QuerySet into a list of objects you can
> then work with as a list, or
> 2. Pull out the object or objects you want, and store them in a
> variable, because there are situations (like this one) where the
> QuerySet won't automatically "remember" them for you.
>
> The slightly longer technical answer, if you're interested, is that
> what you're trying will, sort of by accident, work *if and only if*
> you've already done something which forced the QuerySet to evaluate,
> perform its query and populate its internal result list. If that
> hasn't happened yet, repeatedly slicing or indexing into the QuerySet
> will result in a new query being run each time you do this, with no
> "remembering" of previously-returned results.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Custom manager for many-to-many traversal

2008-08-25 Thread MrJogo

How do I create a custom manager for many-to-many traversal? An
example will illustrate what I want to do better. Suppose I have the
following models.py:

class Book(models.Model):
  title = models.CharField(max_length=100)

class Author(models.Model):
  books = models.ForeignKey(Book)
  name = models.CharField(max_length=100)
  is_alive = models.BooleanField()

This is a many-to-many relationship: a book can have multiple authors
and an author can have written multiple books.

If I have a book object my_book, and I want to get all the authors, I
do my_book.author_set.all(). How can I set up a custom manager to only
get living authors of that book, so I could do something like
my_book.livingauthor_set.all()?

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



  1   2   >