Does fixtures loading invoke custom save method?

2009-04-13 Thread Kegan

I have a model with custom save() method. Does loading fixtures invoke
this method?

class MyModel(models.Model):
 def save(self, *args, **kwargs):
 doStuffs()

>From my testing, doStuffs() is not called when loading fixtures. It is
called when I do:

instance = MyModel()
instance.save()

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



Re: Leopard deploy directory?

2009-04-13 Thread John M

/opt is the typical linux location, my mac has a few things there now.

J

On Apr 13, 4:12 pm, Shannon  wrote:
> Hi -- I am working on a django-powered site on Leopard server.  Where
> is the recommended/conventional deployment directory?  Every example I
> see uses a particular user's home directory, but that does not seem
> appropriate for a production-level site.  I'm fairly new to the
> Leopard environment and am curious what people typically use for their
> production deployment directory.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use several different querysets in one single template(for a single url)?

2009-04-13 Thread John M

You might want to think about using the direct_to_template function
instead, it uses the Request Context values, which allows you to take
advantage of the login system, where as the render_to_response does
not (by default).

J

On Apr 13, 7:16 pm, jason  wrote:
> using the common view function(render_to_response) would solve the
> problems. i should have checked the django documentation more
> carefully.
>
> On Apr 13, 7:48 pm, jason  wrote:
>
> > hi guys,
>
> > i want to create a page includes several querysets to display several
> > boards of different staffs. i used the generic.list_detail to do this,
> > but the object_list seemed to accept only one dictionary argument to
> > go. so how can i use several querysets in the single template to
> > display different record sets? like the index page of most websites,
> > there are many contents from different data sources.
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use several different querysets in one single template(for a single url)?

2009-04-13 Thread jason

using the common view function(render_to_response) would solve the
problems. i should have checked the django documentation more
carefully.

On Apr 13, 7:48 pm, jason  wrote:
> hi guys,
>
> i want to create a page includes several querysets to display several
> boards of different staffs. i used the generic.list_detail to do this,
> but the object_list seemed to accept only one dictionary argument to
> go. so how can i use several querysets in the single template to
> display different record sets? like the index page of most websites,
> there are many contents from different data sources.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Send validation error message to the screen

2009-04-13 Thread Joshua Partogi

I'm sorry Malcolm,

I'm from Java background where I usually put messages on its own
stack. If the way django do it is to put it in context, then I'm gonna
use it that way.

Thanks for clearing this up. :-)

Cheers,

On Apr 13, 10:35 am, Malcolm Tredinnick 
wrote:
> On Sun, 2009-04-12 at 17:22 -0700,JoshuaPartogiwrote:
> > Thanks Malcolm,
>
> > What I'm looking after is sending my custom validation error message
> > that is not covered by django.
>
> But what does this mean? How is it different from passing any other
> piece of information to a template via the context you pass to
> Template.render() or render_to_response()? I'm still not understanding
> what the problem is here.

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



Re: Send validation error message to the screen

2009-04-13 Thread Joshua Partogi

Thanks Margie,

Let me try that first.

Cheers,

On Apr 14, 2:12 am, Margie  wrote:
> Not sure if this is what you are looking for, but I use the
> notifications app to add some extra info to my html, to alert the user
> that there are errors in the form below or to let them know that there
> was no error and the form was submitted successfully.
>
> In view.py:
>
>                 request.notifications.create('Invalid data in form',
> 'error') # render form again
>
> In your html:
>       {% if notifications %}
>           
>               {% for notification in notifications %}
>               
> {{ notification.content }}
>               {% endfor %}
>           
>       {% endif %}
>
> If you put this html in your base html (or some html that gets
> rendered for every page), then you can just create notifications in
> your view.py and they will always get displayed in the next page the
> user gets sent to.
>
> To make this work you need (in settings.py):
> MIDDLEWARE_CLASSES = (
>     'notifications.middleware.NotificationMiddleware',
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>     "notifications.context_processors.notifications",
>
> I believe I downloaded this from:http://code.google.com/p/django-notification/
>
> Margie

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



Leopard deploy directory?

2009-04-13 Thread Shannon

Hi -- I am working on a django-powered site on Leopard server.  Where
is the recommended/conventional deployment directory?  Every example I
see uses a particular user's home directory, but that does not seem
appropriate for a production-level site.  I'm fairly new to the
Leopard environment and am curious what people typically use for their
production deployment directory.

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



Re: Fwd: Default ManyToMany ordering

2009-04-13 Thread Andy Lei

hmm, i think that governs how, for example, Persons are ordered in the
Person's admin list.

what I wanted to do was change the ordering of Persons that show up in
the ManyToMany field in the Group admin page.

also, is there any general way to affect the default ordering of
related items on ManyToMany or ForeignKey relations?


On Apr 12, 8:40 pm, "R. Gorman"  wrote:
> If it's for the admin interface the admin option ordering (http://
> docs.djangoproject.com/en/dev/ref/contrib/admin/#ordering) might do
> the trick.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple sites, single application in Django

2009-04-13 Thread Daniel C

Russell,
I am working through something similar and I think that the basic
structure would be to have project folders for each site plus a folder
for your shared applications (whose models use the 'Site' object and
'CurrentSiteManager'. Something like this:
/home/django/sharedapps/
/home/django/sharedapps/profiles
/home/django/sharedapps/accounts
/home/django/sharedapps/notification
/home/django/sharedapps/photos
/home/django/sharedapps/videos
/home/django/website1/
/home/django/website1/
/home/django/website1/settings.py
/home/django/website2/
/home/django/website2/apps
/home/django/website2/apps/uniquewebsite2app
/home/django/website2/settings.py
/home/django/multisite.db

Assuming your working django directory is '/home/django', you create a
directory named sharedapps and place the apps you want to work across
your sites there. So if you had applications like 'profiles',
'accounts', 'photos', etc. that both websites would use, place the
apps in a 'sharedapps' folder. You would need to make sure the
'sharedapp's folder was added to the environment path for each project
'website1' and 'website2'. The Pinax project basically does this by
modifying 'manage.py' and adding lines like 'sys.path.insert(0, join
(settings.PINAX_ROOT, "apps"))'. I'm thinking something like a '/home/
django/sharedsitesettings.py' might be a place to put this. And of
course you will also need to make sure the database is shared, so
perhaps you'd add database settings into that 'sharedsitesettings.py'
file. For a SQLite3 database, that could be the '/home/django/
multisite.db'

Looking at the Pinax project code has reminded me that Django is first
and foremost python, so I stopped thinking about django projects as
the base container for django...er, projects. I think what Django
calls a 'project' is a convenience for us to get started, but for
complex development, we need to remember that what Django creates is
just a directory with files in it.

Anyway, that is my take currently. Perhaps someone more knowledgeable
will come around and reveal a better way.

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



Re: TreePanel in Django

2009-04-13 Thread Joshua Partogi

Yes you can use ext-js with django for this.

On Apr 14, 6:23 am, Eduardo Aragón Montes  wrote:
> Hi everyone..I'm new in django and I'm developing and app that have virtual
> storage for users...so i would like to do a treepanel for every user where
> they can see what files they have uploaded and if they want create folders
> and organize their files...I know i can use ext-js but i would like to know
> if anyone of you know other way to perform this...Thanks
>
> --
> Eduardo Aragón Montes
> Cel. 3113072880
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Process multiple html forms in the same view

2009-04-13 Thread Karen Tracey
On Mon, Apr 13, 2009 at 2:11 PM, Bastien  wrote:

> ... So my question is how could the
> view know which POST data belongs to which form or how can I change
> the form fields name like the profile tags and post tags would become
> tags_profile and tags_post respectively?


I think you want to specify a prefix for your individual forms:

http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms

Karen

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



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

ok I'll try it,

thanks
drakkan1000

On 13 Apr, 22:39, Alex Gaynor  wrote:
> On Mon, Apr 13, 2009 at 4:37 PM, drakkan  wrote:
>
> > I'm using ugettext, I have to use the lazy variant?
>
> > On 13 Apr, 21:53, Ramiro Morales  wrote:
> > > On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
>
> > > > I found a workaround I have to do:
>
> > > > 'status':_(u.get_status_display())
>
> > > > even if I have already marked the string for translation in models:
>
> > > > STATUS=(
> > > >    (1,_('Active')),
> > > >    (0,_('Inactive')),
> > > > )
>
> > > > this is a really strange behaviour ...
>
> > > To which one of the *gettext* function(s) are the _ alias
> > > defined in both models.py and views.py?
>
> > > --
> > > Ramiro Moraleshttp://rmorales.net
>
> Yes, for any module level strings you need to use the lazy variant.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form Wizard and captcha

2009-04-13 Thread qrilka

Thanks, will do that tomorrow.

Kirill.

On 14 апр, 00:14, Adi Sieker  wrote:
> On 13.04.2009, at 21:43, Kirill Zaborski wrote:
>
> > So no answers were given and I tried to fix FormWizard class.
> > The patch is attached and the only thing changed is that the  
> > revalidation is made with forms which  were before the last one (I  
> > do not see any reason for the second validation of it).
> > Is there any chance to get it into the trunk?
> > Do I need to make any additional steps for this to happen?
>
> open a ticket on code.djangoproject.com/simpleticket attach the patch  
> and see what the devs think of it.
>
> adi
>
>
>
> > Kirill.
>
> > On 8 апр, 22:29, qrilka  wrote:
> > > I've stumbled upon from revalidation in form wizard. The similar
> > > problem was discussed a year ago 
> > > -http://groups.google.com/group/django-users/browse_thread/thread/a6fd
> > ...
> > > I have somewhat different problem: on the last of my forms I use
> > > captcha field, but after successful validation the test string for  
> > it
> > > gets erased (either in cache in supercaptcha or in DB in django-
> > simple-
> > > captcha) and its quite normal from my point of view. But form wizard
> > > does form revalidation at the end so I get validation error.
> > > The only solution I see now (except from not using from wizard) is  
> > to
> > > hack captcha field and not to delete test string after success.But
> > > this option lokks somewhat nasty to me.
> > > Maybe there are some other ways around?
>
> > > Best regards,Kirill.
>
> > Index: django/contrib/formtools/wizard.py
> > ===
> > --- django/contrib/formtools/wizard.py     (revision 9975)
> > +++ django/contrib/formtools/wizard.py     (working copy)
> > @@ -76,19 +76,19 @@
> >             self.process_step(request, form, current_step)
> >             next_step = current_step + 1
>
> > -            # If this was the last step, validate all of the forms  
> > one more
> > +            # If this was the last step, validate all of the  
> > previous forms one more
> >             # time, as a sanity check, and call done().
> >             num = self.num_steps()
> >             if next_step == num:
> > -                final_form_list = [self.get_form(i, request.POST)  
> > for i in range(num)]
> > +                prior_form_list = [self.get_form(i, request.POST)  
> > for i in range(num - 1)]
>
> >                 # Validate all the forms. If any of them fail  
> > validation, that
> >                 # must mean the validator relied on some other  
> > input, such as
> >                 # an external Web site.
> > -                for i, f in enumerate(final_form_list):
> > +                for i, f in enumerate(prior_form_list):
> >                     if not f.is_valid():
> >                         return  
> > self.render_revalidation_failure(request, i, f)
> > -                return self.done(request, final_form_list)
> > +                return self.done(request, prior_form_list+[form])
>
> >             # Otherwise, move along to the next step.
> >             else:
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and i18n what's wrong???

2009-04-13 Thread Alex Gaynor
On Mon, Apr 13, 2009 at 4:37 PM, drakkan  wrote:

>
> I'm using ugettext, I have to use the lazy variant?
>
> On 13 Apr, 21:53, Ramiro Morales  wrote:
> > On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
> >
> > > I found a workaround I have to do:
> >
> > > 'status':_(u.get_status_display())
> >
> > > even if I have already marked the string for translation in models:
> >
> > > STATUS=(
> > >(1,_('Active')),
> > >(0,_('Inactive')),
> > > )
> >
> > > this is a really strange behaviour ...
> >
> > To which one of the *gettext* function(s) are the _ alias
> > defined in both models.py and views.py?
> >
> > --
> > Ramiro Moraleshttp://rmorales.net
> >
>
Yes, for any module level strings you need to use the lazy variant.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Custom Model Fields / Multi-table inheritance / get_db_prep_value / postgresql_psycopg2

2009-04-13 Thread Daniel Roseman

On Apr 13, 7:25 pm, gordyt  wrote:
> Howdy Folks,
>
> I have been testing model inheritance using models that have UUIDField
> primary keys.  It appears that when you save a new instance of a child
> model, the framework is not calling get_db_prep_value() to convert the
> UUIDField to a proper format before querying the parent entry.
>
> Let's say we have two very simple models:
>
> class Person(models.Model):
>     id = UUIDField(primary_key=True)
>     name = models.CharField(max_length=32)
>
> class Child(Person):
>     grade = models.SmallIntegerField()
>
> If you do this...
>
> c = Child(name="Mary", grade=5)
> c.save()
>
> ...the framework will first create the myapp_person entry.  Then it
> does a query like this:
>
> SELECT (1) AS "a" FROM "myapp_child" WHERE
> "myapp_child"."person_ptr_id" = %s
>
> I put some print statement in all of the methods in UUIDField, and
> none of them are being called before that statement is executed,
> including: get_db_prep_lookup, get_db_prep_value, get_db_prep_save,
> pre_save
>
> The result is  an error from the database:
>
> : can't adapt
>
> Interesting note... the psycopg driver doesn't generate an error.
> Even though it is an older driver, apparently is is less picky about
> the parameters.  Psycopg will accept a uuid object in the statement
> that fails and apperently psycopg2 wants it cast to a string.
>
> If anyone has an idea I would love to hear it.
>
> By the way, I'm using a modified version of the UUIDField from the
> django-extensions project.  This is one that uses a native uuid field
> for the database when the backend supports it (postgresql) and a
> charfield when the backend doesn't support it (others).  I did some
> tests and performance with postgresql is better with the native type
> (not suprising).
>
> --gordon

I suspect you have not set the subclass's metaclass to
models.SubfieldBase - see here:
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#the-subfieldbase-metaclass

You need to do this to get any of the overridden methods to be called.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

I'm using ugettext, I have to use the lazy variant?

On 13 Apr, 21:53, Ramiro Morales  wrote:
> On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
>
> > I found a workaround I have to do:
>
> > 'status':_(u.get_status_display())
>
> > even if I have already marked the string for translation in models:
>
> > STATUS=(
> >    (1,_('Active')),
> >    (0,_('Inactive')),
> > )
>
> > this is a really strange behaviour ...
>
> To which one of the *gettext* function(s) are the _ alias
> defined in both models.py and views.py?
>
> --
> Ramiro Moraleshttp://rmorales.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Registration form and Profile form is not saving

2009-04-13 Thread Daniel Roseman

On Apr 13, 5:57 am, Praveen  wrote:
> How the current user logging-in first while registration.. you mean to
> say after successfully registration the user must login automatically.

Well, you haven't explained the user flow at all here. But I assume
that it's the RegistrationForm that's doing the registering, and you
get the new user from that in the line
contact = form.save(request)
So, 'contact' is the object containing your newly registered user. So
surely you should use that as the user value in the profile object.
--
DR.

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



TreePanel in Django

2009-04-13 Thread Eduardo Aragón Montes
Hi everyone..I'm new in django and I'm developing and app that have virtual
storage for users...so i would like to do a treepanel for every user where
they can see what files they have uploaded and if they want create folders
and organize their files...I know i can use ext-js but i would like to know
if anyone of you know other way to perform this...Thanks

-- 
Eduardo Aragón Montes
Cel. 3113072880

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



Re: Form Wizard and captcha

2009-04-13 Thread Adi Sieker

On 13.04.2009, at 21:43, Kirill Zaborski wrote:

> So no answers were given and I tried to fix FormWizard class.
> The patch is attached and the only thing changed is that the  
> revalidation is made with forms which  were before the last one (I  
> do not see any reason for the second validation of it).
> Is there any chance to get it into the trunk?
> Do I need to make any additional steps for this to happen?

open a ticket on code.djangoproject.com/simpleticket attach the patch  
and see what the devs think of it.

adi

>
> Kirill.
>
> On 8 апр, 22:29, qrilka  wrote:
> > I've stumbled upon from revalidation in form wizard. The similar
> > problem was discussed a year ago 
> > -http://groups.google.com/group/django-users/browse_thread/thread/a6fd 
> ...
> > I have somewhat different problem: on the last of my forms I use
> > captcha field, but after successful validation the test string for  
> it
> > gets erased (either in cache in supercaptcha or in DB in django- 
> simple-
> > captcha) and its quite normal from my point of view. But form wizard
> > does form revalidation at the end so I get validation error.
> > The only solution I see now (except from not using from wizard) is  
> to
> > hack captcha field and not to delete test string after success.But
> > this option lokks somewhat nasty to me.
> > Maybe there are some other ways around?
> >
> > Best regards,Kirill.
>
> >
> Index: django/contrib/formtools/wizard.py
> ===
> --- django/contrib/formtools/wizard.py(revision 9975)
> +++ django/contrib/formtools/wizard.py(working copy)
> @@ -76,19 +76,19 @@
> self.process_step(request, form, current_step)
> next_step = current_step + 1
>
> -# If this was the last step, validate all of the forms  
> one more
> +# If this was the last step, validate all of the  
> previous forms one more
> # time, as a sanity check, and call done().
> num = self.num_steps()
> if next_step == num:
> -final_form_list = [self.get_form(i, request.POST)  
> for i in range(num)]
> +prior_form_list = [self.get_form(i, request.POST)  
> for i in range(num - 1)]
>
> # Validate all the forms. If any of them fail  
> validation, that
> # must mean the validator relied on some other  
> input, such as
> # an external Web site.
> -for i, f in enumerate(final_form_list):
> +for i, f in enumerate(prior_form_list):
> if not f.is_valid():
> return  
> self.render_revalidation_failure(request, i, f)
> -return self.done(request, final_form_list)
> +return self.done(request, prior_form_list+[form])
>
> # Otherwise, move along to the next step.
> else:


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



Re: django and i18n what's wrong???

2009-04-13 Thread Ramiro Morales

On Mon, Apr 13, 2009 at 4:30 PM, drakkan  wrote:
>
> I found a workaround I have to do:
>
> 'status':_(u.get_status_display())
>
> even if I have already marked the string for translation in models:
>
> STATUS=(
>    (1,_('Active')),
>    (0,_('Inactive')),
> )
>
> this is a really strange behaviour ...
>

To which one of the *gettext* function(s) are the _ alias
defined in both models.py and views.py?

-- 
Ramiro Morales
http://rmorales.net

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



Re: django and i18n what's wrong???

2009-04-13 Thread Alex Gaynor
On Mon, Apr 13, 2009 at 3:07 PM, drakkan  wrote:

>
> The string that doesn't works are defined in models.py:
>
> STATUS=(
>(1,_('Active')),
>(0,_('Inactive')),
> )
>
> class TestModel(models.Model):
>status=models.IntegerField("Status",choices=STATUS,default=1)
>
> in my view I have:
>
> 'status':u.get_status_display()
>
> ant this is not transalted, why?
>
> On 13 Apr, 19:11, drakkan  wrote:
> > Hi, I'm trying to use i18n with django. I followed the docs and
> > created my transalations for english,italian and spanish
> >
> > in settings I have:
> >
> > ugettext = lambda s: s
> >
> > LANGUAGES = (
> > ('en', ugettext('English')),
> > ('it', ugettext('Italian')),
> > ('es', ugettext('Spanish')),
> > )
> >
> > and I installed the locale middleware
> >
> > MIDDLEWARE_CLASSES = (
> > 'django.contrib.csrf.middleware.CsrfMiddleware',
> > 'django.contrib.sessions.middleware.SessionMiddleware',
> > 'django.middleware.common.CommonMiddleware',
> > 'django.contrib.auth.middleware.AuthenticationMiddleware',
> > 'django.middleware.locale.LocaleMiddleware',
> > 'django.middleware.doc.XViewMiddleware',
> > )
> >
> > If I change the settings:
> >
> > LANGUAGE_CODE
> >
> > all is fine both javascript and coded string are correctly transalted.
> >
> > If I comment LANGUAGE_CODE settings and change the browser language
> > preference only javascript is correctly translated. I have the same
> > issue if I change
> >
> > request.LANGUAGE_CODE
> >
> > or
> >
> > request.session[settings.LANGUAGE_COOKIE_NAME]
> >
> > so the problem seems related to locale middleware.
> >
> > Someone with the same issue? Is this a django bug or a my
> > misconfiguration?
> >
> > thanks
> > drakkan1000
> >
>
Are you using ugettext or ugettext_lazy?  You need to be using the lazy
variant there.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Form Wizard and captcha

2009-04-13 Thread Kirill Zaborski
So no answers were given and I tried to fix FormWizard class.
The patch is attached and the only thing changed is that the revalidation is
made with forms which  were before the last one (I do not see any reason for
the second validation of it).
Is there any chance to get it into the trunk?
Do I need to make any additional steps for this to happen?

Kirill.

On 8 апр, 22:29, qrilka  wrote:
> I've stumbled upon from revalidation in form wizard. The similar
> problem was discussed a year ago -
http://groups.google.com/group/django-users/browse_thread/thread/a6fd...
> I have somewhat different problem: on the last of my forms I use
> captcha field, but after successful validation the test string for it
> gets erased (either in cache in supercaptcha or in DB in django-simple-
> captcha) and its quite normal from my point of view. But form wizard
> does form revalidation at the end so I get validation error.
> The only solution I see now (except from not using from wizard) is to
> hack captcha field and not to delete test string after success.But
> this option lokks somewhat nasty to me.
> Maybe there are some other ways around?
>
> Best regards,Kirill.

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

Index: django/contrib/formtools/wizard.py
===
--- django/contrib/formtools/wizard.py	(revision 9975)
+++ django/contrib/formtools/wizard.py	(working copy)
@@ -76,19 +76,19 @@
 self.process_step(request, form, current_step)
 next_step = current_step + 1
 
-# If this was the last step, validate all of the forms one more
+# If this was the last step, validate all of the previous forms one more
 # time, as a sanity check, and call done().
 num = self.num_steps()
 if next_step == num:
-final_form_list = [self.get_form(i, request.POST) for i in range(num)]
+prior_form_list = [self.get_form(i, request.POST) for i in range(num - 1)]
 
 # Validate all the forms. If any of them fail validation, that
 # must mean the validator relied on some other input, such as
 # an external Web site.
-for i, f in enumerate(final_form_list):
+for i, f in enumerate(prior_form_list):
 if not f.is_valid():
 return self.render_revalidation_failure(request, i, f)
-return self.done(request, final_form_list)
+return self.done(request, prior_form_list+[form])
 
 # Otherwise, move along to the next step.
 else:


Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

I found a workaround I have to do:

'status':_(u.get_status_display())

even if I have already marked the string for translation in models:

STATUS=(
(1,_('Active')),
(0,_('Inactive')),
)

this is a really strange behaviour ...

On 13 Apr, 21:07, drakkan  wrote:
> The string that doesn't works are defined in models.py:
>
> STATUS=(
>     (1,_('Active')),
>     (0,_('Inactive')),
> )
>
> class TestModel(models.Model):
>     status=models.IntegerField("Status",choices=STATUS,default=1)
>
> in my view I have:
>
> 'status':u.get_status_display()
>
> ant this is not transalted, why?
>
> On 13 Apr, 19:11, drakkan  wrote:
>
> > Hi, I'm trying to use i18n with django. I followed the docs and
> > created my transalations for english,italian and spanish
>
> > in settings I have:
>
> > ugettext = lambda s: s
>
> > LANGUAGES = (
> >     ('en', ugettext('English')),
> >     ('it', ugettext('Italian')),
> >     ('es', ugettext('Spanish')),
> > )
>
> > and I installed the locale middleware
>
> > MIDDLEWARE_CLASSES = (
> >     'django.contrib.csrf.middleware.CsrfMiddleware',
> >     'django.contrib.sessions.middleware.SessionMiddleware',
> >     'django.middleware.common.CommonMiddleware',
> >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> >     'django.middleware.locale.LocaleMiddleware',
> >     'django.middleware.doc.XViewMiddleware',
> > )
>
> > If I change the settings:
>
> > LANGUAGE_CODE
>
> > all is fine both javascript and coded string are correctly transalted.
>
> > If I comment LANGUAGE_CODE settings and change the browser language
> > preference only javascript is correctly translated. I have the same
> > issue if I change
>
> > request.LANGUAGE_CODE
>
> > or
>
> > request.session[settings.LANGUAGE_COOKIE_NAME]
>
> > so the problem seems related to locale middleware.
>
> > Someone with the same issue? Is this a django bug or a my
> > misconfiguration?
>
> > thanks
> > drakkan1000
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form validation in Admin Panel

2009-04-13 Thread eli

On 13 Kwi, 21:10, Alex Gaynor  wrote:
> Provide a custom form to the ModelAdmin using the form 
> option:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form
>
> Alex
>

Oh, it's so simple.. :-)

Thank You Alex

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



Re: django and i18n what's wrong???

2009-04-13 Thread drakkan

The string that doesn't works are defined in models.py:

STATUS=(
(1,_('Active')),
(0,_('Inactive')),
)

class TestModel(models.Model):
status=models.IntegerField("Status",choices=STATUS,default=1)

in my view I have:

'status':u.get_status_display()

ant this is not transalted, why?

On 13 Apr, 19:11, drakkan  wrote:
> Hi, I'm trying to use i18n with django. I followed the docs and
> created my transalations for english,italian and spanish
>
> in settings I have:
>
> ugettext = lambda s: s
>
> LANGUAGES = (
>     ('en', ugettext('English')),
>     ('it', ugettext('Italian')),
>     ('es', ugettext('Spanish')),
> )
>
> and I installed the locale middleware
>
> MIDDLEWARE_CLASSES = (
>     'django.contrib.csrf.middleware.CsrfMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'django.middleware.locale.LocaleMiddleware',
>     'django.middleware.doc.XViewMiddleware',
> )
>
> If I change the settings:
>
> LANGUAGE_CODE
>
> all is fine both javascript and coded string are correctly transalted.
>
> If I comment LANGUAGE_CODE settings and change the browser language
> preference only javascript is correctly translated. I have the same
> issue if I change
>
> request.LANGUAGE_CODE
>
> or
>
> request.session[settings.LANGUAGE_COOKIE_NAME]
>
> so the problem seems related to locale middleware.
>
> Someone with the same issue? Is this a django bug or a my
> misconfiguration?
>
> thanks
> drakkan1000
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form validation in Admin Panel

2009-04-13 Thread Alex Gaynor
On Mon, Apr 13, 2009 at 2:52 PM, eli  wrote:

>
> Hi,
>
> How can I to validate data from form in Django Admin Panel? (like:
> clena_fieldname in form.ModelForm) ?
>
> regards.
> >
>
Provide a custom form to the ModelAdmin using the form option:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: How do List, Tuple or Dictionarie mapping (ORM)

2009-04-13 Thread Alex Gaynor
On Mon, Apr 13, 2009 at 12:53 PM, khomutets...@gmail.com <
khomutets...@gmail.com> wrote:

>
> Hi!
>
> I want to map some compex objects, like lists or dictionaries, but in
> Django I don't find Field type for this. Please help me or say how to
> map this data structures. (I'll try to use Hibernate ORM and he have
> List, Map and Set mapping types).
>
> Mikhail Khomutetskiy.
>
> >
>
Django doesn't have any of these Field types built in as they are not,
strictly speaking, relational database ideas.  However, you are more than
welcome to create your own field types(or check a site like Djangosnippets
for already existing ones).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Form validation in Admin Panel

2009-04-13 Thread eli

Hi,

How can I to validate data from form in Django Admin Panel? (like:
clena_fieldname in form.ModelForm) ?

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



Re: newbie question: django-registration

2009-04-13 Thread Angel Cruz
Also,
I had to go use the admin interface, go to Sites and change the 'site name'
from 'example.com' to mine.  A little required edit that I missed.

On Sun, Apr 12, 2009 at 10:00 PM, Praveen wrote:

>
> You should change the site domain name example.com to 127.0.0.1:8000
> check in your django-site table..
> http://www.example.com/accounts/activate/
> 637cd08106eea9b1139efd34a0fa79a5d7f90494/
>  for instance
> http://127.0.0.1:8000/accounts/activate/
> 637cd08106eea9b1139efd34a0fa79a5d7f90494/
>
> On Apr 13, 12:55 am, Angel Cruz  wrote:
> > Eh,
> > Never mind.  Something is wrong with my root url (fixing the link from
> the
> > email activated the account).
> >
> > I will fix it.
> >
> > On Sun, Apr 12, 2009 at 12:21 PM, MrBodjangles  >wrote:
> >
> > > Hi Folks and Happy Easter!
> >
> > > OK, making slow but sure progress on learning Django.
> >
> > > I am using django-registration, have provided the simple templates
> > > required, and am to the point that a user can register (their usename,
> > > password, etc. get populated in the auth_user table of the PostgreSQL
> > > databae I am using), and receives an email.
> >
> > > I am stuck on the activation.
> >
> > > When I check my email and click on the link, I receive the following:
> > > "The requested URL /accounts/activate/
> > > 637cd08106eea9b1139efd34a0fa79a5d7f90494/ was not found on this
> > > server"
> >
> > > I had assumed that the /accounts/activate/ folder
> > > would have been automatically generated?
> >
> > > I added this line to my URLConf, thinking this was the reason:
> > >(r'^accounts/activate//
> > > $','registration.views.activate'),
> >
> > > What step am I missing?
> >
> > > Advanced 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Cannot call a custom model method in my view

2009-04-13 Thread Daniel Roseman

On Apr 11, 11:10 pm, codecowboy  wrote:
> Thank you Daniel.  I got it working.  That link that you gave me
> helped me to figure it out.  I'm curious though, is there ever a
> reason in Django to define a method in a model class or would I always
> use a custom manager method?

It's frequently useful to define normal (instance) methods within
models, which operate on a single instance - eg to provide a formatted
or calculated version of one or more of the model fields for use in a
template, or to override the save method with some custom validation,
etc.

Whether or not you use class methods within a model is up to you - I
have used them as a useful place to define signals on a particular
model class, but you certainly don't need them for that.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom Model Fields / Multi-table inheritance / get_db_prep_value / postgresql_psycopg2

2009-04-13 Thread gordyt

Forgot to add that I'm using the latest revision from subversion
(10558)...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom Model Fields / Multi-table inheritance / get_db_prep_value / postgresql_psycopg2

2009-04-13 Thread gordyt

Howdy Folks,

I have been testing model inheritance using models that have UUIDField
primary keys.  It appears that when you save a new instance of a child
model, the framework is not calling get_db_prep_value() to convert the
UUIDField to a proper format before querying the parent entry.

Let's say we have two very simple models:

class Person(models.Model):
id = UUIDField(primary_key=True)
name = models.CharField(max_length=32)

class Child(Person):
grade = models.SmallIntegerField()

If you do this...

c = Child(name="Mary", grade=5)
c.save()

...the framework will first create the myapp_person entry.  Then it
does a query like this:

SELECT (1) AS "a" FROM "myapp_child" WHERE
"myapp_child"."person_ptr_id" = %s

I put some print statement in all of the methods in UUIDField, and
none of them are being called before that statement is executed,
including: get_db_prep_lookup, get_db_prep_value, get_db_prep_save,
pre_save

The result is  an error from the database:

: can't adapt

Interesting note... the psycopg driver doesn't generate an error.
Even though it is an older driver, apparently is is less picky about
the parameters.  Psycopg will accept a uuid object in the statement
that fails and apperently psycopg2 wants it cast to a string.

If anyone has an idea I would love to hear it.

By the way, I'm using a modified version of the UUIDField from the
django-extensions project.  This is one that uses a native uuid field
for the database when the backend supports it (postgresql) and a
charfield when the backend doesn't support it (others).  I did some
tests and performance with postgresql is better with the native type
(not suprising).

--gordon


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



Editing Submit line Template in Admin

2009-04-13 Thread Alfonso

Hi,

I know it's not possible to easily override the submit_line.html
template on model/app by model/app basis but I'm wondering if anyone
has discovered a workaround for adding custom submit_line
functionality?

Basically within one app I'd like to hide everything but 'Delete' and
'Save'.  At the moment I've implemented this sitewide.

On another app I'd like to adjust the wording a little from 'Save and
continue Editing' to 'Update'.  My client doesn't get the
functionality of these buttons and thinking a little semantic change
might help!

I notice references to show_save_and_add_another in the template
itself, are these controllable through the app's admin.py?

Thanks

A


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



Process multiple html forms in the same view

2009-04-13 Thread Bastien

I have a classic user profile page where the user fills a form with
various field about her profile (name, address, about me...). On the
same page I have another form that is very similar to a blog post
entry (title, body...) that represents a message that the user can
optionaly fill if she wants to. I can only have one submit button for
the whole page and thus the 2 forms. They both submit the POST data to
the same URL (user_ profile) and in the view I process both forms.
Everything runs quite smoothly since the validation process
automatically uses the POST data that it needs and leaves the rest
(ie: validating user profile only uses the form values like name,
address, about me... and leaves things like title, body... for later
use). But my problem is that I have a few form fields in common in
both forms: zone (which is a list of geographical zones relevant to
the website), theme (another list) and the tags field. The view in its
current form is unabled to tell apart which one is from which form,
ie: it receives tags from both the user profile and the user optional
message and can't tell them apart. So my question is how could the
view know which POST data belongs to which form or how can I change
the form fields name like the profile tags and post tags would become
tags_profile and tags_post respectively?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django full-history?

2009-04-13 Thread Mohammad Tayseer
This can be helpful
http://code.djangoproject.com/wiki/AuditTrail

 Mohammad Tayseer
http://spellcoder.com/blogs/tayseer






From: Brazilian Joe 
To: Django users 
Sent: Monday, April 13, 2009 6:48:13 PM
Subject: Django full-history?


Dear all,

I have been working on a system where we need full-history for our
data. We need features like a 'live time machine', to be able to look
at information as it was at a certain point of time in the past, in
real time (including seeing deleted items). For that, we currently use
a compound primary key (id + timestamp). This way, there are no
updates or deletes, only inserts. a 'deletion' works by inserting
another version of the object with a 'deleted' status.

I would like to have some insight of the djago users and developers,
if django already has similar features, or if would have to be created
from scratch.

I have been toiling on a system using stored procedures to distribute
the data on several tables. PostgreSQL currently does not have full
support for table partitioning, so custom procedures must be in place
for the system to work. I am thinking about a simple partitioning
system based on number of IDs, but frequently updated objects would
cause certain tables to bloat.

It seems to me (python+django n00b) that django provides a very nice
way to speed up putting stuff online, but (assuming django does not
already provide this functionality) I don't know how easy it would be
to integrate django with a database system like that (if at all) , or
to start over using django's models. Any insight is very much
appreciated!

Best regards



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



Re: serving static files

2009-04-13 Thread amit sethi
hi thanks ,
well got the point about url-conf the url pattern you have given does not
raise the error but i have still not been able to get my css working
my urls.py has an entry
(r'^sitemedia/?P.*$', 'django.views.static.serve',
{'document_root': '/home/amit/analytics/sitemedia', 'show_indexes':
True })

my css file is at path '/home/amit/analytics/sitemedia/default.css'

my template has the link to css


>
> i know this might be very basic but i have just started to try my hand at
> this .
>



-- 
A-M-I-T S|S

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



Re: Trouble with DateField

2009-04-13 Thread Brandon Taylor

Well, I'm not sure what the matter was, maybe some bad cache or
something, but the problem seems to have corrected itself. Weird!

On Apr 13, 12:06 pm, Brian Neal  wrote:
> On Apr 13, 11:47 am, Brandon Taylor  wrote:
>
>
>
> > Hi everyone,
>
> > I need a sanity check here. I'm using a jQueryUI DatePicker, with the
> > dateFormat option set to 'yy-mm-dd', which is returning a date in -
> > MM-DD format, if I check my request.POST values.
>
> > I have a DateField - "effective_from", on my model, and am using a
> > corresponding ModelForm. When I check the form.cleaned_data
> > ['effective_from'], I get a Python datetime object as: 2009-04-13.
>
> > However, I'm getting an exception error for the view, saying:
> > ValidationError at /codes/create/
> > Enter a valid date in -MM-DD format.
>
> > I have also parsed the date by hand:
> > , MM, DD = map(int, request.POST['effective_from'].split('-'))
> > effective_from = datetime.date(, MM, DD)
>
> > The portion of the view in question is:
> > form = ActivityCodeForm(request.POST)
> >         if form.is_valid():
> >             activity_code = form.save(commit=False)
> >             activity_code.created_by = request.user
> >             activity_code.category = Category.objects.get(pk=int
> > (form.cleaned_data['kategory']))
> >             activity_code.effective_from = form.cleaned_data
> > ['effective_from']
> >             activity_code.slug = slugify(form.cleaned_data['title'])
> >             activity_code.save()
>
> > Can anyone see what I'm doing wrong here?
>
> Here:
>
> activity_code.effective_from = form.cleaned_data['effective_from']
>
> You are assigning a string to what I assume is a models.DateTimeField
> or DateField. I don't think that works. You need to turn the string
> into a Python datetime object first. I think this is done
> automatically for you if you were using a ModelForm.
>
> Best,
> BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django full-history?

2009-04-13 Thread Bruno Tikami
On Mon, Apr 13, 2009 at 1:48 PM, Brazilian Joe wrote:

>
> Dear all,
>
> I have been working on a system where we need full-history for our
> data. We need features like a 'live time machine', to be able to look
> at information as it was at a certain point of time in the past, in
> real time (including seeing deleted items). For that, we currently use
> a compound primary key (id + timestamp). This way, there are no
> updates or deletes, only inserts. a 'deletion' works by inserting
> another version of the object with a 'deleted' status.
>
> I would like to have some insight of the djago users and developers,
> if django already has similar features, or if would have to be created
> from scratch.
>
> I have been toiling on a system using stored procedures to distribute
> the data on several tables. PostgreSQL currently does not have full
> support for table partitioning, so custom procedures must be in place
> for the system to work. I am thinking about a simple partitioning
> system based on number of IDs, but frequently updated objects would
> cause certain tables to bloat.
>
> It seems to me (python+django n00b) that django provides a very nice
> way to speed up putting stuff online, but (assuming django does not
> already provide this functionality) I don't know how easy it would be
> to integrate django with a database system like that (if at all) , or
> to start over using django's models. Any insight is very much
> appreciated!
>
> Best regards
>

Hi Brazilian Joe, Brazilian Bruno speaking ;-)

did you look at Audit Trail [1] ? I know it does not do everything you need
but it could give you some good ideas on how to develop your app.
Unfortunately, I cannot help you with the other features you need.


[1] http://code.djangoproject.com/wiki/AuditTrail

Regards,

Tkm

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



Re: Trouble with DateField

2009-04-13 Thread Brandon Taylor

Hi Brian,

Yes, I've also made certain that the value returned for effective date
from form.cleaned_data['effective_date'] is a valid Python datetime
object.

Something seems to be amiss. The exception is happening in: django/db/
models/fields/__init__.py in to_python, line 473

If I put a print statement in there to print the 'value' variable
handed to the 'to_python' function, it doesn't return None or the
value, in fact it prints an empty line, which is making me think it's
an empty string...?

b



On Apr 13, 12:06 pm, Brian Neal  wrote:
> On Apr 13, 11:47 am, Brandon Taylor  wrote:
>
>
>
> > Hi everyone,
>
> > I need a sanity check here. I'm using a jQueryUI DatePicker, with the
> > dateFormat option set to 'yy-mm-dd', which is returning a date in -
> > MM-DD format, if I check my request.POST values.
>
> > I have a DateField - "effective_from", on my model, and am using a
> > corresponding ModelForm. When I check the form.cleaned_data
> > ['effective_from'], I get a Python datetime object as: 2009-04-13.
>
> > However, I'm getting an exception error for the view, saying:
> > ValidationError at /codes/create/
> > Enter a valid date in -MM-DD format.
>
> > I have also parsed the date by hand:
> > , MM, DD = map(int, request.POST['effective_from'].split('-'))
> > effective_from = datetime.date(, MM, DD)
>
> > The portion of the view in question is:
> > form = ActivityCodeForm(request.POST)
> >         if form.is_valid():
> >             activity_code = form.save(commit=False)
> >             activity_code.created_by = request.user
> >             activity_code.category = Category.objects.get(pk=int
> > (form.cleaned_data['kategory']))
> >             activity_code.effective_from = form.cleaned_data
> > ['effective_from']
> >             activity_code.slug = slugify(form.cleaned_data['title'])
> >             activity_code.save()
>
> > Can anyone see what I'm doing wrong here?
>
> Here:
>
> activity_code.effective_from = form.cleaned_data['effective_from']
>
> You are assigning a string to what I assume is a models.DateTimeField
> or DateField. I don't think that works. You need to turn the string
> into a Python datetime object first. I think this is done
> automatically for you if you were using a ModelForm.
>
> Best,
> BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django and i18n what's wrong???

2009-04-13 Thread drakkan

Hi, I'm trying to use i18n with django. I followed the docs and
created my transalations for english,italian and spanish

in settings I have:

ugettext = lambda s: s

LANGUAGES = (
('en', ugettext('English')),
('it', ugettext('Italian')),
('es', ugettext('Spanish')),
)

and I installed the locale middleware

MIDDLEWARE_CLASSES = (
'django.contrib.csrf.middleware.CsrfMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
)

If I change the settings:

LANGUAGE_CODE

all is fine both javascript and coded string are correctly transalted.

If I comment LANGUAGE_CODE settings and change the browser language
preference only javascript is correctly translated. I have the same
issue if I change

request.LANGUAGE_CODE

or

request.session[settings.LANGUAGE_COOKIE_NAME]

so the problem seems related to locale middleware.

Someone with the same issue? Is this a django bug or a my
misconfiguration?

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



Re: Trouble with DateField

2009-04-13 Thread Brian Neal

On Apr 13, 11:47 am, Brandon Taylor  wrote:
> Hi everyone,
>
> I need a sanity check here. I'm using a jQueryUI DatePicker, with the
> dateFormat option set to 'yy-mm-dd', which is returning a date in -
> MM-DD format, if I check my request.POST values.
>
> I have a DateField - "effective_from", on my model, and am using a
> corresponding ModelForm. When I check the form.cleaned_data
> ['effective_from'], I get a Python datetime object as: 2009-04-13.
>
> However, I'm getting an exception error for the view, saying:
> ValidationError at /codes/create/
> Enter a valid date in -MM-DD format.
>
> I have also parsed the date by hand:
> , MM, DD = map(int, request.POST['effective_from'].split('-'))
> effective_from = datetime.date(, MM, DD)
>
> The portion of the view in question is:
> form = ActivityCodeForm(request.POST)
>         if form.is_valid():
>             activity_code = form.save(commit=False)
>             activity_code.created_by = request.user
>             activity_code.category = Category.objects.get(pk=int
> (form.cleaned_data['kategory']))
>             activity_code.effective_from = form.cleaned_data
> ['effective_from']
>             activity_code.slug = slugify(form.cleaned_data['title'])
>             activity_code.save()
>
> Can anyone see what I'm doing wrong here?

Here:

activity_code.effective_from = form.cleaned_data['effective_from']

You are assigning a string to what I assume is a models.DateTimeField
or DateField. I don't think that works. You need to turn the string
into a Python datetime object first. I think this is done
automatically for you if you were using a ModelForm.

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



How do List, Tuple or Dictionarie mapping (ORM)

2009-04-13 Thread khomutets...@gmail.com

Hi!

I want to map some compex objects, like lists or dictionaries, but in
Django I don't find Field type for this. Please help me or say how to
map this data structures. (I'll try to use Hibernate ORM and he have
List, Map and Set mapping types).

Mikhail Khomutetskiy.

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



Django full-history?

2009-04-13 Thread Brazilian Joe

Dear all,

I have been working on a system where we need full-history for our
data. We need features like a 'live time machine', to be able to look
at information as it was at a certain point of time in the past, in
real time (including seeing deleted items). For that, we currently use
a compound primary key (id + timestamp). This way, there are no
updates or deletes, only inserts. a 'deletion' works by inserting
another version of the object with a 'deleted' status.

I would like to have some insight of the djago users and developers,
if django already has similar features, or if would have to be created
from scratch.

I have been toiling on a system using stored procedures to distribute
the data on several tables. PostgreSQL currently does not have full
support for table partitioning, so custom procedures must be in place
for the system to work. I am thinking about a simple partitioning
system based on number of IDs, but frequently updated objects would
cause certain tables to bloat.

It seems to me (python+django n00b) that django provides a very nice
way to speed up putting stuff online, but (assuming django does not
already provide this functionality) I don't know how easy it would be
to integrate django with a database system like that (if at all) , or
to start over using django's models. Any insight is very much
appreciated!

Best regards

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



Trouble with DateField

2009-04-13 Thread Brandon Taylor

Hi everyone,

I need a sanity check here. I'm using a jQueryUI DatePicker, with the
dateFormat option set to 'yy-mm-dd', which is returning a date in -
MM-DD format, if I check my request.POST values.

I have a DateField - "effective_from", on my model, and am using a
corresponding ModelForm. When I check the form.cleaned_data
['effective_from'], I get a Python datetime object as: 2009-04-13.

However, I'm getting an exception error for the view, saying:
ValidationError at /codes/create/
Enter a valid date in -MM-DD format.

I have also parsed the date by hand:
, MM, DD = map(int, request.POST['effective_from'].split('-'))
effective_from = datetime.date(, MM, DD)


The portion of the view in question is:
form = ActivityCodeForm(request.POST)
if form.is_valid():
activity_code = form.save(commit=False)
activity_code.created_by = request.user
activity_code.category = Category.objects.get(pk=int
(form.cleaned_data['kategory']))
activity_code.effective_from = form.cleaned_data
['effective_from']
activity_code.slug = slugify(form.cleaned_data['title'])
activity_code.save()

Can anyone see what I'm doing wrong here?
TIA,
Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



deploy django apps to multiple servers

2009-04-13 Thread ihome

Hi,

Has anyone had the experience to deploy django apps to multiple
servers to increase serving capacity? Is there any references or best
practice documents we could refer to?

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



Re: rendering values from ManyToMany fields

2009-04-13 Thread Adam Fraser

figured it out!

class ModelForm(forms.ModelForm):
'''
Define our own model forms so we can use the form to render a
read-only detail page.
'''
def __init__(self, *args, **kwargs):
readonly = kwargs.get('readonly', False)
if readonly:
del kwargs['readonly']
super(ModelForm, self).__init__(*args, **kwargs)
if readonly:
obj = self.instance
for field_name in self.fields:
if hasattr(obj, 'get_%s_display' % field_name):
display_value = getattr(obj, 'get_%s_display' %
field_name)()
else:
# ---
# for fields that don't have a get_FIELD_display,
try to join the values manually in a  separated list.
try:
display_value = ''.join([unicode(x) for x
in getattr(obj, field_name).get_query_set()])
except:
display_value = None
# --
self.fields[field_name].widget = ReadOnlyWidget(getattr
(obj, field_name, ''), display_value)


On Apr 13, 9:54 am, Adam Fraser  wrote:
> Okay, so I should probably be dealing with the field in my ModelForm
> class (the one that subclasses ModelForm).
>
> This code is where the display values are found before creating the
> ReadOnlyWidget.  In the case of my stains field (a ManyToMany field),
> there isn't a get_stains_display function, so there's no way of
> displaying it nicely (yet).
>
> for field_name in self.fields:
>                 if hasattr(obj, 'get_%s_display' % field_name):
>                     display_value = getattr(obj, 'get_%s_display' %
> field_name)()
>                 else:
>                     # what to do?
>                     display_value = None
>                 self.fields[field_name].widget = ReadOnlyWidget(getattr
> (obj, field_name, ''), display_value)
>
> I assume the get_XXX_display functions are being defined automatically
> for my other fields in the project model (all of which are
> PositiveIntegerFields).  How do I define one to get the display value
> (s) for my stains ManyToManyField which maps to this model?
>
> class Stain(models.Model):
>     def __unicode__(self):
>         return unicode(self.name)
>     name = models.CharField(max_length=40)
>
> On Apr 10, 7:31 pm, Malcolm Tredinnick 
> wrote:
>
> > On Fri, 2009-04-10 at 12:16 -0700, Adam Fraser wrote:
>
> > [...]
>
> > > The problem I'm running into is that the value that comes into render
> > > for the ManyToManyField is a list of the id's for the selected stains
> > > and not the stains themselves.  I assume I should be getting them
> > > somehow through the django.db.models.fields.related.ManyRelatedManager
> > > which is in the original_value, but I haven't been able to figure out
> > > how.
>
> > > Anyone know what I'm missing?
>
> > The Widget subclass should only be processing the data that is going to
> > be displayed on the form. For something like a choice field based on
> > models, this would be, say, the pk value and a string to use for the
> > human-readable portion.
>
> > The django.forms.models.ModelChoiceField is a good example to look at to
> > see what's going on. It uses ModelChoiceIterator.choice() to generate
> > the data that is passed to the widget for rendering and you'll see that
> > it returns (pk, label) pairs.
>
> > So it sounds like things are working as expected. What extra work are
> > you trying to do at the widget level that requires more than what is
> > already passed in (the sequence of (pk, label) values)? Why isn't
> > whatever field you're using generating the right data? It's the Field
> > subclass that you want to be addressing here, not the widget.
>
> > In summary, widgets are objects that know how to take flat data and
> > convert it to HTML. Fields are objects that know how to take more
> > complex Python things (models, arbitrary objects, ...) and convert them
> > to flat data for passing to the widgets.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Send validation error message to the screen

2009-04-13 Thread Margie

Not sure if this is what you are looking for, but I use the
notifications app to add some extra info to my html, to alert the user
that there are errors in the form below or to let them know that there
was no error and the form was submitted successfully.


In view.py:

request.notifications.create('Invalid data in form',
'error') # render form again

In your html:
  {% if notifications %}
  
  {% for notification in notifications %}
  
{{ notification.content }}
  {% endfor %}
  
  {% endif %}

If you put this html in your base html (or some html that gets
rendered for every page), then you can just create notifications in
your view.py and they will always get displayed in the next page the
user gets sent to.

To make this work you need (in settings.py):
MIDDLEWARE_CLASSES = (
'notifications.middleware.NotificationMiddleware',

TEMPLATE_CONTEXT_PROCESSORS = (
"notifications.context_processors.notifications",

I believe I downloaded this from: http://code.google.com/p/django-notification/

Margie


On Apr 12, 6:37 am, Joshua Partogi  wrote:
> Dear all,
>
> I want to send and display validation error message from the view to
> the template, how do I do this in Django? I tried searching on the
> documents but could not find any topics on error message. Could anyone
> give me a hint on how to do this?
>
> Thank you very much
>
> --
> If you can't believe in God the chances are your God is too small.
>
> Read my blog:http://joshuajava.wordpress.com/
> Follow us on twitter:http://twitter.com/scrum8
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Seeking Developer to Continue Project

2009-04-13 Thread Alvin

Hello,

Seeking to add to an existing webapp over the next few weeks, built on
a MySQL database  currently have a multi-part form and hierarchal user
system based on MPTT with several custom reports for stored
submissions and their user relationships.

I'm seeking an individual who has experience writing quality code,
ideally with experience using JQuery in addition to Django. Have a few
new functions that will be going in relating to behavior of a number
of reports and a scheduling system, w/ a csv template for outlook
calendar, a slew of user interface upgrades (though you won't need to
handle this part), among others.

Development will be ongoing for a little while, and I am looking to
have someone get started very quickly.

For more details please send an email to django [at] mitesdesign.com

Thank you,
Alvin

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



Re: Use Python to parse HTML and integrating said script into Django

2009-04-13 Thread Brian Neal

On Apr 13, 9:44 am, Tonne  wrote:
> It's the calendar with the unusual form/structure  that I'm
> struggling to implement with the stock Django tools.
>
> I'll take a step back and give it another shot with logic in view and
> parsing in the template.

I'm not sure what you mean by "parsing"...I am assuming you mean
"generating".

But it sounds to me like you might want to look into creating your own
template tag to generate the calendar HTML. I'd rather do that than go
nuts with nested loops inside a template.

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



Developer Designer Job in NYC

2009-04-13 Thread Tony Haile

We're looking for a developer with Django and CSS skills to come work
on Chartbeat.com. Chartbeat is a Betaworks company, the people behind
Bit.ly, Summize, Tweetdeck and a whole hos of other companies. Email
me at tony at betaworks.com. Job description below:

Chartbeat provides real-time analytics for your website, allowing you
to react instantly and effectively as visitors interact with your
site. We tell you how many people on your site and what they are doing
as they do it in real time. What’s more, we’ll send you alerts when
extraordinary activity takes place whether it’s uptime, user load time
or a flood of visitors exceeding your average maximum.

Chartbeat launched at the Web 2.0 Expo Keynote and has had an
incredible response. Now we’re looking for a superb front end designer-
developer to lead Chartbeat’s growth from newly-launched beta to fully-
fledged can’t live without it real-time analytics service.

Chartbeat is an early-stage company within the Betaworks Studios, the
early stage accelerator that has also been behind bit.ly, Tweetdeck
and Summize. You would be working out of the Betaworks loft in the
Meatpacking district of Manhattan (complete with full size pool table)
and getting the chance to interact with people from other companies
within the Betaworks stable. It’s a great mashup of some of the
brightest and best companies in the industry today.

What we use:

- CSS/HTML
- Django/Python
- Linux
- Javascript
- Flash
- Canvas
- Silverlight
- Amazon Web Services


We want to hear from you if:

- Your CSS mastery inspires awe in all who see it
- You are a creative product visionary who groks the real-time web
- You are passionate about metrics
- You have extensive experience of agile product development and
working in small teams that get things done on time.

Roles and responsibilities

- You will own the front-end of Chartbeat, shaping the look and
functionality of the service as it evolves.
- You will be in charge of the Chartbeat API and working with our
partners and resellers to integrate Chartbeat’s functionality into a
host of other services.
- You will work closely with the System Architect to ensure a
consistent stable service for our clients.




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



Re: How to find the version of Django?

2009-04-13 Thread mike171562

django-admin.py --version   from the command line should work as well.





On Apr 12, 1:39 am, Alex Gaynor  wrote:
> On Sun, Apr 12, 2009 at 2:38 AM, ydjango  wrote:
>
> > How do I find which version of django I have on my server?
>
> import django; print django.VERSION
>
> That should have a tuple with the version info.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Use Python to parse HTML and integrating said script into Django

2009-04-13 Thread Tonne

Thanks for you input. Okay, I clearly need to do a bit of revision on
nesting loops in templates then, if you think it might be possible to
do that. 3 nested 'while' loops with incrementing variables sound
doable in a template?

>Well, what does the updating of the dict consist of?

It will need to be updated based on queryset derived from a model, so
not so much a cron job. I do have the rest of the app working as I
want it. It's the calendar with the unusual form/structure  that I'm
struggling to implement with the stock Django tools.

I'll take a step back and give it another shot with logic in view and
parsing in the template.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



nginx/cherokee frontend , threaded vs prefork scgi/fcgi server

2009-04-13 Thread chiggsy

I'm going to be running django from either the threaded or preforked
runfcgi mode.

I'm wondering which one is more efficient for a deployment targeted
for now on an x64 linode/slice .

I dont really see any docs describing the different options, when to
use them, or anything like that, so I'm asking here.

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



Setting and deleting cache keys with tags

2009-04-13 Thread Sean Brant

I wrote up a blog post the other day on how I go about deleting
multiple related objects from cache based on tags. It allows you to
tag objects as you add them to cache that way you can delete a bunch
with one call. 
http://stepsandnumbers.com/archive/2009/04/11/setting-and-delete-cache-in-django-with-tags/

My question to the group is??? Is there a common use-case for this?
and should I submit a ticket and see if this or an approach similar is
worth including into trunk?

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



Re: rendering values from ManyToMany fields

2009-04-13 Thread Adam Fraser

Okay, so I should probably be dealing with the field in my ModelForm
class (the one that subclasses ModelForm).

This code is where the display values are found before creating the
ReadOnlyWidget.  In the case of my stains field (a ManyToMany field),
there isn't a get_stains_display function, so there's no way of
displaying it nicely (yet).

for field_name in self.fields:
if hasattr(obj, 'get_%s_display' % field_name):
display_value = getattr(obj, 'get_%s_display' %
field_name)()
else:
# what to do?
display_value = None
self.fields[field_name].widget = ReadOnlyWidget(getattr
(obj, field_name, ''), display_value)

I assume the get_XXX_display functions are being defined automatically
for my other fields in the project model (all of which are
PositiveIntegerFields).  How do I define one to get the display value
(s) for my stains ManyToManyField which maps to this model?

class Stain(models.Model):
def __unicode__(self):
return unicode(self.name)
name = models.CharField(max_length=40)


On Apr 10, 7:31 pm, Malcolm Tredinnick 
wrote:
> On Fri, 2009-04-10 at 12:16 -0700, Adam Fraser wrote:
>
> [...]
>
> > The problem I'm running into is that the value that comes into render
> > for the ManyToManyField is a list of the id's for the selected stains
> > and not the stains themselves.  I assume I should be getting them
> > somehow through the django.db.models.fields.related.ManyRelatedManager
> > which is in the original_value, but I haven't been able to figure out
> > how.
>
> > Anyone know what I'm missing?
>
> The Widget subclass should only be processing the data that is going to
> be displayed on the form. For something like a choice field based on
> models, this would be, say, the pk value and a string to use for the
> human-readable portion.
>
> The django.forms.models.ModelChoiceField is a good example to look at to
> see what's going on. It uses ModelChoiceIterator.choice() to generate
> the data that is passed to the widget for rendering and you'll see that
> it returns (pk, label) pairs.
>
> So it sounds like things are working as expected. What extra work are
> you trying to do at the widget level that requires more than what is
> already passed in (the sequence of (pk, label) values)? Why isn't
> whatever field you're using generating the right data? It's the Field
> subclass that you want to be addressing here, not the widget.
>
> In summary, widgets are objects that know how to take flat data and
> convert it to HTML. Fields are objects that know how to take more
> complex Python things (models, arbitrary objects, ...) and convert them
> to flat data for passing to the widgets.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving static files

2009-04-13 Thread google torp

Hi.

You misunderstood the docs a bit, I c/p'ed the url-conf bit here:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'}),

The problem here that is also causing the error is that the file name
should be
a variable and not hardcoded for every file, so instead of default.css
you should
instead have (?P.*). This is part of the argument that serve
will take, which
it uses to find the right file to serve. That is why the error is
saying:
erve() takes at least 2 non-keyword arguments (1 given)
the 2nd arguement that it expect is the document root.

Hope this clear things up for you

~Jakob

On 13 Apr., 13:58, amit sethi  wrote:
> Hi , i am new to django and i am trying to serve my css file .
> I followed the instruction to serve  static files in development server and
> made a seperate /media directory
> I copied my css file into it
>
> and changed the url pattern to include:
> (r'^site_media/default.css$', 'django.views.static.serve',
>         {'document_root': '/home/amit/analytics/media', 'show_indexes': 
> True}),
>
> now i get the error
> serve() takes at least 2 non-keyword arguments (1 given)
> i am new to web development please help
> --
> A-M-I-T S|S
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



serving static files

2009-04-13 Thread amit sethi
Hi , i am new to django and i am trying to serve my css file .
I followed the instruction to serve  static files in development server and
made a seperate /media directory
I copied my css file into it

and changed the url pattern to include:
(r'^site_media/default.css$', 'django.views.static.serve',
{'document_root': '/home/amit/analytics/media', 'show_indexes': True
}),
now i get the error
serve() takes at least 2 non-keyword arguments (1 given)
i am new to web development please help
-- 
A-M-I-T S|S

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



Re: How to scale out django apps?

2009-04-13 Thread Andy

Tim,

Thanks for the helpful answers.

As for specific details about my app, right now I'm still in the
design phase. It will start small, but hopefully it will get popular
quickly. So I don't know how big the Db will be or how many users will
there be.

What I'm trying to do is to make sure there is a graceful scale out
path should such a need arise.

Some answers to your questions:

> are you bringing back huge datasets or just small sub-slices of
your data?

Small

> are you updating large swaths of data at a time, or are you
just updating single records most of the time?

Mostly single records

> are just a few select users doing the updating, and all the
rest of your users are doing piles of reads?

Most users will do both reads and writes.
The usage pattern is not unlike facebook status update, where most
users will both update status and read status frequently.

> can you partition by things that totally do not relate, such as
by customer, so each customer can have their own instance that
then gets put wherever your admins define letting DNS balance the
load? (a'la BaseCamp's customername.basecamp.com)

App is for general users, anyone can sign up for free. So I doubt this
would work.

> can you tolerate replication delays?  what time-frame?
(sub-second?  async taking up to 30 minutes?  a whole day?)

Probably not. If a user updates her own status, she should be able to
see that updates immediately. Otherwise she'd think the site is not
working.


Is there any plan to support multiple connections? Sharding is a very
common techniques used in many places. I know in theory with a big
server and huge SAN disk array a single database could support many
users, but it's a lot cheaper to use multiple commodity servers
instead. And even with a huge budget sooner or later the scale up
approach will stop working.


On Apr 13, 6:51 am, Tim Chase  wrote:
> > Recently I found out Django doesn't support multiple databases. That's
> > quite surprising.
>
> > Given that limitation, how do you scale out a Django app?
>
> Depends on where your bottleneck(s) is/are.  It also depends
> heavily on your read/write usage pattern.  If you're truly
> experiencing a stenosis of the database connection, you have
> several options, but most of them reside in domain specific tuning.
>
> > Without multi-DB support, most of the usual techniques for scaling out
> > such as:
> >    - DB sharding
> >    - functional partitioning - eg. separate DB servers for user
> > profiles, orders, and products
> > would be infeasible with django.
>
> Sharding and functional partitioning don't yet exist in stock
> Django.  There's a GSoC project that may make some headway on
> "multiple database support", but I've not heard anything further
> on the Django Developers regarding that.
>
> > I know replication is still available. But that still means all data
> > must fit in 1 server.
>
> Well, with bountiful storage using things like AoE, SAS, SAN, FC,
> etc, having "all the data fit in one server" isn't a horrible
> issue.  And with 1TB drives on the market, fitting multiple TB in
> a single machine isn't a disastrous idea.  If you have more data
> than will fit in a single machine, you have a lot of other issues
> and will likely have to get very specific (and likely expensive
> ;-) help.
>
> > Also replication isn't going to help update performance.
>
> This goes back to my "read/write usage pattern" quip...if you
> have a high volume of reads, and a low volume of writes,
> replication is one of the first tools you reach for.  However,
> with a high volume of writes, you've entered the realm of "hard
> problems".  Usually if you app reaches this volume of DB traffic,
> you need a solution specialized to your domain, so stock Django
> may not be much help.  Given that you've not detailed the problem
> you're actually having (this is where profiling comes in), it's
> hard to point much beyond the generic here.  So answers to some
> questions might help:
>
> - are you bringing back huge datasets or just small sub-slices of
> your data?
>
> - are you updating large swaths of data at a time, or are you
> just updating single records most of the time?
>
> - are just a few select users doing the updating, and all the
> rest of your users are doing piles of reads?
>
> - how big is this hypothetical DB of yours?
>
> - can you partition by things that totally do not relate, such as
> by customer, so each customer can have their own instance that
> then gets put wherever your admins define letting DNS balance the
> load? (a'la BaseCamp's customername.basecamp.com)
>
> - can you tolerate replication delays?  what time-frame?
> (sub-second?  async taking up to 30 minutes?  a whole day?)
>
> - how readily can you cache things to prevent touching the
> database to begin with?  Can you cache with an HTTP proxy
> font-end for repeated pages?  Can you cache datasets or other
> fragments with memcached?  If your web-app follows 

how to use several different querysets in one single template(for a single url)?

2009-04-13 Thread jason

hi guys,

i want to create a page includes several querysets to display several
boards of different staffs. i used the generic.list_detail to do this,
but the object_list seemed to accept only one dictionary argument to
go. so how can i use several querysets in the single template to
display different record sets? like the index page of most websites,
there are many contents from different data sources.

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



Re: Use Python to parse HTML and integrating said script into Django

2009-04-13 Thread TiNo
On Mon, Apr 13, 2009 at 11:17 AM, Tonne  wrote:

> In my case I need to firstly update a 3 dimensional dict/list (i.e.
> nested 3 levels deep - not sure if 3 dimensional is an appropriate
> description), then iterate over it and put those results into an html
> page. I'm probably not looking hard enough, but I can't quite seem to
> grasp how to achieve this with traditional Django views and Django
> templates.


Couldn't you do that with three nested for loops in the template? See:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

I'd prefer to solve the problem the Django way. The problem for me is
>
that what I'm trying to do is not the usual scenario of passing the
>
results of query through a view to a template. I haven't found a
>
precedent in the docs or a tutorial elsewhere that covers this.


Well, what does the updating of the dict consist of? Even if it depends on
the date or on other external factors, it could happen in the view. Unless
updating it is only necessary once a day and takes a lot of computing power.
In that case you could run it with a cronjob [1] or any other scheduled
task, once a day, and save the data into a file or db.

Remember that Django can be used as what you refer to as 'freeform' python
as well. You are totally free to import parts of django into an external
python script, and in that way make use of django's models etc. (Only make
sure to set DJANGO_SETTINGS_MODULE in your script [2])

[1] http://en.wikipedia.org/wiki/Cron
[2] http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

TiNo

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



Re: How to scale out django apps?

2009-04-13 Thread Tim Chase

> Recently I found out Django doesn't support multiple databases. That's
> quite surprising.
> 
> Given that limitation, how do you scale out a Django app?

Depends on where your bottleneck(s) is/are.  It also depends 
heavily on your read/write usage pattern.  If you're truly 
experiencing a stenosis of the database connection, you have 
several options, but most of them reside in domain specific tuning.

> Without multi-DB support, most of the usual techniques for scaling out
> such as:
>- DB sharding
>- functional partitioning - eg. separate DB servers for user
> profiles, orders, and products
> would be infeasible with django.

Sharding and functional partitioning don't yet exist in stock 
Django.  There's a GSoC project that may make some headway on 
"multiple database support", but I've not heard anything further 
on the Django Developers regarding that.

> I know replication is still available. But that still means all data
> must fit in 1 server.

Well, with bountiful storage using things like AoE, SAS, SAN, FC, 
etc, having "all the data fit in one server" isn't a horrible 
issue.  And with 1TB drives on the market, fitting multiple TB in 
a single machine isn't a disastrous idea.  If you have more data 
than will fit in a single machine, you have a lot of other issues 
and will likely have to get very specific (and likely expensive 
;-) help.

> Also replication isn't going to help update performance.

This goes back to my "read/write usage pattern" quip...if you 
have a high volume of reads, and a low volume of writes, 
replication is one of the first tools you reach for.  However, 
with a high volume of writes, you've entered the realm of "hard 
problems".  Usually if you app reaches this volume of DB traffic, 
you need a solution specialized to your domain, so stock Django 
may not be much help.  Given that you've not detailed the problem 
you're actually having (this is where profiling comes in), it's 
hard to point much beyond the generic here.  So answers to some 
questions might help:

- are you bringing back huge datasets or just small sub-slices of 
your data?

- are you updating large swaths of data at a time, or are you 
just updating single records most of the time?

- are just a few select users doing the updating, and all the 
rest of your users are doing piles of reads?

- how big is this hypothetical DB of yours?

- can you partition by things that totally do not relate, such as 
by customer, so each customer can have their own instance that 
then gets put wherever your admins define letting DNS balance the 
load? (a'la BaseCamp's customername.basecamp.com)

- can you tolerate replication delays?  what time-frame? 
(sub-second?  async taking up to 30 minutes?  a whole day?)

- how readily can you cache things to prevent touching the 
database to begin with?  Can you cache with an HTTP proxy 
font-end for repeated pages?  Can you cache datasets or other 
fragments with memcached?  If your web-app follows good design, 
any GET can be cached based on a subset of its headers.

Lastly, read over David Cramer's blog[1] as he's done some nice 
work scaling Django to big deployments and has some helpful tips.

-tim

[1]
http://www.davidcramer.net/category/code/django






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



Re: Any way to bypass django's ORM?

2009-04-13 Thread Tim Chase

Continuation wrote:
> Is there any way to bypass django's ORM and have direct access to a
> database?

http://docs.djangoproject.com/en/dev/topics/db/sql/

Yep.

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



Any way to bypass django's ORM?

2009-04-13 Thread Continuation

Is there any way to bypass django's ORM and have direct access to a
database?

This would be useful for accessing features not supported by django
ORM - multi-db access, composite primary key, etc.

If it is possible to do so under django, can anyone point me to
tutorials or code samples?

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



How to scale out django apps?

2009-04-13 Thread Continuation

Recently I found out Django doesn't support multiple databases. That's
quite surprising.

Given that limitation, how do you scale out a Django app?

Without multi-DB support, most of the usual techniques for scaling out
such as:
   - DB sharding
   - functional partitioning - eg. separate DB servers for user
profiles, orders, and products
would be infeasible with django.

I know replication is still available. But that still means all data
must fit in 1 server. Also replication isn't going to help update
performance.

Is scalability of django really limited to a single DB? Or are there
workarounds?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Use Python to parse HTML and integrating said script into Django

2009-04-13 Thread Tonne

Thanks for you reply, Jakob.

I'd prefer to solve the problem the Django way. The problem for me is
that what I'm trying to do is not the usual scenario of passing the
results of query through a view to a template. I haven't found a
precedent in the docs or a tutorial elsewhere that covers this.

In my case I need to firstly update a 3 dimensional dict/list (i.e.
nested 3 levels deep - not sure if 3 dimensional is an appropriate
description), then iterate over it and put those results into an html
page. I'm probably not looking hard enough, but I can't quite seem to
grasp how to achieve this with traditional Django views and Django
templates.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnpickleableError when sessions are saved

2009-04-13 Thread Iqbal Abdullah

Thanks Alex and matehat,

Concerning this issue of mine, I've decided to remove the images and
save the objects without the ImagingCore in them, which fixed the
whole thing.

On a different note, other than actively testing data which we want to
put into sessions before we design the application for pickability,
are there any best practices which we can adhere to concerning
sessions? i.e keeping in mind to make sure data in sessions are all
simple types etc.

- i


On Apr 12, 10:42 pm, matehat  wrote:
> As Alex pointed out, only picklable data can be put in the session. If
> you really need that ImagingCore object in the session, you have to
> make it somehow picklable by adding "__getstate__" and "__setstate__"
> method for picklability (seehttp://docs.python.org/library/pickle.html).
> Basically, you'd need to find out what data identifies the object as
> it is now (the image path for example) so that it can be constructed
> back from scratch into its current state from that data alone, which
> must in turn by picklable.
>
> Of course if the ImagingCore class is not one of your own, you'll have
> to inspect then subclass 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How can I implement an app to enable user for importing their friends from MSN, Gmail etc.

2009-04-13 Thread TTear1943

Hi all,
I want to add my site an app so that enables users to invite their
friends from MSN, Gmail etc. to join in my site. Is there any solution
or apps for this.
Thank you very much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Default mimetype

2009-04-13 Thread Roman Timushev

Thank you for your answers, I came to the same decision (that url
cannot define mimetype), but have not thought about decorators.


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



Re: Use Python to parse HTML and integrating said script into Django

2009-04-13 Thread google torp

Hi.

It sounds like you need to change your code structure a bit to really
take advantage of Django and the possibilities it offer. If you just
want
to get your stuff working with Django and then nothing more, I guess
you could keep it like it is, but else re factoring would be a good
idea.

The way django works, you want to keep the logic separated from the
presentation. So basically that means, that you should keep the Python
code separated from your HTML. In Django terms, we use the view
to make the logic, where we can if needed, import helper functions.
When all the data has been calculated, we pass it to a template, a
html file where we with some Django code can insert data dynamically.

It sounds like you need to grasp these things, before you really get
going.

about writing views: http://docs.djangoproject.com/en/dev/topics/http/views/
about the template language 
http://docs.djangoproject.com/en/dev/topics/templates/
about render_to_response: 
http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response

Render to response is  common way of passing data to a template for
display.
Which was what your initial question was about. But I would recommend
that
you strip the html from your Python code and instead put the html in
your template
instead. That would be a more clean and Djangoish way of doing it.

~Jakob

On 13 Apr., 07:24, Tonne  wrote:
> Hi
>
> I'm not too sure how to ask this correctly (not an experienced
> developer so my vocab is not very accurate), but I'll try.
>
> I have created a Python script (collection of functions) that
> generates a calendar of sorts, really just a long list of dates from a
> 4 year date range. It also parses the HTML, as I couldn't work out how
> to do this with the limited logic available the templating language.
>
> My question are:
>
> Is it possible to use a "freeform" python within the Django framework,
> and yet let it receive arguments from the model?
>
> I was intially thinking of making a custom view, but then I have all
> this parsed HTML and am not sure how to get it into a template.
>
> Or should I be looking at making a custom tag?
>
> If not the above, do you have any other pointers on how to go about
> this?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use email instead of username for user authentication?

2009-04-13 Thread Praveen

You please check the satchmo package there they are using email as
username in satchmo-registration using
user=generate_id(email,firstname)

On Apr 13, 9:44 am, pkenjora  wrote:
> Malcolm,  <- Remembered the 'l' this time!
>
> To keep things simple and avoid fragmenting this discussion into a
> million different dead end tit for tats , I'll try to reign in the
> main points.
>
> 1. The default authentication method in Django should have no inherent
> restrictions.  Such as blocking '@' in the username.  This leaves the
> default framework open and free of workarounds.  This approach would
> not preclude any project specific requirements.
>
> 2. Any authentication method having restrictions should be an opt in
> method.  The current method is a restrictive authentication method,
> one that does not allow email, and should be made optional.
>
> 3. When you boil down the hundreds of specific use cases out there you
> still end up with the above two points.  In which case I would make
> the argument that if you need to block emails as user names then it is
> you who should write a new authentication handler.  In your own words,
> the framework allows this and its only a few lines of code.
>
> Now for the dead end tit for tat... this is really project philosophy
> not framework philosophy... hence I feel like it is circular
> discussion that distracts from the main point...
>
> Authenticating by email does not require me to check my email every
> time I log in.  So if my email is no longer accessible (left my job) I
> can simply log in and change it to a new one.  If changing the
> username requires checking my email then I will have the same problem
> if I use email as my username or not.
>
> You yourself identify the username as mainly an authentication
> mechanism not necessarily a display value.  Thats all the more reason
> to have a robust restriction free out of the box implementation of
> authentication.
>
> Thanks for reading the feedback, I still fail to see how you can
> include project specific requirements in a framework? The
> implementation you are advocating is a subset of the general
> implementation I would like to see bundled out of the box.  Why not
> move it into an optional module?
>
> -Paul
>
> On Apr 11, 4:13 pm, Malcolm Tredinnick 
> wrote:
>
> > On Sat, 2009-04-11 at 07:52 -0700, pkenjora wrote:
> > > Malcom,
>
> > Well, I'm not "Malcom" (sic), but I'll reply anyway.
>
> > >    Google, FaceBook, and LinkedIn have been using email authentication
> > > for how long now?  With the default constraints you've put on Django a
> > > developer would have to "work around" the out of the box code to make
> > > the project behave like the big 3 names on the web.
>
> > There's some assumption there that what they're doing is a good idea.
> > Their systems have the usability problems I've mentioned. It's also not
> > clear their authentication methods are the best around. In any case, as
> > I note below (and have written elsewhere), you're simply not restricted
> > from using this system and can do so without patching Django, if that's
> > the way you want to go. There's no restriction in place here!
>
> > The combined size of forums and social networking sites not pretending
> > that my "handle" is an email address is, I'll wager, larger than
> > Facebook or LinkedIn, certainly. Which has precisely the same small
> > weight as your examples. The point being that there are valid use-cases
> > in both directions and you'll notice that that's never been disputed.
>
> > [...]
>
> > >   As far as your reasons go, I'm fairly sure its just as easy to
> > > change the email as it is the username,
>
> > I'm sorry you feel that way. It's patently false. The username is only
> > used on the site you are creating an account for. Your email address has
> > much wider usage and creating a new one isn't always possible or
> > desirable (signing up to one of the hosted services requires agreeing to
> > T that are often unpleasant). The username when creating a new account
> > on a site has much less currency.
>
> > > I would even argue that my
> > > username (display name) could change but my login credentials should
> > > stay the same.
>
> > You are assuming that the username is the display name. That might be a
> > secondary use for it and it sometimes works well for that. However, the
> > username is primarily the unique identifier for the user within the
> > system. It's the thing that won't change. Having a display name,
> > particularly one that can change is also quite common and it's for
> > extensions like that that user profile exist for.
>
> > Login credentials are not the same as identifier within the system. The
> > login credentials should definitely be permitted to change. Having an
> > account tied to an email address is tragic when that email address is no
> > longer accessible to you (for example, it was a company address and
> > you've since left