Re: Thumbnail - django-utils - Google Code

2007-08-10 Thread Greg

Ok,
I downloaded the svn by typing 'svn co 
svn://trac.studioquattro.biz/django-utils/trunk/nesh'
into my command prompt at the directory C:/pyhton24/Lib/site-
packages.  So now nesh and django and in the same directory.  I then
edited my settings file for my project located at c:/django/mysite/.
In the settings file I added the following line to my INSTALLED_APPS
directory.

'nesh',

So now my installed apps looks like this:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'nesh',
'mysite.blog',
 'mysite.test',

Not sure if this correct

/

In my models file (from within mysite.test) I have the following:

from django.db import models
from nesh.thumbnail.field import ImageWithThumbnailField

class MyPhotoTest(models.Model):
name = models.CharField(maxlength=100)
photo = models.ImageWithThumbnailField(upload_to='site_media/')

class Admin:
pass

However, when I try to validate my models.  I get the following error:

C:\django\mysite>python manage.py validate
mysite.test: 'module' object has no attribute
'ImageWithThumbnailField'
1 error found.

//

Anybody have any suggestions?

Thanks

On Aug 10, 11:23 pm, Greg <[EMAIL PROTECTED]> wrote:
> Lisa,
> Very Interesting.  How would I go about getting the module
> 'nesh.thumbnail.field'?  Do I need to get the latest revision of
> django?
>
> Thanks
>
> On Aug 10, 5:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hey all,
>
> > I'm new to the group, but I thought you guys might find this little
> > guy interesting...
>
> >http://code.google.com/p/django-utils/wiki/Thumbnail
>
> > If this a repost, many apologies
>
> > Cheers,
>
> > Lisa


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



Don't Repeat Yourself!

2007-08-10 Thread sago

I was delivering some Django training this week, and it occurred to me
there is a huge DRY-violation in the Django feed system.

Django has a comprehensive and (in my opinion) superb URL routing
mechanism. You route urls to views. In many cases you can route a
number of urls to the same view, adding extra information with a
dictionary of data. Generic views work very well in this way.

But the feed system gets you to extract a whole section of the url and
feed it to the feed view. Thereafter the first part of the url is
matched against a regular dictionary to find the feed class, and any
further bits of the url are split into sections by slash and given to
get_object.

The feed approach for routing urls is everything that django's url
system was designed not to be: it imposes a hierarchical structure on
the url, distributes the configuration over multiple representations,
and could be avoided by having a feed view that behaves more like
generic views:

(r'feeds/rss/comments/(?P\w+)/',
  'django.contrib.syndication.views.feed',
  {'feed': LatestEntriesFeedClass}),

And removing the (imho warty) url_elements list of strings that get
passed to get_object, replacing it with any regular named groups
pulled from the url:

def feed(request, feed, *args, **kws):
   feed_instance = feed()
   object = feed_instance.get_object(*args, **kws)

and so on...

Am I wrong to feel this way?

Ian.


--~--~-~--~~~---~--~~
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: Thumbnail - django-utils - Google Code

2007-08-10 Thread Greg

Lisa,
Very Interesting.  How would I go about getting the module
'nesh.thumbnail.field'?  Do I need to get the latest revision of
django?

Thanks

On Aug 10, 5:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hey all,
>
> I'm new to the group, but I thought you guys might find this little
> guy interesting...
>
> http://code.google.com/p/django-utils/wiki/Thumbnail
>
> If this a repost, many apologies
>
> Cheers,
>
> Lisa


--~--~-~--~~~---~--~~
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 make a field that can be inserted but not updated?

2007-08-10 Thread r_f_d

I realized after I posted this that I did not explain it well, so here
goes try number two.
The editable=false affects the admin interface and I believe the
newforms module and perhaps the old manipulator framework.  You can
simply create your own form, particularly with a model this simple,
and do your own validation (see the docs for how to do this) for the
form after checking to see that the user is a super user.  Also after
re-reading your post my question is whether or not what you are really
trying to accomplish would require the user field to be editable=false
as well.  This would ensure that the email address could not be
changed, and that the user associated with the email address could not
be changed without using a custom view that was limited to the super
user.
hth,
-r

On Aug 10, 9:48 pm, r_f_d <[EMAIL PROTECTED]> wrote:
> If I am not mistaken, editable=False is only applicable to the admin-
> forms.  Simply create a view that checks to see if the user is a
> superuser and then give them a form to add an email address.
>
> peace,
> -r
>
> On Aug 10, 7:59 pm, Russell Blau <[EMAIL PROTECTED]> wrote:
>
> > I am working on an application that includes the following in
> > models.py:
>
> > class UserEmail(models.Model):
> > email = models.EmailField("email address", unique=True,
> > editable=False)
> > user = models.ForeignKey(UserRegistration)
>
> > # an email address can only be associated with one user, and can
> > never
> > # be deleted
> > # once assigned to a user, it can be shifted to another user only
> > by
> > # manual intervention by an administrator
>
> > def delete(self):
> > "Deletion of email addresses is not permitted"
> > warnings.warn("Attempt to delete registered email %s
> > rejected."
> >   % self.email)
>
> > def __str__(self):
> > return self.email
>
> > class Admin:
> > pass
>
> > Basically, I want to keep track of every email address that has ever
> > been registered with my app, to prevent duplication.  By overriding
> > delete(), I prevent any address from being removed from the database,
> > but I also have to prevent editing the address once it has been
> > registered.  The problem is that "editable=False" works too well -- it
> > prevents an admin from editing an existing address, but also prevents
> > them from adding new ones.  Is there a way to set up my model so that
> > the administrator can enter new email addresses for a user, but cannot
> > change the existing ones?
>
> > Russ


--~--~-~--~~~---~--~~
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: Saving a copy of a model

2007-08-10 Thread r_f_d

I also forgot to mention two things, the model documentation states
that each model subclasses django.db.models.Model, and I believe it
will not work to subclass a model.  I believe I tried this when I
first started with Django last year and it would not work. Secondly,
based on your coment that you have been playing with and learning
about manipulators for a few hours now, if you are new to Django, you
may want to avoid using Manipulators as the newforms will be replacing
them, if not before, in Version 1.

-richard

On Aug 10, 10:18 pm, r_f_d <[EMAIL PROTECTED]> wrote:
> I am not sure I understand, I think you want to archive a model
> instance? or put another way, when the model is no longer active or
> useful to the user, you would essentially like to treat that database
> record differently than other records.  In that case, you could simply
> change the archived field to a boolean, set true on it when you
> archive it, and the modified field would automatically record the
> date.  Then all you have to do is filter out all of the archived or
> non archived models via Assessment.objects.filter(archived__exact =
> True) or = False.  This would make your views much easier to customize
> as would only be dealing with one model.
> hth,
> -richard
>
> On Aug 10, 7:40 pm, Carlos Hanson <[EMAIL PROTECTED]> wrote:
>
> > Greetings,
>
> > I have a model which I would like to archive.  My thought was to
> > extend that model with one additional DateTimeField called archived.
> > But I am having difficulty saving an instance of the archived object
> > based on an existing object.
>
> > class Assessment(models.Model):
> > student = models.ForeignKey(Student)
> > created = models.DateTimeField(auto_now_add=True, editable=False)
> > modified = models.DateTimeField(auto_now=True, editable=False)
> > background = models.TextField(blank=True)
> > ...
>
> > class ArchivedAssessment(Assessment):
> > archived = models.DateTimeField(auto_now_add=True, editable=False)
>
> > I am working within the admin interface and creating a view to take
> > the saved Assessment and save it as an ArchivedAssessment.  It seems
> > like it should be relatively easy to do, but I am not seeing how.
> > I've been learning about and playing with Manipulators for a couple
> > hours now.
>
> > Any suggestions?
>
> > Carlos Hanson


--~--~-~--~~~---~--~~
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: Saving a copy of a model

2007-08-10 Thread r_f_d

I am not sure I understand, I think you want to archive a model
instance? or put another way, when the model is no longer active or
useful to the user, you would essentially like to treat that database
record differently than other records.  In that case, you could simply
change the archived field to a boolean, set true on it when you
archive it, and the modified field would automatically record the
date.  Then all you have to do is filter out all of the archived or
non archived models via Assessment.objects.filter(archived__exact =
True) or = False.  This would make your views much easier to customize
as would only be dealing with one model.
hth,
-richard

On Aug 10, 7:40 pm, Carlos Hanson <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I have a model which I would like to archive.  My thought was to
> extend that model with one additional DateTimeField called archived.
> But I am having difficulty saving an instance of the archived object
> based on an existing object.
>
> class Assessment(models.Model):
> student = models.ForeignKey(Student)
> created = models.DateTimeField(auto_now_add=True, editable=False)
> modified = models.DateTimeField(auto_now=True, editable=False)
> background = models.TextField(blank=True)
> ...
>
> class ArchivedAssessment(Assessment):
> archived = models.DateTimeField(auto_now_add=True, editable=False)
>
> I am working within the admin interface and creating a view to take
> the saved Assessment and save it as an ArchivedAssessment.  It seems
> like it should be relatively easy to do, but I am not seeing how.
> I've been learning about and playing with Manipulators for a couple
> hours now.
>
> Any suggestions?
>
> Carlos Hanson


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



Support for macros in templates

2007-08-10 Thread Michal Ludvig

Hi all,

This is a little announcement of a tag library for {% macro %} support
in Django templates.

I have been using TAL template engine in my previous project and got
used to the concept of "macros" as building blocks of the final HTML
output. Now in Django I realised the missing support for "macros" is a
serious limitation. I admit I may be too locked to a different mindset
and perhaps the same things I need macros for could be achieved with
pure Django templates. Maybe, maybe not. Anyway, I was missing macros so
much that I decided to add them to Django.

If interested, take the library from here:
http://www.djangosnippets.org/snippets/363/

Usage is like this:

1) Load the macro library:
{% load macros %}

2) Define a new macro called 'my_macro'
   with parameter 'arg1':
{% macro my_macro arg1 %}
Parameter: {{ arg1 }} 
{% endmacro %}

3) Use the macro with a String parameter:
{% usemacro my_macro "String parameter" %}

   or with a variable parameter (provided the
   Context defines 'somearg' variable, e.g. with
   value "Variable parameter"):
{% usemacro my_macro somearg %}

The output of the above code would be:
Parameter: String parameter 
Parameter: Variable parameter 

It works pretty well and the only drawback is that the defined macros
are local to each template file, i.e. are not inherited through
{%extends ...%} and you can't have for instance some common macros
defined in a separate file and include that file wherever needed. I'll
try to solve that problem later. Perhaps through a new tag, for instance
{%macrofile ...%} or something like that. Maybe someone will contribute
a patch? ;-)

Enjoy and sorry for the spam

Michal
-- 
* http://www.logix.cz/michal








--~--~-~--~~~---~--~~
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 make a field that can be inserted but not updated?

2007-08-10 Thread r_f_d

If I am not mistaken, editable=False is only applicable to the admin-
forms.  Simply create a view that checks to see if the user is a
superuser and then give them a form to add an email address.

peace,
-r

On Aug 10, 7:59 pm, Russell Blau <[EMAIL PROTECTED]> wrote:
> I am working on an application that includes the following in
> models.py:
>
> class UserEmail(models.Model):
> email = models.EmailField("email address", unique=True,
> editable=False)
> user = models.ForeignKey(UserRegistration)
>
> # an email address can only be associated with one user, and can
> never
> # be deleted
> # once assigned to a user, it can be shifted to another user only
> by
> # manual intervention by an administrator
>
> def delete(self):
> "Deletion of email addresses is not permitted"
> warnings.warn("Attempt to delete registered email %s
> rejected."
>   % self.email)
>
> def __str__(self):
> return self.email
>
> class Admin:
> pass
>
> Basically, I want to keep track of every email address that has ever
> been registered with my app, to prevent duplication.  By overriding
> delete(), I prevent any address from being removed from the database,
> but I also have to prevent editing the address once it has been
> registered.  The problem is that "editable=False" works too well -- it
> prevents an admin from editing an existing address, but also prevents
> them from adding new ones.  Is there a way to set up my model so that
> the administrator can enter new email addresses for a user, but cannot
> change the existing ones?
>
> Russ


--~--~-~--~~~---~--~~
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 html snippet via XHR with simplejson

2007-08-10 Thread r_f_d

I was wondering what people are doing to format html snippets returned
via XHR.  I am currently using code  like:

response_dict = {}

t = ModelObject.objects.all()

html_table = render_to_response('table_template.html', {'table': t})

response_dict.update({'table': html_table})

return HttpResponse(simplejson.dumps(response_dict),
mimetype='application/javascript')

Where my template contains code to loop through the queryset and
layout the table appropriately.  I also do this with
form_for_model(instance) to layout the form fields.

This seems pretty appropriate to me, but as I am relatively new to
python and django, I was wondering if others are doing something
similar or if there are other suggestions for returning the html
formatted.
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: newforms + multiple sister forms submitted/processed in one user action

2007-08-10 Thread Doug B

> ---
>
> If I have 8 people, how should bind POST data to a form object in the
> view?

You can use the 'prefix' option when instantiating the forms.  Prefix
the form with the corresponding form 'number' or other unique
identifier.  On post pass it the whole post dict.  It will pull the
data out according to the prefix.


--~--~-~--~~~---~--~~
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 make a field that can be inserted but not updated?

2007-08-10 Thread Kai Kuehne

Hi,

On 8/11/07, Russell Blau <[EMAIL PROTECTED]> wrote:
> Basically, I want to keep track of every email address that has ever
> been registered with my app, to prevent duplication.  By overriding
> delete(), I prevent any address from being removed from the database,
> but I also have to prevent editing the address once it has been
> registered.  The problem is that "editable=False" works too well -- it
> prevents an admin from editing an existing address, but also prevents
> them from adding new ones.  Is there a way to set up my model so that
> the administrator can enter new email addresses for a user, but cannot
> change the existing ones?

__setattr__  or property which sets the email only if it is None? I'm not sure,
but this could work. :)

> Russ

Kai

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



How to make a field that can be inserted but not updated?

2007-08-10 Thread Russell Blau

I am working on an application that includes the following in
models.py:

class UserEmail(models.Model):
email = models.EmailField("email address", unique=True,
editable=False)
user = models.ForeignKey(UserRegistration)

# an email address can only be associated with one user, and can
never
# be deleted
# once assigned to a user, it can be shifted to another user only
by
# manual intervention by an administrator

def delete(self):
"Deletion of email addresses is not permitted"
warnings.warn("Attempt to delete registered email %s
rejected."
  % self.email)

def __str__(self):
return self.email

class Admin:
pass

Basically, I want to keep track of every email address that has ever
been registered with my app, to prevent duplication.  By overriding
delete(), I prevent any address from being removed from the database,
but I also have to prevent editing the address once it has been
registered.  The problem is that "editable=False" works too well -- it
prevents an admin from editing an existing address, but also prevents
them from adding new ones.  Is there a way to set up my model so that
the administrator can enter new email addresses for a user, but cannot
change the existing ones?

Russ


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



Saving a copy of a model

2007-08-10 Thread Carlos Hanson

Greetings,

I have a model which I would like to archive.  My thought was to
extend that model with one additional DateTimeField called archived.
But I am having difficulty saving an instance of the archived object
based on an existing object.

class Assessment(models.Model):
student = models.ForeignKey(Student)
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)
background = models.TextField(blank=True)
...

class ArchivedAssessment(Assessment):
archived = models.DateTimeField(auto_now_add=True, editable=False)

I am working within the admin interface and creating a view to take
the saved Assessment and save it as an ArchivedAssessment.  It seems
like it should be relatively easy to do, but I am not seeing how.
I've been learning about and playing with Manipulators for a couple
hours now.

Any suggestions?

Carlos Hanson


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



Admin methods in any project

2007-08-10 Thread Mario Gonzalez

 We know that every project needs to save data and usually the time
that we've got to write templates is a lot.

  The question is: how can I improve the time I use to write those
templates? Maybe I'm doing something wrong because if I need to enter
data to different classes, ex 10 classes, in different instances I've
got to write 10 templates.

 Is there a way that when I want to display the content of any class I
could use one template only?


--~--~-~--~~~---~--~~
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: Launchpad - Community for free projects

2007-08-10 Thread Jonas



On 10 ago, 22:16, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> On 8/10/07, Jonas <[EMAIL PROTECTED]> wrote:
>
> > I posted it here bacause I have been that there are many projects
> > based on Python/Django hosted on Google Code and as found a better
> > service where the community can integrate and participate better then
> > I said it.
>
> Fair enough; I'm just *extremely* suspicious of Cannonical's motives
> and overall plans for Launchpad. To each their own, I suppose.
>
> Jacob
Since to me it worries more the power that Google has obtained and
manages about the information of users, and to want to include the
whole internet getting more and more services where there are great
communities.


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



Thumbnail - django-utils - Google Code

2007-08-10 Thread [EMAIL PROTECTED]

Hey all,

I'm new to the group, but I thought you guys might find this little
guy interesting...

http://code.google.com/p/django-utils/wiki/Thumbnail

If this a repost, many apologies

Cheers,

Lisa


--~--~-~--~~~---~--~~
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: newforms + multiple sister forms submitted/processed in one user action

2007-08-10 Thread Patrick Anderson

On Fri, 10 Aug 2007 13:32:32 -0700, Collin Grady wrote:

> One method is to include a hidden input somewhere that indicates the
> number of forms present. Then you can just use a for loop from 1 to that
> number in the view to build the right number of forms again.
> 
> 
> 
This is the raw html form loop (without {{ form }}):

--


Name:


F. Name:

M. Name:

L. Name:



---

If I have 8 people, how should bind POST data to a form object in the 
view?

Well, here's my view I just started writing:

---

def index(request, template):

from forms import PersonForm

persons = []

if 'total_transfers' in request.session:
if request.session['total_transfers']:
[persons.append(x) for x in range(1, request.session
['total_transfers']+1)]

personnel_form = []

if len(persons):
if request.method == 'POST':
data = request.POST.copy()  
for i in persons.values():
f = PersonForm(data) # how should I bind data to form?
personnel_form.append(f)
...
# to-be done

return direct_to_template(request, 
template,
extra_context = {
'persons': persons,
'forms': personnel_forms,
})

-


--~--~-~--~~~---~--~~
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: Launchpad - Community for free projects

2007-08-10 Thread Jacob Kaplan-Moss

On 8/10/07, Jonas <[EMAIL PROTECTED]> wrote:
> I posted it here bacause I have been that there are many projects
> based on Python/Django hosted on Google Code and as found a better
> service where the community can integrate and participate better then
> I said it.

Fair enough; I'm just *extremely* suspicious of Cannonical's motives
and overall plans for Launchpad. To each their own, I suppose.

Jacob

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



Syncing microformat data with generic views

2007-08-10 Thread [EMAIL PROTECTED]

If anyone's interested, I posted how I'm creating vcard and ical data
with generic views so people can just click a link or button to sync
things up with their calendar or address book. I suspect it's riddled
with errors and bad advice, so be kind:
http://thebitterpill.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: Multi field validation with clean method

2007-08-10 Thread jeffhg58
I was finally able to figure it out as I saw on another post. Instead, of
using the RaiseValidation error I did the following:

self.errors.update(annotation=ErrorList([u'You must enter an Annotation 
Type.']))

Thanks for all your help,

Jeff

-- Original message -- 
From: rskm1 <[EMAIL PROTECTED]> 

> 
> On Aug 9, 7:34 pm, [EMAIL PROTECTED] wrote: 
> > So, if I use clean_annotationvalue to do both how would I be able to put an 
> error 
> > message on the annotation type ... 
> 
> I think you were on the right track the first time. Philosophically, 
> the Form's clean() method is where you're supposed to be doing the 
> inter-field validations, and you don't have to worry about field 
> sequence there either. 
> 
> So now your question boils down to a simple "How do I associate the 
> error message with a specific field, from the form's clean() method?" 
> 
> Normally, if you raise a ValidationError exception from 
> YourForm.clean(), the message appears in a "special" section of the 
> form._errors collection named "__all__", accessed from the template as 
> {{ form.non_field_errors }}. 
> But if you can figure out how to manually inject the message into 
> yourform._errors yourself, you could make it appear on any field you 
> want. Well, *theoretically* anyway; I haven't tried that myself, 
> since I always *want* the inter-field validation errors to appear in a 
> different spot. 
> 
> 
> > 
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Google Checkout w/out a shopping cart?

2007-08-10 Thread [EMAIL PROTECTED]

I'm trying to build a very simple ecommerce page using Google Checkout
without the use of a shopping cart.  Here are my models:

class Team(models.Model):
name = models.CharField(maxlength=30, unique=True)
def __str__(self):
return self.name
class Meta:
ordering = ['name']
class Admin:
pass
class Association(models.Model):
name = models.CharField(maxlength=30, unique=True)
def __str__(self):
return self.name
class Meta:
ordering = ['name']
class Admin:
pass
class OrderForm(forms.Form):
association =
forms.ModelChoiceField(queryset=Association.objects.all())
team = forms.ModelChoiceField(queryset=Team.objects.all())

I'd like users to be able to select their association and team from a
drop down list, and send their selection immediately to Google
Checkout without the use of a shopping cart.

Is there a way to capture their selection and send "team" as the item-
name, and "association" as its description?  Here's my view function
so far:

def order(request):
order_form = OrderForm()
return render_to_response('order.html',
{'order_form': order_form})

And here's how I'm currently trying to send the info through Google
Checkout:

  
  

Right now, when I send this to Google Checkout, instead of sending the
name of the Association and Team that was selected, it sends the word
"team" as the item-name, and "association" as the item-description.
Please let me know if you have any insight!


--~--~-~--~~~---~--~~
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: urlconf for multiple page slugs

2007-08-10 Thread Peter Baumgartner
>
>
> Collin's suggestion may sound daunting, but it's really quite easy:


Thanks guys. I took your advice. Here is my solution:
http://www.djangosnippets.org/snippets/362/

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



Feed question

2007-08-10 Thread [EMAIL PROTECTED]

I have an events model, and a feed for it - shows all events

Events has a foreign key relationship with Club. What I'd like to do
is have a feed for each club, but I'm not sure how to get that into a
feed without explicitly defining it for each club.

Say I have two clubs, Foo and Bar, I want something in feeds.py like:
def items(self):
return Event.objects.filter(club=theClub).order_by('-created')

where theClub is Foo, or Bar, or whatever.

Can I do this with the built-in feeds framework?


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



Fix Your WINDOWS XP

2007-08-10 Thread John Travolta
Repair your installation and fix all errors in your operating system
http://windowsxpsp2pro.blogspot.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: Multi field validation with clean method

2007-08-10 Thread rskm1

On Aug 9, 7:34 pm, [EMAIL PROTECTED] wrote:
> So, if I use clean_annotationvalue to do both how would I be able to put an 
> error
> message on the annotation type ...

I think you were on the right track the first time.  Philosophically,
the Form's clean() method is where you're supposed to be doing the
inter-field validations, and you don't have to worry about field
sequence there either.

So now your question boils down to a simple "How do I associate the
error message with a specific field, from the form's clean() method?"

Normally, if you raise a ValidationError exception from
YourForm.clean(), the message appears in a "special" section of the
form._errors collection named "__all__", accessed from the template as
{{ form.non_field_errors }}.
But if you can figure out how to manually inject the message into
yourform._errors yourself, you could make it appear on any field you
want.  Well, *theoretically* anyway; I haven't tried that myself,
since I always *want* the inter-field validation errors to appear in a
different spot.


--~--~-~--~~~---~--~~
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: urlconf for multiple page slugs

2007-08-10 Thread Tim Chase

> About the only way to do that is just grab (.*) from the url, and
> parse it in your view, looking up slugs as needed


Collin's suggestion may sound daunting, but it's really quite easy:

your urls.py can have something like

r"^(?P(?:[-\w]+/)*[-\w]+)/?$"

and then in your view:

def my_view(request, path):
  # iterate from grandparent -> parent -> child -> grandchild
  for piece in path.split('/'):
do_something(piece)



Not too scary and rather easy to understand (except perhaps for
the regexp, but that's another matter).

-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: newforms - form for multiple models

2007-08-10 Thread Collin Grady

Do you need validation that ties between fields in both models?

If not, just pass each form into the template individually.

A newforms form will only pay attention to POST keys that match its
own fields, so the others will just be ignored, and everything just
works :)


--~--~-~--~~~---~--~~
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: Rails-like Flash in Django

2007-08-10 Thread Collin Grady

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


--~--~-~--~~~---~--~~
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: newforms + multiple sister forms submitted/processed in one user action

2007-08-10 Thread Collin Grady

One method is to include a hidden input somewhere that indicates the
number of forms present. Then you can just use a for loop from 1 to
that number in the view to build the right number of forms again.


--~--~-~--~~~---~--~~
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 define a User?

2007-08-10 Thread Collin Grady

To fkey to User, you should be importing it, not typing out a full
path like that (unless you're doing "import django" but that's a bit
unwieldy)

You cannot set the fkey to the current user in save(), as request is
not available.

You also can't do it in admin because of that. It's very easy in a
custom view, however :)


--~--~-~--~~~---~--~~
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: Rails-like Flash in Django

2007-08-10 Thread James Bennett

On 8/10/07, sagi s <[EMAIL PROTECTED]> wrote:
> In Rails, flash is a way to display a message in the next page. It is
> extremely useful to provide lightweight feedback to user operations.
> For examples when the user, say, submits a new article and after
> clicking on the "Submit" button, then is redirected to the front page,
> you want to let him know that his submission was successful on the
> front page.

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

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



Re: editing newforms field

2007-08-10 Thread Collin Grady

Yes, you can do something like form.fields['fieldname'].widget =
forms.TextInput() or whatever


--~--~-~--~~~---~--~~
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: urlconf for multiple page slugs

2007-08-10 Thread Collin Grady

About the only way to do that is just grab (.*) from the url, and
parse it in your view, looking up slugs as 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
-~--~~~~--~~--~--~---



urlconf for multiple page slugs

2007-08-10 Thread Peter Baumgartner
I'm building a site where pages can have parent pages in the form:

* Grandparent 1
* Grandparent 2
** Parent 1
*** Child 1
*** Child 2
** Parent 2

I'd like the url to contain each parent. For example, 'child 2' would be at
/grandparent-2/parent-1/child-2/

I'm not sure how to implement this in my urls.py without hardcoding the
parent slugs. Any ideas?

Here is what my get_absolute_url looks like for each page:

def get_absolute_url(self):
url = "/%s/" % self.slug
page = self
while page.parent:
url = "/%s%s" % (page.parent.slug,url)
page = page.parent
return url

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



Re: MediaWiki Port in Django - Project Interest?

2007-08-10 Thread Ramdas S
There is something called Diamanda.
http://code.google.com/p/diamanda/

We had customized it for a community web site, though the project is not
live yet.

Yes, I am interested.

RS


On 8/11/07, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Fri, Aug 10, 2007 at 03:59:07PM -, [EMAIL PROTECTED] wrote:
> > > Would anyone be interested in using it if it was released as a contrib
> > > app?
> >
> > Yes.
> >
> > With kind regards,
> > --
> > Baurzhan Ismagulov
> > http://www.kz-easy.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: Multilingual site best practices

2007-08-10 Thread Francis

1. You should use a quick description and then write the full text in
the po file.

2.  You are better of using english in the {%trans%} bloc because
gettext don't support UTF-8 or character outside the limited ascii.

no clue for 3.

Francis


On Aug 10, 11:42 am, Vincent Foley <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I work for a company who develops web sites and web applications for
> clients in Quebec.  People in Quebec mainly speak french, but there
> are english speaking people too.  Most sites we make eventually want
> to have a french and english version with french being the "main"
> version.
>
> I would like to know if anyone could share best practices for
> multilingual sites.  I also have some questions:
>
> 1. In the {% trans %} and {% blocktrans %} tags, should I include the
> full text, or just a quick description and enter the full text in
> the .po files?
>
> 2. As I said, french is the main language in Quebec, so if I write a
> site in french and am later asked to translate it, will the accented
> characters cause a problem if they're used in the msgid of the .po
> files?
>
> 3. It seems the server always has to be restarted after the .po files
> have been compiled.  Is that so?  If I don't have root access to the
> server to restart Apache, is there a way I can have the new
> definitions appear on the site?
>
> Thanks for the input,
>
> Vincent.


--~--~-~--~~~---~--~~
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: Fwd: Proposal for the Web User Interface of the OSSEC HIDS

2007-08-10 Thread RajeshD


>
> -- Forwarded message --
> From: Ian Scott Speirs <[EMAIL PROTECTED]>
> Date: 10 ago, 14:27
> Subject: Proposal for the Web User Interface
> To: ossec-list
>
> Jonas wrote:
>
> > On 9 ago, 23:33, Jeff Schroeder <[EMAIL PROTECTED]> wrote:
> >> In opensource, proposing something is often equivalent to volunteering
> >> to do it yourself :)
> > True :)
> >> Also, php is easier to set up than python / django on a majority of
> >> operating systems / distributions
> >> simply because it has more market penetration.
> > I disagree totally. Python is being installed by default in the major
> > distributions and a Django application can be easily installed via
> > Setuptools

How about this quote on Python:

"Python is fast enough for our site and allows us to produce
maintainable features in record times, with a minimum of developers,"
said Cuong Do, Software Architect, YouTube.com.


> /There has been a LOT of Python development.  The benefit (and
> detriment) of Python v PHP is not its immaturity (shared by a LOT of
> library PHP code) but the fact of it's nature of being compiled to
> bytecode before use.  In that realm, it's questionably better than C++
> -- can be completely obfuscated, with only an API "visible".  Again,
> that's a benefit to the developer doing non-FOSS development, but a
> detriment to the user who wants to code-audit.
> /
> He and I have been watching the use of and evaluation of open source
> by
> US government. There are efforts to certify some open source operating
> systems and software and thus provide a huge boost to this are of the
> the software market. His point about code-audits and obfustication are
> relevant from that aspect--they are going to want a guarantee if it's
> used by DOD or DHS.

What does code audit have to do with compiled binaries or bytecode?
You audit Python source code just as you would audit PHP or any other
code.

I don't understand the comment about Python's immaturity either --
it's been around for over 15 years and it seems to be mature enough
for You Tube, Google, and NASA :)

>
> /As such, it's a trade-off.  You can get good or bad library code with
> either, and IIRC there's a mod_python so that python doesn't have to
> run CGI.  Certainly there COULD be advantages at run time, to prior
> compile in terms of speed and resources taken, which for most projects
> today is quite offset by the need to compile BEFORE testing, AFAIK.

If performance is a concern, there are a large number of Python/Django
sites that are performing incredibly well. Django supports memcached
and is able to scale with pretty much any hardware you throw at it.

Python code gets byte compiled on first access. So, there's no
recompilation penalty on every web request. And in any case, it's the
network I/O that takes up a majority of a request's life cycle.

>
> /  I'm going to guess that this Django is similar to that PHP template
>   system that makes maintenance of "things not covered" such a pain.
> /

That guess is plain wrong! Django is modular enough that you can use
your own layers if you don't like what's in the box. For example, you
can use a different templating system, a different ORM (to an extent),
pretty much any Web Server, a number of different caching backends.
For example, it has well defined interfaces to DB backends, caching
backends, and such so that you can write your own implementations if
your DB or cache is not supported. It lets you use all the agility and
elegance of Python.


> I can't speak to or of Django because I am not that familiar with it
> nor
> use it. However, I have been examining a variety of PHP web
> applications
> recently and have found serious maintenance issues with several of
> them
> built on common frameworks.

Most such issues are a result of bad programming decisions more than
anything else. Through DRY, Django actually encourages good decisions.
Django also provides excellent documentation in that respect. But you
can write bad unmaintanable code in any language :) So, this is
neither a PHP problem nor a Python one.

> I understand that PHPnuke has had some
> serious vulnerabilities discovered in it and I believe the Smarty-
> based
> software has a few problems too. Granted, being open source allows
> many
> people to see these and respond to them but the real issue is the
> design
> and development process undertaken. If a development group is in too
> much of a hurry to get something out so others can see it and become
> potential participants, what does that say about the basic design?

Django is actually the perfect framework for situations where you want
to get things out in a hurry. There are numerous stories of people
knocking out serious, stable, high performing code in a weekend that
would take a lot longer with anything else.

>
> And again I can't speak to that in Django

Well, Scott needs to take a more serious look at Django then. He has
too many preconceived notions about bad frameworks. 

newforms - form for multiple models

2007-08-10 Thread sagi s

I am trying to create a form for a couple of models:

PubForm =  forms.form_for_model(Publication)
CopyForm =  forms.form_for_model(Copy)
class PubCopyForm(PubForm, CopyForm):
pass

I would expect to see a combination of the Copy and Publication fields
in the form but I only see Publication's fields.

Any suggestions on how to achieve 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: about templates tags

2007-08-10 Thread rskm1

On Aug 9, 11:23 am, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> can I include more than one template tag definition in a single template tag
> file? Right  now I was trying  to do that and I can't.

I'm still a novice, but I know you can define multiple filters in
one .py file, and I'm pretty sure you can define multiple tags in
one .py file also.  I'll bet you could even *mix* filter and tag
definitions in the same .py file.

Since you claim you "can't", I would guess that you just forgot to
register one of the tags.
Or maybe you're not returning a Node-subclass object with a render()
method defined.
Or some other problem that is unrelated to it being in the same file
as another tag definition.

def mytagfunc(parser, token):
  # ...
  return myNode
register.tag('mytag', mytagfunc)

def myothertagfunc(parser, token):
  # ...
  return myotherNode
register.tag('myothertag', myothertagfunc)


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



Rails-like Flash in Django

2007-08-10 Thread sagi s

In Rails, flash is a way to display a message in the next page. It is
extremely useful to provide lightweight feedback to user operations.
For examples when the user, say, submits a new article and after
clicking on the "Submit" button, then is redirected to the front page,
you want to let him know that his submission was successful on the
front page.

What you would like to do is something like this:

...views.py
def new_article(request):
  ...
  article.save()
  flash("Your article was saved")
  ...
  HttpRedirect("frontpage")

I have implemented as a context processor:

Step 1:
create a file called session_context_processor.py:
def flash(request):
# Add the flash message from the session and clear it
flash = ""
if 'flash' in request.session:
flash = request.session['flash']
del request.session['flash']
return {'flash': flash}

Step 2:
Add the context processor to settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
...
'session_context_processor.flash',
)

Step 3:
Add the context to *every* view that renders a template:
e.g. change:
return render_to_response('mytemplate.html', context)
to:
return render_to_response('mytemplate.html', context,
context_instance=RequestContext(request))
Again: do this in every view which should be displaying a flash (I
have it in all views)

Step 4:
Add the flash message to your base template:
...
... {{ flash }}
...

Step 5:
Set the flash whenever desired. Following the example above:
...views.py
def new_article(request):
  ...
  article.save()
  request.session['flash'] = "Your article was saved"
  ...
  HttpRedirect("frontpage")

That's it.

I've seen other pointers on how to do it but this one makes sense to
me.

One thing I want to add is a flash type to help the template format
the flash differently depending on whether it represents an error,
successful operation etc.

Suggestions for improvement are welcome.


--~--~-~--~~~---~--~~
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: Multilingual site best practices

2007-08-10 Thread Vincent Foley

There's django-multilingual for that.

On Aug 10, 1:05 pm, Grupo Django <[EMAIL PROTECTED]> wrote:
> Vincent Foley ha escrito:
>
>
>
> > Hello,
>
> > I work for a company who develops web sites and web applications for
> > clients in Quebec.  People in Quebec mainly speak french, but there
> > are english speaking people too.  Most sites we make eventually want
> > to have a french and english version with french being the "main"
> > version.
>
> > I would like to know if anyone could share best practices for
> > multilingual sites.  I also have some questions:
>
> > 1. In the {% trans %} and {% blocktrans %} tags, should I include the
> > full text, or just a quick description and enter the full text in
> > the .po files?
>
> > 2. As I said, french is the main language in Quebec, so if I write a
> > site in french and am later asked to translate it, will the accented
> > characters cause a problem if they're used in the msgid of the .po
> > files?
>
> > 3. It seems the server always has to be restarted after the .po files
> > have been compiled.  Is that so?  If I don't have root access to the
> > server to restart Apache, is there a way I can have the new
> > definitions appear on the site?
>
> > Thanks for the input,
>
> > Vincent.
>
> I'd like to extend this questions.
> 4. Best practice to use a multilingual database. i.e. News in English
> and French from an app. I need it for a project. I'll write some docs
> about it when I get it to work, if I get it ;-) IMHO, multilingual in
> the interface but monolingual in database, is not very useful.
> 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
-~--~~~~--~~--~--~---



newforms + multiple sister forms submitted/processed in one user action

2007-08-10 Thread Patrick Anderson

This is a simplified PersonForm I've created with newforms library:

class PersonForm(forms.Form):

name = forms.CharField()
first_name = forms.CharField()
middle_name = forms.CharField(required = False)
last_name = forms.CharField()

The problem I have is that I need to update the Personnel on the same 
page. How should I go about writing a template and processing the POST 
request with newforms if the number of PersonForms can vary in each 
session and the user should submit all forms in one action?


By the way, this form is not going to be tied to any existing model. I 
need to pass submitted data to another server, but that is not the issue 
here. I'm wondering how newforms library could help me with this task. 

Has anyone done this before and has any thoughts and tips?



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



Car Air Conditioning

2007-08-10 Thread knjaz milos
All the informations about car air conditioners can be found on this
website...

http://car-air-conditioning.blogspot.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: Presentations about Django?

2007-08-10 Thread Horst Gutmann

Jacob Kaplan-Moss wrote:
> 
> See http://www.djangoproject.com/community/logos/ -- that page has
> downloadable high-res logos, along with some pretty simple usage
> guidlines. In general, as long as you're using the Django logo to
> promote Django itself (and not some other project/product), nobody's
> going to come down on you.
> 

Thank you very much :-) **If** this presentation happens, I guess, it
will be some kind of introduction where I also would like to talk about
some of the aspects that I like about Django. It definitely won't be
even close to what you people are doing since I'm still quite new to the
whole world of Django development, but I simply want to do at least a
little bit of promotion work.

The "if" is there because if by the time I have some projects of my own
to present, I will probably do those instead (although it's quite
likely, that they will also be Django related ... hmm lifestreams
anyone? ^_^).

Btw.: If someone of you plans to come to the BarCamp in Vienna (Austria)
this fall and wants to present Django, I will naturally abort my plans
and find something new :)

- Horst

--~--~-~--~~~---~--~~
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: Testing/Fixtures/Production/TestRunner

2007-08-10 Thread Chris Green

On Aug 9, 7:55 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 8/9/07, Chris Green <[EMAIL PROTECTED]> wrote:

> >  1)  initial_data has bitten me not realizing it was synced in
> > production each time.

> There is an argument to be made that initial_data for a model should
> only be loaded once - when the model is added to the database. I can't
> say I've been bitten by this problem myself, but I'm happy to
> entertain discussion/patches that address the issue.

I'll look into creating such a patch. The test case was having some
"basic templates" to choose from but then allowing users to edit those
templates to meet their own prefs.  The syncdb to add additional apps
killed the modified templates.


> > 2) Setting up users/groups/users manually in the runner gets blown
> > away by the TestCase architecture.  Works as documented.  However, I'm
> > not sure where I should put things that should happen post-each syncdb
> > for testing only.  Should there be a testrunner function that gets
> > called post each sync or should I create a single TestCase derived
> > from django.test.TestCase that does the "pre-setup"?
>
> I'm not sure I follow. TestCase goes out of its way to avoid
> interfering with setUp/tearDown methods, and in a TestCase, there is a
> complete flush after each test, so any setup would need to be rerun on
> a per-test basis, not a per-sync basis. Can you provide an example of
> the problem?

Sure: My runner simplified

The suggestion is I need to move setup_auth() to my test methods.
That does seem to be the right way to do it so I can have different
perms across each item.

def permission_finder(s):
""" Given a string in the format app_label.codename, return the
exact permission """
parts = s.split('.')
if len(parts) != 2:
raise UnknownPermission, "Unable to parse permission string
%s"%  s

m,c = parts

model_perms =
Permission.objects.filter(content_type__app_label__exact=m)

if not model_perms:
raise UnknownPermission, "No such model permissions: %s" % m

perms = model_perms.filter(codename__exact=c)

if not perms:
raise UnknownPermission, "No permissions found for %s.%s" %
(m,c)

return perms

def setup_auth():
 # Helpdesk Perms
 helpdesk_perms = permission_finder('helpdesk.view_logs')

 # Level 2 Perms
 l2_perms = (helpdesk_perms,
 
permission_finder('helpdesk.reset_passwords'))

l1group = Group(name='Level1 Support')
l1group.save()

l2group = Group(name='Level2 Support')
l2group.save()

for each in l2_perms:
assert(each)
for p in each:
print "adding %s to %s" % (p,g1)
g1.permissions.add(p)

u1 = User.objects.create_user('level1user', '[EMAIL PROTECTED]',
'password')
u1.save()
u1.groups.add(g1)

def run_tests(...):
setup_middleware() # get rid of cas for Unit Testing
setup_test_environment()
[ Build the test suite ]
old_name = settings.DATABASE_NAME
create_test_db(verbosity,autoclobber=True)
setup_auth()
unittest.TextTestRunner(verbosity=verbosity).run(suite)
destroy_test_db(old_name, verbosity)
teardown_test_environment()





>
> > 3) DateTime serialization won't work if the date is before 1901 - I
> > have a bug/real life data set where I get some bogus dates out of
> > another system.   This is really a python problem.
>
> Again, if you can provide an example, it would help. However, if the
> problem is with Python itself, there's not a great deal we can do.
>

class DateModel(models.Model):
 time = models.DateTime()

dm = DateModel(time=datetime.datetime(1,1,1))

Since strptime() breaks with dates before 1901, it gets serialized out
with dumpdata but fails on a loaddata()


--~--~-~--~~~---~--~~
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: Launchpad - Community for free projects

2007-08-10 Thread Jonas



On 10 ago, 17:43, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> I'm not entirely clean why you posted this here -- are you proposing
> that Django switch to Launchpad (hint: don't).
Of course that not.

I posted it here bacause I have been that there are many projects
based on Python/Django hosted on Google Code and as found a better
service where the community can integrate and participate better then
I said it.


--~--~-~--~~~---~--~~
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: Multilingual site best practices

2007-08-10 Thread Grupo Django


Vincent Foley ha escrito:
> Hello,
>
> I work for a company who develops web sites and web applications for
> clients in Quebec.  People in Quebec mainly speak french, but there
> are english speaking people too.  Most sites we make eventually want
> to have a french and english version with french being the "main"
> version.
>
> I would like to know if anyone could share best practices for
> multilingual sites.  I also have some questions:
>
> 1. In the {% trans %} and {% blocktrans %} tags, should I include the
> full text, or just a quick description and enter the full text in
> the .po files?
>
> 2. As I said, french is the main language in Quebec, so if I write a
> site in french and am later asked to translate it, will the accented
> characters cause a problem if they're used in the msgid of the .po
> files?
>
> 3. It seems the server always has to be restarted after the .po files
> have been compiled.  Is that so?  If I don't have root access to the
> server to restart Apache, is there a way I can have the new
> definitions appear on the site?
>
> Thanks for the input,
>
> Vincent.

I'd like to extend this questions.
4. Best practice to use a multilingual database. i.e. News in English
and French from an app. I need it for a project. I'll write some docs
about it when I get it to work, if I get it ;-) IMHO, multilingual in
the interface but monolingual in database, is not very useful.
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: Launchpad - Community for free projects

2007-08-10 Thread Jacob Kaplan-Moss

On 8/10/07, Jonas <[EMAIL PROTECTED]> wrote:
> I found a great service to hosting free projects of software that let
> a great relation with the community and integration with Bazaar
> control version. Its name is launchpad.net, and the company behind is
> Canonical, the Ubuntu's creator.

I'm not entirely clean why you posted this here -- are you proposing
that Django switch to Launchpad (hint: don't).

Jacob

--~--~-~--~~~---~--~~
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: Presentations about Django?

2007-08-10 Thread Jacob Kaplan-Moss

On 8/10/07, Vincent Foley <[EMAIL PROTECTED]> wrote:
> Has your "Django Master Class" at OSCON 07 been taped?

It wasn't, but the handouts contain nearly all the info, and you can
find 'em here: http://toys.jacobian.org/presentations/2007/oscon/tutorial/

Jacob

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



MediaWiki Port in Django - Project Interest?

2007-08-10 Thread [EMAIL PROTECTED]

I've got a project where I need to build a public wiki for some
community websites. The main requirement is that the functionality be
similar to Mediawiki since many people are familiar with the way that
software works.

Does anyone know if a project like this has been undertaken? Would
anyone be interested in helping develop it? Would anyone be interested
in using it if it was released as a contrib app?

(Before anyone asks why I'm reinventing the wheel, I don't use PHP
anymore, I don't have PHP installed on my production servers, and I
want to use a common authentication system that is already in place
with my very large Django project)


--~--~-~--~~~---~--~~
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: Presentations about Django?

2007-08-10 Thread Vincent Foley

Has your "Django Master Class" at OSCON 07 been taped?

Vincent

On Aug 10, 11:12 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> On 8/10/07, Brian Rosner <[EMAIL PROTECTED]> wrote:
>
> > I saw the video of you presenting Django to Google at one of their Tech
> > Talks and I am not sure if I read/heard this somewhere, but is that
> > presentation freely available under the Creative Commons license or
> > something?
>
> It's athttp://video.google.com/videoplay?docid=-70449010942275062. I
> don't think the video itself is CC licensed, but as far as I'm
> concerned, anyone who wants to use the content in their own Django
> talks can certainly do so.
>
> The slides themselves are 
> athttp://toys.jacobian.org/presentations/2006/baypiggies/, btw, and a
> similar offer applies to them.
>
> Jacob


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



Re: Using Filter on a list of objects?

2007-08-10 Thread Greg

RajeshD, Tim, and Nis,
We'll I think I got it working.  I changed the following line:

Style.objects.filter(sandp__choice__in=choice_ids).distinct()
to
Style.objects.filter(sandp__in=choice_ids).distinct()

That brought back the correct records.

/

Also, the problem with:

y = y.filter(price__price_cat=request['price'])

Actually, wasn't a problem.  There wasn't a choice that contained 249
as the price



Here is the final version of my view:

def searchresult(request):
if request.method == 'POST':
NOT_PICKED = "---"
y = Choice.objects.all()
if ('price' in request.POST and request.POST['price'] <>
NOT_PICKED):
y = y.filter(price__price_cat__exact=request['price'])
if ('size' in request.POST and request.POST['size'] <> 
NOT_PICKED):
y = y.filter(size__size_cat__exact=request['size'])
choice_ids = [c.id for c in y]
styles = Style.objects.filter(sandp__in=choice_ids).distinct()
if ('color' in request.POST) and (request.POST['color'] <>
NOT_PICKED):
styles = styles.filter(color_cat=request['color'])
return render_to_response('searchresult.html', {'s': styles})

/

Hopefully, it's at least readable now.

Thanks again to everybody that helped!



On Aug 10, 8:48 am, RajeshD <[EMAIL PROTECTED]> wrote:
> Hi Greg,
>
> Please see some notes below.
>
> > def searchresult(request):
> > if request.method == 'POST':
> > NOT_PICKED = "---"
> > y = Choice.objects.all()
> > if ('price' in request.POST and request.POST['price'] <>
> > NOT_PICKED):
>
> You could simplify idioms like the above into a single condition:
>
> if request.POST.get('price', None) <> NOT_PICKED:
>
>
>
> > y = y.filter(price__price_cat=request['price'])
> > if ('size' in request.POST and request.POST['size'] <> 
> > NOT_PICKED):
> > y = y.filter(size__size_cat=request['size'])
> > choice_ids = [c.id for c in y]
> > styles =
> > Style.objects.filter(sandp__choice__in=choice_ids).distinct()
> > if ('color' in request.POST) and (request.POST['color'] <>
> > NOT_PICKED):
> > styles = styles.filter(color_cat=request['color'])
> > return render_to_response('searchresult.html', {'s': styles})
>
> > 
>
> > I'm having a couple of problems with this code.  First is the
> > following code:
>
> > y = y.filter(price__price_cat=request['price'])
>
> Can you paste your entire model so we can see how you have defined
> Choices, Price, Color, etc? ManyToManyFields get trickier when you
> need to join multiple tables. I suspect that's what is causing this
> problem for you.
>
> > I currently have two prices in the 200-299 range (249 and 299).  If
> > the user does a search for price between 200-299 then the only thing
> > this filter returns is the first one.  I never returns more than one.
> > For example when i do a assert False, y after the statement above I
> > get:
>
> > AssertionError at /rugs/searchresult/
> > [, )>]
>
> > I do have a record in my choice table that has 249 as the price.
>
> Instead of using assertions and debug print statements, it will save
> you a lot of time if you dropped into a shell (python manage.py shell)
> and ran a few of these querysets directly in there. View->Browse->Fix->Repeat 
> takes much longer in situations where you are just looking to
>
> create the right query sets.


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



Multilingual site best practices

2007-08-10 Thread Vincent Foley

Hello,

I work for a company who develops web sites and web applications for
clients in Quebec.  People in Quebec mainly speak french, but there
are english speaking people too.  Most sites we make eventually want
to have a french and english version with french being the "main"
version.

I would like to know if anyone could share best practices for
multilingual sites.  I also have some questions:

1. In the {% trans %} and {% blocktrans %} tags, should I include the
full text, or just a quick description and enter the full text in
the .po files?

2. As I said, french is the main language in Quebec, so if I write a
site in french and am later asked to translate it, will the accented
characters cause a problem if they're used in the msgid of the .po
files?

3. It seems the server always has to be restarted after the .po files
have been compiled.  Is that so?  If I don't have root access to the
server to restart Apache, is there a way I can have the new
definitions appear on the site?

Thanks for the input,

Vincent.


--~--~-~--~~~---~--~~
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: Presentations about Django?

2007-08-10 Thread Jacob Kaplan-Moss

On 8/10/07, Brian Rosner <[EMAIL PROTECTED]> wrote:
> I saw the video of you presenting Django to Google at one of their Tech
> Talks and I am not sure if I read/heard this somewhere, but is that
> presentation freely available under the Creative Commons license or
> something?

It's at http://video.google.com/videoplay?docid=-70449010942275062. I
don't think the video itself is CC licensed, but as far as I'm
concerned, anyone who wants to use the content in their own Django
talks can certainly do so.

The slides themselves are at
http://toys.jacobian.org/presentations/2006/baypiggies/, btw, and a
similar offer applies to them.

Jacob

--~--~-~--~~~---~--~~
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: basic testing procedure?

2007-08-10 Thread Tim Chase

> if you have an app named "tests" and you add it to your INSTALLED_APPS
> (which I guess is necessary) - does django create any tables or any
> content (e.g., additional content-types) outside the test-database?


I would proffer that unless there's a pressing reason to name
your app "tests" (such as you're writing academic software or
software whose purpose is testing the user or something they
have), I would avoid tempting fate by using "tests" as my appname.

I just create a folder called "tests/" within my regular app.

As for your "does django create any tables or any
content...outside the test-database", my understanding is that
the answer is "mostly no".  A fresh testing DB is created,
populated, tested against, and then dropped.  However, if you
have Image or File fields which store pieces outside the DB,
their associated flotsam may linger about.

-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: Presentations about Django?

2007-08-10 Thread Brian Rosner

On 2007-08-10 08:21:59 -0600, "Jacob Kaplan-Moss" 
<[EMAIL PROTECTED]> said:

> 
> Hi Horst --
> 
> See http://www.djangoproject.com/community/logos/ -- that page has
> downloadable high-res logos, along with some pretty simple usage
> guidlines. In general, as long as you're using the Django logo to
> promote Django itself (and not some other project/product), nobody's
> going to come down on you.
> 
> Jacob
> 
> 
Jacob,

I saw the video of you presenting Django to Google at one of their Tech 
Talks and I am not sure if I read/heard this somewhere, but is that 
presentation freely available under the Creative Commons license or 
something?  If not, I think it might be a great value to the community 
to present Django to their user groups or wherever.  It would need to 
be revised since your Tech Talk, but will help with the promotion of 
Django and keeping those presentations consistent.

-- 
Brian Rosner
http://www.brosner.com/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
-~--~~~~--~~--~--~---



Re: databrowse, coercing to Unicode:

2007-08-10 Thread paulh

Here is the stack:


TypeError at /databrowse/
coercing to Unicode: need string or buffer, __proxy__ found
Request Method: GET
Request URL:http://pan.dynalias.com/databrowse/
Exception Type: TypeError
Exception Value:coercing to Unicode: need string or buffer,
__proxy__ found
Exception Location: /usr/lib/python2.4/site-packages/django/utils/
encoding.py in force_unicode, line 37
Python Executable:  /usr/bin/python
Python Version: 2.4.3
Template error

In template /usr/lib/python2.4/site-packages/django/contrib/databrowse/
templates/databrowse/homepage.html, error at line 9
Caught an exception while rendering: coercing to Unicode: need string
or buffer, __proxy__ found
1   {% extends "databrowse/base.html" %}
2
3   {% block title %}Databrowse{% endblock %}
4
5   {% block bodyid %}homepage{% endblock %}
6
7   {% block content %}
8
9   {% for model in model_list %}
10  
11  {{ model.verbose_name_plural|
capfirst }}
12  
13  {% for object in model.sample_objects %}
14  {{ object|escape }},
15  {% endfor %}
16  More 
17  
18  
19  {% endfor %}
Traceback (innermost last)
Switch to copy-and-paste view

* /usr/lib/python2.4/site-packages/django/template/__init__.py in
render_node
   747.
   748. def render_node(self, node, context):
   749. return node.render(context)
   750.
   751. class DebugNodeList(NodeList):
   752. def render_node(self, node, context):
   753. try:
   754. result = node.render(context) ...
   755. except TemplateSyntaxError, e:
   756. if not hasattr(e, 'source'):
   757. e.source = node.source
   758. raise
   759. except Exception, e:
   760. from sys import exc_info
  ▼ Local vars
  Variable  Value
  context
  [{'forloop': {'parentloop': {}, 'last': True, 'counter': 1,
'revcounter0': 0, 'revcounter': 1, 'counter0': 0, 'first': True},
u'model': }, {'block': , , ]>}, {'root_url': u'/databrowse/',
'model_list': []}]
  e
  
  exc_info
  
  node
  
  self
  [, , ]
  wrapped
  
* /usr/lib/python2.4/site-packages/django/template/defaulttags.py
in render
   127. }
   128. if unpack:
   129. # If there are multiple loop variables, unpack the item
into them.
   130. context.update(dict(zip(self.loopvars, item)))
   131. else:
   132. context[self.loopvars[0]] = item
   133. for node in self.nodelist_loop:
   134. nodelist.append(node.render(context)) ...
   135. if unpack:
   136. # The loop variables were pushed on to the context so pop
them
   137. # off again. This is necessary because the tag lets the
length
   138. # of loopvars differ to the length of each set of items
and we
   139. # don't want to leave any vars from the previous loop on
the
   140. # context.
  ▼ Local vars
  Variable  Value
  context
  [{'forloop': {'parentloop': {}, 'last': True, 'counter': 1,
'revcounter0': 0, 'revcounter': 1, 'counter0': 0, 'first': True},
u'model': }, {'block': , , ]>}, {'root_url': u'/databrowse/',
'model_list': []}]
  i
  0
  item
  
  len_values
  1
  node
  
  nodelist
  [u'\n \n\t ']
  parentloop
  {}
  self
  
  unpack
  False
  values
  []
* /usr/lib/python2.4/site-packages/django/template/__init__.py in
render
   783.
   784. def render(self, context):
   785. return self.filter_expression.resolve(context)
   786.
   787. class DebugVariableNode(VariableNode):
   788. def render(self, context):
   789. try:
   790. return self.filter_expression.resolve(context) ...
   791. except TemplateSyntaxError, e:
   792. if not hasattr(e, 'source'):
   793. e.source = self.source
   794. raise
   795.
   796. def generic_tag_compiler(params, defaults, name,
node_class, parser, token):
  ▼ Local vars
  Variable  Value
  context
  [{'forloop': {'parentloop': {}, 'last': True, 'counter': 1,
'revcounter0': 0, 'revcounter': 1, 'counter0': 0, 'first': True},
u'model': }, {'block': , , ]>}, {'root_url': u'/databrowse/',
'model_list': []}]
  self
  
* /usr/lib/python2.4/site-packages/django/template/__init__.py in
resolve
   575. upto = match.end()
   576. if upto != len(token):
   577. raise TemplateSyntaxError, "Could not parse the remainder:
'%s' from '%s'" % (token[upto:], token)
   578. self.var, self.filters = var, filters
   579.
   580. def resolve(self, context, ignore_failures=False):
   581. try:
   582. obj = resolve_variable(self.var, context) ...
   583. except VariableDoesNotExist:
   584. if ignore_failures:
   585. obj = None
   586. else:
   587. if settings.TEMPLATE_STRING_IF_INVALID:
   588. global invalid_var_format_string
  ▼ Local vars
  Variable  Value
  context
  

Re: basic testing procedure?

2007-08-10 Thread patrickk

thanks tim. that´s very useful.

one additional question:
if you have an app named "tests" and you add it to your INSTALLED_APPS
(which I guess is necessary) - does django create any tables or any
content (e.g., additional content-types) outside the test-database?

patrick.

On Aug 10, 2:19 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > 1. where to define the testing? in models.py or in tests.py? I´d like
> > to seperate the testing from models.py, so how can I write doctests
> > in a seperate file (the example in the django documentation only
> > explains seperate unit-testing)?
>
> my understanding is that doctests can only be (for the
> better...one might be able to monkey-patch them from remote
> modules, but it's ugly) in the module they're testing.  Unit
> tests don't have this limitation and can be put in separate files.
>
> > 2. can I make a test-directory (and does that make sense) for all my
> > tests or do I have to use the application-directories? within
> > django_src, there´s a directory called "tests" for example.
>
> With unit tests, yes.  I had found that having everything in a
> single tests.py started to get too big to comfortably manage.
> I've done this with a tests/ folder with an __init__.py file that
> imports * from all my test modules:
>
> ~/proj/app/tests/__init__.py
> ~/proj/app/tests/model1.py
> ~/proj/app/tests/model2.py
> ~/proj/app/tests/view1.py
> ...
>
> and __init__.py contains
>
>   from model1 import *
>   from model2 import *
>   from view1 import *
>   ...
>
> one has to be slightly careful of naming clashes in your testing
> modules, however these just involve the class names (of your
> testing classes) so it's pretty easy to prevent conflicts.
>
> > 3. where do I find some examples (besides the django docs)?
>
> I wish I could provide more info here...for the most part, it's
> just standard Python testing, so any resources on general testing
> in python should be helpful.  For such resources, I think the
> F-bot and Ian Bickling have posted some good web pages that
> supplement the more terse docs.python.org descriptions of
> testing.  A little googling might be in order.
>
> There are a couple django-specific items, such as fixtures (a
> little sparsely documented, but this list has helped with some
> clarifications, so the archives may be useful) and the custom
> test object that supports them (along with some other nicities).
>  However, once you're comfortable with regular Python testing, at
> least the custom Django test object is easy to understand.
> Fixtures are still a bit fuzzy for me.
>
> > 4. does anyone know about a simple "how-to" on testing? something
> > like "step 1: setup the testing-database", "step 2: create a test-
> > directory (or use the app-dir or whatever)" ... ?
>
> One of the beauties of Django is that, when you run "./manage.py
> test", it takes care of creating the testing DB, populating it
> with any initial data (fixtures) specified for each test,
> clearing the DB between tests, etc.
>
> I don't have any good pointers to a step-by-step, but I find that
> writing my tests first and then writing the code to implement
> them helps keep me focused on (1) having automated testing to
> prevent regressions, and (2) the very next task at hand (rather
> than implementing miles ahead of myself in a direction I didn't
> need to go).
>
> Just my early-morning thoughts on Django+testing
>
> -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: Presentations about Django?

2007-08-10 Thread Jacob Kaplan-Moss

Hi Horst --

See http://www.djangoproject.com/community/logos/ -- that page has
downloadable high-res logos, along with some pretty simple usage
guidlines. In general, as long as you're using the Django logo to
promote Django itself (and not some other project/product), nobody's
going to come down on you.

Jacob

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



how to define a User?

2007-08-10 Thread tit4

Hi,

I want to store a User who modify or create the Object:

class Object(models.Model):
...
 user = models.ForeignKey(django.contrib.auth.models.User,
editable=False)
...

the question is: how can I define User who save/create particular
object
inside save() method?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Generating charts with ReportLab

2007-08-10 Thread [EMAIL PROTECTED]

This library looks pretty nice too... for graphs... if you decide not
to go the reportlab route.  I haven't fiddled with it any, but was
looking over the docs and it looks promising:
http://nullcube.com/software/pygdchart2.html

On Aug 6, 4:12 am, "Ben Ford" <[EMAIL PROTECTED]> wrote:
> Hi Carole,
> Just FYI as they are kind of related topics, I've created a project called
> django-reports  with some of my
> code for reporting on your django objects. I thought you might find it
> interesting and integration with reportlabs would be a cool feature for the
> future. See my other message to the group or the link for more details. To
> everyone else: Sorry for the double message for those of you not using gmail
> :-)
> Ben
>
> On 30/07/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hey Ben...thanks...I'll check that out.
>
> > We'll most likely continue to use ReportLab for our project, as we are
> > using the graphs in some reports we are going to export to PDF... but
> > looks like an interesting read :)
>
> > I'll also add the other two samples to the wiki this week...
> > Carole
>
> > On Jul 30, 4:29 am, "Ben Ford" <[EMAIL PROTECTED]> wrote:
> > > Hey Carole,
> > > A guy called Toby has put something together using R and rpy that does
> > > graphs... I haven't been able to make it work as yet, but he's keen to
> > move
> > > on with it, and wants some testers and some help!
> > > Check out:
> >http://groups.google.com/group/django-users/browse_thread/thread/43ea...
>
> > > or just have a look through your gmail for *Re: Graphs and django.*
> > > (The search string "contrib namespace r" worked for me.)
> > > Ben
>
> > > On 30/07/07, David Reynolds <[EMAIL PROTECTED] > wrote:
>
> > > > On 28 Jul 2007, at 4:34 am, [EMAIL PROTECTED] wrote:
>
> > > > > I had the need to generate a few different types of charts using
> > > > > ReportLab.  The wiki only had a sample of a Horizontal Bar Chart, so
> > > > > I've added a new sample on how to produce a Line Chart...
> > > > >http://code.djangoproject.com/wiki/Charts
>
> > > > > If anyone is interested in a sample for a Pie or Scatter chart, let
> > me
> > > > > know, and I can add samples of these as well.
>
> > > > I would say, go ahead and add them, as I'm sure many people will find
> > > > them useful at some point.
>
> > > > Thanks,
>
> > > > David
>
> > > > --
> > > > David Reynolds
> > > > [EMAIL PROTECTED]
>
> > > --
> > > Regards,
> > > Ben Ford
> > > [EMAIL PROTECTED]
> > > +628111880346
>
> --
> Regards,
> Ben Ford
> [EMAIL PROTECTED]
> +628111880346


--~--~-~--~~~---~--~~
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: url styling

2007-08-10 Thread Filipe Correia

>From a REST perspective, I think the best would be to make the action
part of the query string.
However, I also know not everyone agrees with this, so don't take my
word for it.

--
Filipe

On Aug 10, 6:21 am, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> is there any advantage or disadvantage or best practices in forming
> urls? like which set are much better?
>
> domain/employee/1
> domain/edit_employee/1
> domain/inactive_employee/1
>
> or
>
> domain/employee/1
> domain/employee/1/edit/
> domain/employee/1/inactive/
>
> thanks
> james


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



Re: django built-in web server

2007-08-10 Thread Justin Johnson


I did spend some time looking at a third option - py2exe.  In general 
this works really well and means you can package up with a single 
install.  The only snag is that django has lots of dynamic imports which 
means you have to have a source file somewhere that imports statically.  
I ran out of time experimenting with that but I'd like to hear if anyone 
else has successfully deployed a django project with py2exe.

> I'm having a similar situation now.  The requirement is to pack my web
> app so that an average user without programming or network
> administration background can easily install it on windows.
>
> I'm considering:
>
> 1) pack the whole apache with default conf + sqlite + python + django
> + my project as a whole msi cabinet.
>
> 2) let them install python first (which is easy enough I think) then
> use something like python setuptools to install django and the
> project.  The http server must be run in python.  Have to install
> sqlite manually?
>
> It seems 2) is better but it might still be too complex to install.
> Still evaluating my options now...
>
> On Aug 10, 5:36 pm, Justin Johnson <[EMAIL PROTECTED]> wrote:
>   
>> Apache is the easiest and most documented route.  It is pretty easy to
>> set-up and config so don't let that put you off.
>>
>> However, I had a situation where I needed a single self-contained
>> install for deployment.  On that occasion I used CherryPy3 + WSGI and
>> ran the whole thing as a windows service using the Python Win32
>> library.  It worked out really well.  I also had a 'debug' mode where I
>> can run my server from the command line and see all requests etc - again
>> utilising CherryPy3.  IMHO, that worked out much better than using
>> Django's test server because it didn't require any extra URL information
>> for serving media.
>>
>> Django's test server isn't going to cut it for deployment and using
>> Apache is simple.  Just a few lines of config in httpd.conf and you're
>> done.  Avoiding Apache isn't going to make life easier for you.
>>
>> 
>>> hi,
>>>   
>>> Can I use the django's built in web server in an intranet enviroment
>>> where the maximum users could be not more than 50 users? I am just
>>> asking this for the purpose for easy deployment :). I am very newbie,
>>> and trying to avoid apache
>>>   
>>> THanks
>>> james
>>>   
>
>
> >
>
>
>   

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



Re: Using Filter on a list of objects?

2007-08-10 Thread RajeshD

Hi Greg,

Please see some notes below.

> def searchresult(request):
> if request.method == 'POST':
> NOT_PICKED = "---"
> y = Choice.objects.all()
> if ('price' in request.POST and request.POST['price'] <>
> NOT_PICKED):

You could simplify idioms like the above into a single condition:

if request.POST.get('price', None) <> NOT_PICKED:

> y = y.filter(price__price_cat=request['price'])
> if ('size' in request.POST and request.POST['size'] <> 
> NOT_PICKED):
> y = y.filter(size__size_cat=request['size'])
> choice_ids = [c.id for c in y]
> styles =
> Style.objects.filter(sandp__choice__in=choice_ids).distinct()
> if ('color' in request.POST) and (request.POST['color'] <>
> NOT_PICKED):
> styles = styles.filter(color_cat=request['color'])
> return render_to_response('searchresult.html', {'s': styles})
>
> 
>
> I'm having a couple of problems with this code.  First is the
> following code:
>
> y = y.filter(price__price_cat=request['price'])

Can you paste your entire model so we can see how you have defined
Choices, Price, Color, etc? ManyToManyFields get trickier when you
need to join multiple tables. I suspect that's what is causing this
problem for you.

> I currently have two prices in the 200-299 range (249 and 299).  If
> the user does a search for price between 200-299 then the only thing
> this filter returns is the first one.  I never returns more than one.
> For example when i do a assert False, y after the statement above I
> get:
>
> AssertionError at /rugs/searchresult/
> [, )>]
>
> I do have a record in my choice table that has 249 as the price.

Instead of using assertions and debug print statements, it will save
you a lot of time if you dropped into a shell (python manage.py shell)
and ran a few of these querysets directly in there. View->Browse->Fix-
>Repeat takes much longer in situations where you are just looking to
create the right query sets.


--~--~-~--~~~---~--~~
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: databrowse, coercing to Unicode:

2007-08-10 Thread Michael Radziej

On Fri, Aug 10, paulh wrote:

> 
> I have tried the databrowse app on a couple of projects, but it fails
> on both with the same error. I wondered whether anyone else has seen
> this error message:
> 
> coercing to Unicode: need string or buffer, __proxy__ found
> 
> If you need the whole stack, let me know.

Might be a bug, please provide the whole stack.

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

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



Re: Django on Linux, MS SQL on Windoz

2007-08-10 Thread Peter Bailey
Thanks Florian. Guess I better have a look at SQLAlchemey - too bad that
branch of django does not seem to be advancing much either!. Thanks for your
help.

Peter


On 8/10/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> There is currently no fully working backend for mssql, but someone is
> working on it already (and I am sure he will need some testers).
> If I am not mistaken there is also http://pymssql.sourceforge.net/
>
> I hope this helps,
> Florian
>
> On Aug 9, 7:10 pm, [EMAIL PROTECTED] wrote:
> > Is it possible to run a django web server on a nix box and communicate
> > with a MS-SQL (2000) database on a Windoz 2003 server. I am looking
> > for a good python framework, and django seems like it might be the
> > one, but if it can't do this, that could be a show stopper. From what
> > I have seen, there is only the adodapi that you can use to connect to
> > sql server (and it may not be great), and I believe that has to run on
> > a doz box.
> >
> > I am trying to migrate away from windows, thus the desired
> > implementation above. Plan won't work if I have to run django on a
> > windows box.
> >
> > Help anyone ...
> >
> > 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: django built-in web server

2007-08-10 Thread TheMaTrIx

You could use something like XAMPP if your really unconfortable
setting up apache and mysql by hand.

Xampp's base install gives you apache and mysql preconfigured and
there is a python addon thats also preconfigured.

And if you can install and develop python/django apps, don't be to
afraid of installing Apache, its not that hard.



On Aug 10, 1:25 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
> > hi,
>
> > Can I use the django's built in web server in an intranet enviroment
> > where the maximum users could be not more than 50 users? I am just
> > asking this for the purpose for easy deployment :). I am very newbie,
> > and trying to avoid apache
>
> Unless something changed recently, the built in server is *not*
> threaded, meaning you can only service one request at a time. Even if
> only 50 people have access to the server, that might start causing
> problems for you.
>
> 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: Launchpad - Community for free projects

2007-08-10 Thread Horst Gutmann

Jonas wrote:
> I found a great service to hosting free projects of software that let
> a great relation with the community and integration with Bazaar
> control version. Its name is launchpad.net, and the company behind is
> Canonical, the Ubuntu's creator.
> 
> I have remained very impressed since I saw the tour [2], and it is
> clear that it allows a better relation with the developers community,
> much better than Google Code.
> 
> [2] https://launchpad.net/+about
> 
> These posts could help you with Bazaar and Launchpad:
> 
> http://blogs.gnome.org/jamesh/2006/08/17/shared-branches-using-bazaar-and-launchpad/
> http://ddaa.net/blog/launchpad/bzr-hosting
> 
> 

Launchpad is definitely a nice service with a nice community esp. since
their integration of a translation service, but it also has some quite
strange limitations currently like that you can't effectively remove
branches, which would be quite handy if _anything_ goes wrong during an
import (as was the case when I tried it).

- Horst

--~--~-~--~~~---~--~~
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: folder security

2007-08-10 Thread hiddenhippo

thanks so much. it's amazing how you spend hours sifting through
endless material only to find the answer was there all along.  I'll
take a look at the online documentation.

thanks again.

On Aug 10, 1:37 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > My problem is that the application requires private folders
> > for all the logged in users to store their content, and hence
> > my problem.  I know that you can password protect folders
> > using both apache and litehttpd however their methods don't
> > seem suitable.  I need to dynamically add users,
> [trimmed]
> > certain how I can stop users from changing the url in order to
> > gain access to different folder e.g.
>
> > myurl.com/user1/docs - user 1 could then change the url to
> > myurl.com/ user2/docs
>
> I suspect you simply haven't yet stumbled across Django's stock
> "auth" module in contrib/auth
>
> This comes with the ability to create users dynamically according
> to your DB and then control access to pages within them.
>
> Because of this, your URL scheme doesn't even need to include the
> user name/id unless non-logged-in users can see select portions
> of other users' data.  However, for that, one might implement
> something like
>
>   example.com/docs/   <- private for logged in user
>   example.com/public/ <- public for everybody
>
> Thus, your view can use the "login_required" decorator:
>
> @login_required
> def view_docs(request):
>   docs = Docs.objects.filter(user_id=request.user)
>   # do stuff with this user's docs
>   return results
>
> The django docs have a good primer on using the
> django.contrib.auth module and should get you pointed in the
> right direction.
>
> -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
-~--~~~~--~~--~--~---



Launchpad - Community for free projects

2007-08-10 Thread Jonas

I found a great service to hosting free projects of software that let
a great relation with the community and integration with Bazaar
control version. Its name is launchpad.net, and the company behind is
Canonical, the Ubuntu's creator.

I have remained very impressed since I saw the tour [2], and it is
clear that it allows a better relation with the developers community,
much better than Google Code.

[2] https://launchpad.net/+about

These posts could help you with Bazaar and Launchpad:

http://blogs.gnome.org/jamesh/2006/08/17/shared-branches-using-bazaar-and-launchpad/
http://ddaa.net/blog/launchpad/bzr-hosting


--~--~-~--~~~---~--~~
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: folder security

2007-08-10 Thread Tim Chase

> My problem is that the application requires private folders 
> for all the logged in users to store their content, and hence
> my problem.  I know that you can password protect folders
> using both apache and litehttpd however their methods don't
> seem suitable.  I need to dynamically add users, 
[trimmed]
> certain how I can stop users from changing the url in order to
> gain access to different folder e.g.
> 
> myurl.com/user1/docs - user 1 could then change the url to
> myurl.com/ user2/docs

I suspect you simply haven't yet stumbled across Django's stock
"auth" module in contrib/auth

This comes with the ability to create users dynamically according
to your DB and then control access to pages within them.

Because of this, your URL scheme doesn't even need to include the
user name/id unless non-logged-in users can see select portions
of other users' data.  However, for that, one might implement
something like

  example.com/docs/   <- private for logged in user
  example.com/public/ <- public for everybody

Thus, your view can use the "login_required" decorator:


@login_required
def view_docs(request):
  docs = Docs.objects.filter(user_id=request.user)
  # do stuff with this user's docs
  return results

The django docs have a good primer on using the
django.contrib.auth module and should get you pointed in the
right direction.

-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: basic testing procedure?

2007-08-10 Thread Tim Chase

> 1. where to define the testing? in models.py or in tests.py? I´d like  
> to seperate the testing from models.py, so how can I write doctests  
> in a seperate file (the example in the django documentation only  
> explains seperate unit-testing)?

my understanding is that doctests can only be (for the
better...one might be able to monkey-patch them from remote
modules, but it's ugly) in the module they're testing.  Unit
tests don't have this limitation and can be put in separate files.

> 2. can I make a test-directory (and does that make sense) for all my  
> tests or do I have to use the application-directories? within  
> django_src, there´s a directory called "tests" for example.

With unit tests, yes.  I had found that having everything in a
single tests.py started to get too big to comfortably manage.
I've done this with a tests/ folder with an __init__.py file that
imports * from all my test modules:

~/proj/app/tests/__init__.py
~/proj/app/tests/model1.py
~/proj/app/tests/model2.py
~/proj/app/tests/view1.py
...

and __init__.py contains

  from model1 import *
  from model2 import *
  from view1 import *
  ...

one has to be slightly careful of naming clashes in your testing
modules, however these just involve the class names (of your
testing classes) so it's pretty easy to prevent conflicts.

> 3. where do I find some examples (besides the django docs)?

I wish I could provide more info here...for the most part, it's
just standard Python testing, so any resources on general testing
in python should be helpful.  For such resources, I think the
F-bot and Ian Bickling have posted some good web pages that
supplement the more terse docs.python.org descriptions of
testing.  A little googling might be in order.

There are a couple django-specific items, such as fixtures (a
little sparsely documented, but this list has helped with some
clarifications, so the archives may be useful) and the custom
test object that supports them (along with some other nicities).
 However, once you're comfortable with regular Python testing, at
least the custom Django test object is easy to understand.
Fixtures are still a bit fuzzy for me.

> 4. does anyone know about a simple "how-to" on testing? something  
> like "step 1: setup the testing-database", "step 2: create a test- 
> directory (or use the app-dir or whatever)" ... ?

One of the beauties of Django is that, when you run "./manage.py
test", it takes care of creating the testing DB, populating it
with any initial data (fixtures) specified for each test,
clearing the DB between tests, etc.

I don't have any good pointers to a step-by-step, but I find that
writing my tests first and then writing the code to implement
them helps keep me focused on (1) having automated testing to
prevent regressions, and (2) the very next task at hand (rather
than implementing miles ahead of myself in a direction I didn't
need to go).

Just my early-morning thoughts on Django+testing

-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: Error from URLs with non-ascii characters and that need login

2007-08-10 Thread web-junkie

Okay, after further investigation the error appears for me too, not
just googlebot. When I browse the site as anonymous user and click a
link with encoded Unicode in URL, and if that links needs login, I get
an error.
Seems to be a bug in the checklogin decorator.

On Aug 8, 3:34 pm, web-junkie <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I get that error emailed, apparently Google tries to crawl pages that
> need a login. Now when there's Unicode in the URL this error is
> raised.
> Can anyone tell me why I get this error? It's really just Google's
> crawl, when I surf the site everything works fine.
>
> Traceback (most recent call last):
>
>  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/
> base.py", line 77, in get_response
>response = callback(request, *callback_args, **callback_kwargs)
>
>  File "/usr/local/lib/python2.4/site-packages/django/contrib/auth/
> decorators.py", line 18, in _checklogin
>return HttpResponseRedirect('%s?%s=%s' % (login_url,
> REDIRECT_FIELD_NAME, quote(request.get_full_path(
>
>  File "/usr/local/lib/python2.4/urllib.py", line 1117, in quote
>res = map(safe_map.__getitem__, s)
>
> KeyError: u'\xdf'
>
>  \nPOST:,\nCOOKIES:{},\nMETA:{'AUTH_TYPE': None,\n
> 'CONTENT_LENGTH': 0L,\n 'CONTENT_TYPE': None,\n 'GATEWAY_INTERFACE':
> 'CGI/1.1',\n 'HTTP_ACCEPT': '*/*',\n 'HTTP_ACCEPT_ENCODING': 'gzip',\n
> 'HTTP_CONNECTION': 'Keep-alive',\n 'HTTP_FROM':
> 'googlebot(at)googlebot.com',\n [...]


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



Re: Django on Linux, MS SQL on Windoz

2007-08-10 Thread Jeremy Dunck

On 8/10/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
> Hi,
> There is currently no fully working backend for mssql, but someone is
> working on it already (and I am sure he will need some testers).
> If I am not mistaken there is also http://pymssql.sourceforge.net/

The new effort for SQL Server support is using pymssql.

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



databrowse, coercing to Unicode:

2007-08-10 Thread paulh

I have tried the databrowse app on a couple of projects, but it fails
on both with the same error. I wondered whether anyone else has seen
this error message:

coercing to Unicode: need string or buffer, __proxy__ found

If you need the whole stack, let me know.

Paul Hide


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



Re: django built-in web server

2007-08-10 Thread Jay Parlar

On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> hi,
>
> Can I use the django's built in web server in an intranet enviroment
> where the maximum users could be not more than 50 users? I am just
> asking this for the purpose for easy deployment :). I am very newbie,
> and trying to avoid apache

Unless something changed recently, the built in server is *not*
threaded, meaning you can only service one request at a time. Even if
only 50 people have access to the server, that might start causing
problems for you.

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



Presentations about Django?

2007-08-10 Thread Horst Gutmann

Hi :-)

I'm currently thinking about doing a small presentation of Django at a
BarCamp in Vienna this fall - nothing big, probably just a short intro
of what you need to get it running with some small hints for Dreamhost
and perhaps a small demo app - and I wanted to know, if there are any
rules I have to adhere to what I'm allowed to use.

Like for example what kind of logo I'm allowed to use and which I should
use and so on.

Thank you.

- Horst

--~--~-~--~~~---~--~~
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: scheduling job

2007-08-10 Thread Kresimir Sojat


Here is example how to create django cron job:
http://slowchop.com/index.php/2006/09/17/creating-a-django-cron-job/


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



Re: django built-in web server

2007-08-10 Thread John Lee

I'm having a similar situation now.  The requirement is to pack my web
app so that an average user without programming or network
administration background can easily install it on windows.

I'm considering:

1) pack the whole apache with default conf + sqlite + python + django
+ my project as a whole msi cabinet.

2) let them install python first (which is easy enough I think) then
use something like python setuptools to install django and the
project.  The http server must be run in python.  Have to install
sqlite manually?

It seems 2) is better but it might still be too complex to install.
Still evaluating my options now...

On Aug 10, 5:36 pm, Justin Johnson <[EMAIL PROTECTED]> wrote:
> Apache is the easiest and most documented route.  It is pretty easy to
> set-up and config so don't let that put you off.
>
> However, I had a situation where I needed a single self-contained
> install for deployment.  On that occasion I used CherryPy3 + WSGI and
> ran the whole thing as a windows service using the Python Win32
> library.  It worked out really well.  I also had a 'debug' mode where I
> can run my server from the command line and see all requests etc - again
> utilising CherryPy3.  IMHO, that worked out much better than using
> Django's test server because it didn't require any extra URL information
> for serving media.
>
> Django's test server isn't going to cut it for deployment and using
> Apache is simple.  Just a few lines of config in httpd.conf and you're
> done.  Avoiding Apache isn't going to make life easier for you.
>
> > hi,
>
> > Can I use the django's built in web server in an intranet enviroment
> > where the maximum users could be not more than 50 users? I am just
> > asking this for the purpose for easy deployment :). I am very newbie,
> > and trying to avoid apache
>
> > THanks
> > james


--~--~-~--~~~---~--~~
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: OperationalError 1054 Unknown column

2007-08-10 Thread AnaReis

Hum... I thought that to be an AutoField it was mandatory that "_id"
would have to be added to the name of the field... Apparently not! :)
Thanks.

Ana

On Aug 9, 6:57 pm, Collin Grady <[EMAIL PROTECTED]> wrote:
> Why did you add _id to your model definition for levelID ? The column
> does not have that.


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



basic testing procedure?

2007-08-10 Thread patrickk

I´ve been reading the slides for "Django Master Class" and the django  
documentation on testing, but I´m still not sure how to actually do  
some testing.

here are a couple of questions:
1. where to define the testing? in models.py or in tests.py? I´d like  
to seperate the testing from models.py, so how can I write doctests  
in a seperate file (the example in the django documentation only  
explains seperate unit-testing)?
2. can I make a test-directory (and does that make sense) for all my  
tests or do I have to use the application-directories? within  
django_src, there´s a directory called "tests" for example.
3. where do I find some examples (besides the django docs)?
4. does anyone know about a simple "how-to" on testing? something  
like "step 1: setup the testing-database", "step 2: create a test- 
directory (or use the app-dir or whatever)" ... ?

btw, I´ve also checked the docs for testing on python.org, but that  
doesn´t help much (at least in my case).

thanks,
patrick

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



Re: django built-in web server

2007-08-10 Thread Justin Johnson


Apache is the easiest and most documented route.  It is pretty easy to 
set-up and config so don't let that put you off.

However, I had a situation where I needed a single self-contained 
install for deployment.  On that occasion I used CherryPy3 + WSGI and 
ran the whole thing as a windows service using the Python Win32 
library.  It worked out really well.  I also had a 'debug' mode where I 
can run my server from the command line and see all requests etc - again 
utilising CherryPy3.  IMHO, that worked out much better than using 
Django's test server because it didn't require any extra URL information 
for serving media.

Django's test server isn't going to cut it for deployment and using 
Apache is simple.  Just a few lines of config in httpd.conf and you're 
done.  Avoiding Apache isn't going to make life easier for you.

> hi,
>
> Can I use the django's built in web server in an intranet enviroment
> where the maximum users could be not more than 50 users? I am just
> asking this for the purpose for easy deployment :). I am very newbie,
> and trying to avoid apache
>
> THanks
> james
>
>
> >
>
>
>   

--~--~-~--~~~---~--~~
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: pagination for search result ...

2007-08-10 Thread LaundroMat

request["filter"] is a session variable, that's why it works :)

On Aug 10, 5:25 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
> On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > hi,
>
> > > def list_filter(request):
> > > """Update session filter"""
> > > # request['filter'] is a hidden field. frankly, I don't know if
> > > this is really needed.
> > > # I added it in case I add another form to the template
> > > if request.method == 'POST' and request['filter'] == '1':
> > > request.session['filter_title'] = request.POST['title']
> > > request.session['filter_genre'] = request.POST['genre']
> > > request.session['filter_rating'] = request.POST['rating']
> > > return HttpResponseRedirect('/')
>
> > thanks kai :). is this request['filter'] a django builtin or u just
> > created it?
>
> No, I added it. It's a hidden field just to check that's the filter
> that is fired up and not another form on the page.
>
> To tell the truth, this should be request.POST['filter'] and I
> don't really know why request['filter'] worked. Thanks for
> pointing that out. :-)
>
> Kai


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



inconsistent timesince behavior

2007-08-10 Thread omat

When using the "timesince" template filter, I experience weird
behavior.

When I refresh a page, + 8 hours is added to the output of "timesince"
**randomly**. That is, one time I get the correct output, the other
time it is 8 hours added to the correct time.

This is so strange that I do not even know how to approach the
problem.

I check the data, and assured that it is not changing.

This happens only on the production environment: mod-pyhton, apache,
psycopg2

You may see it for yourself here:
http://www.turkpop.com/forum/

The site is in Turkish but you still may recognize the numbers in the
middle column changing randomly between two values (the correct and
the correct + 8 hours) as you refresh the page a couple of times.


Has anybody experienced something like that before? 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: url styling

2007-08-10 Thread Nicola Larosa

[RESTafarian zealotry follows: you have been warned. ;-) ]

james_027 wrote:
> is there any advantage or disadvantage or best practices in forming
> urls?

Yes, there is. By following web architecture principles, as formalized in
the REST (REpresentational State Transfer) methodology, you gain benefits
of simplicity, uniformity, interoperability and scalability.

This series of articles by Joe Gregorio is a good introduction to REST:

The Restful Web
http://www.xml.com/pub/at/34

Work on REST for Django is being done by Andreas Stuhlmüller within the
Google Summer Of Code initiative, here's his last report:

GSoC 2007 Status Update VI: Django REST interface
http://groups.google.com/group/django-developers/browse_thread/thread/f86bd8ea6579baaa/dd5598af026e62f2


> like which set are much better?
> 
> domain/employee/1
> domain/edit_employee/1
> domain/inactive_employee/1
> 
> or
> 
> domain/employee/1
> domain/employee/1/edit/
> domain/employee/1/inactive/

Neither. :-)

According to REST, you don't put verbs in your URLs. Verbs are already
contained in the HTTP protocol: GET and POST are usable by current
browsers, then there's PUT and DELETE (and a few others), accessible by
Django via this snippet:

HttpMethodsMiddleware
http://www.djangosnippets.org/snippets/174/

Here's a quick rundown of how your URLs could be refactored.

> domain/employee/1

GET /domain/employee/1

This one would return the default, read-only representation of the resource.


> domain/employee/1/edit/

I like using parameters for identifying alternate representations of
resources. In this case:

GET /domain/employee/1;editable

(notice the semicolon) would return the editable representation of the
resource. You could then edit it, and POST the data:

POST /domain/employee/1;editable


> domain/employee/1/inactive/

Is this meant to set the employee status? You could use the above POST to
just send the enable flag, or else you could separate the resource metadata
in a distinct representation, and POST that instead:

POST /domain/employee/1;metadata
Enabled: false


-- 
Nicola Larosa - http://www.tekNico.net/

Being online demands a tremendous amount of discipline. You must shut
out the world around you and focus exclusively on a glowing screen.
You must sit in a chair for hours on end and will your body to remain
still. You are at an altar, but you are both priest and supplicant.
 -- Scott Jason Cohen, July 2000



--~--~-~--~~~---~--~~
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: editing newforms field

2007-08-10 Thread james_027

Hi,

On Aug 10, 4:12 pm, Collin Grady <[EMAIL PROTECTED]> wrote:
> Yes, just edit the fields in form.fields :)

I am sorry, I didn't make it clear, I mean changing it like in views?

james


--~--~-~--~~~---~--~~
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: editing newforms field

2007-08-10 Thread Collin Grady

Yes, just edit the fields in form.fields :)


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



editing newforms field

2007-08-10 Thread james_027

hi,

is it possible to edit the newforms field like required from true to
false? or editing the widget property?

Thanks
james


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



Re: django built-in web server

2007-08-10 Thread Kenneth Gonsalves


On 10-Aug-07, at 1:19 PM, james_027 wrote:

>>
>>> I am very newbie,
>>> and trying to avoid apache
>>
>> why?
>>
>
> Just in case a problem occur, I think it could be more easy to
> troubleshoot it without being a apache expert? Or if threre's a patch
> for the client's program that need to be apply it could be much
> easier?

when your company becomes bigger, you will have to use apache - so  
might as well get used to it now. It isnt a big deal and once you get  
used to it you will be very happy.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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: scheduling job

2007-08-10 Thread Collin Grady

cron is definitely the proper way to do this (or the scheduled tasks
if you're stuck on windows)


--~--~-~--~~~---~--~~
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: Newforms validations & request.user

2007-08-10 Thread Collin Grady

Makes the most sense to me :)


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



Re: django built-in web server

2007-08-10 Thread Collin Grady

No, this will not work well at all.

Django's dev server is single-threaded, and as such, nobody else could
use it while it's serving a request - if even 2 people were browsing
around at any speed, you'd start running into delays.

Apache is easy. Use it :)


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



Re: django built-in web server

2007-08-10 Thread james_027

Hi,

>
> > I am very newbie,
> > and trying to avoid apache
>
> why?
>

Just in case a problem occur, I think it could be more easy to
troubleshoot it without being a apache expert? Or if threre's a patch
for the client's program that need to be apply it could be much
easier?

THanks
james


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



Re: django built-in web server

2007-08-10 Thread Kenneth Gonsalves


On 10-Aug-07, at 12:19 PM, james_027 wrote:

> Can I use the django's built in web server in an intranet enviroment
> where the maximum users could be not more than 50 users? I am just
> asking this for the purpose for easy deployment :).

sure
> I am very newbie,
> and trying to avoid apache

why?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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: session expire_date

2007-08-10 Thread Jens Diemer

KpoH schrieb:
> You can view all other settings in django_root_dir/conf/global_settings.py

Don't understand. How should this help me?
I would like to know, how long the current session is still valid.

Do I think to complex? Should I simply do this:

--
now = datetime.datetime.now()
cookie_age = datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)
expiry_date = now + cookie_age
--



-- 
Mfg.

Jens Diemer



A django powered CMS: http://www.pylucid.org


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



django built-in web server

2007-08-10 Thread james_027

hi,

Can I use the django's built in web server in an intranet enviroment
where the maximum users could be not more than 50 users? I am just
asking this for the purpose for easy deployment :). I am very newbie,
and trying to avoid apache

THanks
james


--~--~-~--~~~---~--~~
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: url styling

2007-08-10 Thread Sean Perry

On Aug 9, 2007, at 10:21 PM, james_027 wrote:

>
> hi,
>
> is there any advantage or disadvantage or best practices in forming
> urls? like which set are much better?
>
> domain/employee/1
> domain/edit_employee/1
> domain/inactive_employee/1
>
> or
>
> domain/employee/1
> domain/employee/1/edit/
> domain/employee/1/inactive/
>


Better is always subjective. From a technical perspective, here is  
what the URL patterns look like:

a)
simple form
r'domain/(?:(\w+)_)?(\w+)/(\d+)'

one where you get all of the items nicely named:
r'domain/(?:(?P\w+)_)?(?P\w+)/(?P\d+)'

b)
r'domain/(\w+)/(\d+)(?:/(\w+))?'

r'domain/(?P\w+)/(?P\d+)(?:/(?P\w+))?'

I see the first URL set as being function oriented and the second set  
being more object oriented. Just depends on how you prefer to see the  
world I suppose.

Personally, I would probably do the second one.

May I suggest the first choice get turned around slightly:
domain/employee_edit/1
Like I said, I see the first grouping as more functional style and it  
is good practice to name the object first in function names. You end  
up with a regex like this:
r'domain/(?P\w+)(?:_(?P\w+))?/(?P\d+)'
which reads better in my opinion.

BTW, the (?:) syntax lets you group things without adding more items  
to the groupdict result. Purely optional, I just like to be really  
explicit about my regexes.

--~--~-~--~~~---~--~~
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 this not allowed select_related()

2007-08-10 Thread james_027

THanks Doug

>
> class Employee(models.Model):
>  # your employee model fields here, no FKs to Contact or
> Assignment models
>  ...
>
> class EmployeeAssignment(models.Model):
> active = models.BooleanField()  # I added this
> employee = models.ForeignKey(Employee)
> ...
>
> class EmployeeContract(models.Model):
> active = models.BooleanField()  # I added this
> employee = models.ForeignKey(Employee)
> ...
>
> then you could do
>
> bob = Employee.objects.get(pk=1)
> current_contacts = bob.employeecontract_set.filter(active=True)
> current_assignments = bob.employeassignment_set.filter(active=True)
>
> I added the active flag to differentiate history vs current

cheers,
james


--~--~-~--~~~---~--~~
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: scheduling job

2007-08-10 Thread Hodren Naidoo

Try creating a cron job.

On Fri, 2007-08-10 at 06:42 +, james_027 wrote:
> hi,
> 
> This might not be a django stuff, but how could I write something that
> will execute itself depending on the frequency that I'll set. For
> example, since django session table needs to be clean up at a certain
> time, I want to write a script that will execute itself monthly to
> clean up the session table.
> 
> Thanks
> james
> 
> 
> 

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



scheduling job

2007-08-10 Thread james_027

hi,

This might not be a django stuff, but how could I write something that
will execute itself depending on the frequency that I'll set. For
example, since django session table needs to be clean up at a certain
time, I want to write a script that will execute itself monthly to
clean up the session table.

Thanks
james


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