Re: urls question

2008-07-04 Thread [EMAIL PROTECTED]

Look up how to do an or using python regexs. 
http://docs.python.org/lib/re-syntax.html

On Jul 5, 12:46 am, Luis Sanchez <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to do this:
>
> www.domain.com/part1/
>
> if part1 is :  someword1 , someword2 or someword3   go to the view:
> view1
> if part1 is :  someword6 , someword7 or someword9   go to the view:
> view2
>
> How can I do that using urls.py ??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



urls question

2008-07-04 Thread Luis Sanchez

Hi,

I want to do this:

www.domain.com/part1/

if part1 is :  someword1 , someword2 or someword3   go to the view:
view1
if part1 is :  someword6 , someword7 or someword9   go to the view:
view2

How can I do that using urls.py ??

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



Re: Another error

2008-07-04 Thread Leaf

I really need to stop making assumptions about Python. Again, I
assumed that the parameters wouldn't be case-sensitive. Most of my
programming experience has been in BASIC and PHP, which aren't quite
as picky. Thanks for all your help.

Regards,
Leaf

On Jul 4, 10:56 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-07-04 at 19:53 -0700, Leaf wrote:
>
> [...]
>
> > I'm not sure why maxlength.py was invoked at all, since as you can
> > clearly see I used the newer max_length version. At any rate, it seems
> > like I need help again. Can anyone explain what this error is, why it
> > got called, and how to fix it?
>
> Given that you're just starting out, you really are going to have to
> learn to take the time to examine some of these errors and work out what
> they could be. Reading the error messages carefully is going to be
> important.
>
> Django is reporting that it's being passed an unexpected keyword
> argument "Help_text". So look at where you are using "Help_text" and see
> if it's a permitted parameter (it isn't, since you've used a capital
> letter in the wrong place). Whenever Django gives you an error like
> this, go back and check your assumptions: look at the variable name of
> keyword or function you're using and verify in the documentation that
> you've spelt it exactly correctly.
>
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Another error

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 19:53 -0700, Leaf wrote:
[...]
> I'm not sure why maxlength.py was invoked at all, since as you can
> clearly see I used the newer max_length version. At any rate, it seems
> like I need help again. Can anyone explain what this error is, why it
> got called, and how to fix it?

Given that you're just starting out, you really are going to have to
learn to take the time to examine some of these errors and work out what
they could be. Reading the error messages carefully is going to be
important.

Django is reporting that it's being passed an unexpected keyword
argument "Help_text". So look at where you are using "Help_text" and see
if it's a permitted parameter (it isn't, since you've used a capital
letter in the wrong place). Whenever Django gives you an error like
this, go back and check your assumptions: look at the variable name of
keyword or function you're using and verify in the documentation that
you've spelt it exactly correctly.

Malcolm



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



Another error

2008-07-04 Thread Leaf

After fixing the Style model in Dj Style by replacing all the hyphens
with underscores, the syntax checked out completely. I ran manage.py
syncdb on it, and it returned this traceback:

Traceback (most recent call last):
  File "C:\django-project\firstsite\manage.py", line 11, in 
execute_manager(settings)
  File "C:\Python25\lib\site-packages\django\core\management
\__init__.py", line
272, in execute_manager
utility.execute()
  File "C:\Python25\lib\site-packages\django\core\management
\__init__.py", line
219, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python25\lib\site-packages\django\core\management\base.py",
line 72,
in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python25\lib\site-packages\django\core\management\base.py",
line 85,
in execute
self.validate()
  File "C:\Python25\lib\site-packages\django\core\management\base.py",
line 112,
 in validate
num_errors = get_validation_errors(s, app)
  File "C:\Python25\lib\site-packages\django\core\management
\validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 128, in
 get_app_errors
self._populate()
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 57, in
_populate
self.load_app(app_name, True)
  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
line 72, in
load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "C:\django-project\firstsite\dj_styles\models.py", line 36, in

class Style(models.Model):
  File "C:\django-project\firstsite\dj_styles\models.py", line 37, in
Style
Style_Name = models.CharField("Style Name", Max_length=32,
Default="Styles Upon Styles", Help_text="A user_friendly name for the
style.")
  File "C:\Python25\lib\site-packages\django\utils\maxlength.py", line
47, in inner
func(self, *args, **kwargs)
  File "C:\Python25\lib\site-packages\django\utils\maxlength.py", line
47, in inner
func(self, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'Help_text'

I'm not sure why maxlength.py was invoked at all, since as you can
clearly see I used the newer max_length version. At any rate, it seems
like I need help again. Can anyone explain what this error is, why it
got called, and how to fix it?

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



File Browser and Editor with Django,any help?

2008-07-04 Thread Darren Lee

Hi,all
   I am new to this community. these days My leader give me a
mission ,describe as below:
the httpd server was installed under a linux server ,and the it  use
Django tech. I should add the web server with a funtion like Windows
Explorer  and Editor in the WebBrowser like firefox.

any one can help ?
thanks



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



Re: Syntax error: "can't assign to operator"

2008-07-04 Thread Leaf

Okay. I'll run a quick find-and-replace to set all my identifiers to
use underscores instead of hyphens. I'm not that familiar with Python,
so I assumed that it would recognize hyphens as a seperator and not a
minus sign.

Regards,
Leaf

On Jul 4, 10:27 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-07-04 at 19:24 -0700, Leaf wrote:
> > I'm still working on the models.py for Dj Styles. I'm trying to create
> > a "Style" class, and the part of my code in question looks something
> > like this:
>
> > class Style(models.Model):
> >     Style-Name = models.CharField("Style Name", Max_length = 32,
> > Default = "Styles Upon Styles", Help_text = "A user-friendly name for
> > the style.")
>
> > Before resyncing the database, I hit the "Check Syntax" button in
> > PythonWin, and it returned "syntax error - can't assign to operator
> > (models.py, line 37)". Line 37 is the one beginning with Style-Name. I
> > tried searching the Internet for the syntax error, but couldn't find
> > anything that was particularly helpful. Does anyone know what's wrong
> > with my code that could be causing this error?
>
> Python thinks "Style-Name" is "Style - Name". You cannot use hyphens in
> identifiers. Looks like you need to slow down and take care that your
> Python is valid when you see these sorts of error messages.
>
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Syntax error: "can't assign to operator"

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 19:24 -0700, Leaf wrote:
> I'm still working on the models.py for Dj Styles. I'm trying to create
> a "Style" class, and the part of my code in question looks something
> like this:
> 
> class Style(models.Model):
> Style-Name = models.CharField("Style Name", Max_length = 32,
> Default = "Styles Upon Styles", Help_text = "A user-friendly name for
> the style.")
> 
> Before resyncing the database, I hit the "Check Syntax" button in
> PythonWin, and it returned "syntax error - can't assign to operator
> (models.py, line 37)". Line 37 is the one beginning with Style-Name. I
> tried searching the Internet for the syntax error, but couldn't find
> anything that was particularly helpful. Does anyone know what's wrong
> with my code that could be causing this error?

Python thinks "Style-Name" is "Style - Name". You cannot use hyphens in
identifiers. Looks like you need to slow down and take care that your
Python is valid when you see these sorts of error messages.

Malcolm



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



Syntax error: "can't assign to operator"

2008-07-04 Thread Leaf

I'm still working on the models.py for Dj Styles. I'm trying to create
a "Style" class, and the part of my code in question looks something
like this:

class Style(models.Model):
Style-Name = models.CharField("Style Name", Max_length = 32,
Default = "Styles Upon Styles", Help_text = "A user-friendly name for
the style.")

Before resyncing the database, I hit the "Check Syntax" button in
PythonWin, and it returned "syntax error - can't assign to operator
(models.py, line 37)". Line 37 is the one beginning with Style-Name. I
tried searching the Internet for the syntax error, but couldn't find
anything that was particularly helpful. Does anyone know what's wrong
with my code that could be causing this error?

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



Re: Copyright issues for an application developed using django, python and mySQL

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 19:03 -0700, Nagu wrote:
> Thank you very much for your explanations. From the above
> explanations, I can infer that I do not have to worry about any
> copyright or licensing issues. Please correct me if I am wrong.

Well, you have to respect them and know what the valid licensing issues
are. But they probably don't interfere with what you're trying to do.
With all due respect, if your company is worried about this, the only
correct answer is "talk to a lawyer". Open Source licenses aren't
particularly hard to understand, but when they are also interacting with
distributed proprietary stuff and when a corporation is worried about
their liabilities, taking advice solely from an internet mailing list is
probably not a good idea.

But Open Source software is designed to be used. Freely and without
onerous restrictions. So the sort of stuff you're talking about is
exactly in line with those goals.

Regards,
Malcolm


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



Re: Copyright issues for an application developed using django, python and mySQL

2008-07-04 Thread Nagu

Thank you very much for your explanations. From the above
explanations, I can infer that I do not have to worry about any
copyright or licensing issues. Please correct me if I am wrong.

A little context may help here. Our company is a reseller. We sell
computer products. I make mathematical models for our company. Our
sales force already have CRM (Customer Relationship Management) typish
thing to interact with the customers in driving business.  This new
toy, recommendation engine, can help them attaching more items to the
current order.

All I want to do is to help the sales force with this new
recommendation system while they are interacting with customers over
the phone. They are going type an internal web address, and enter a
customer id in a search box on the webpage to get recommendations of
numerous products to cross-sell and up-sell.

We are not going to sell this application to anyone, as the underlying
the data would be meaningless to others and no distribution involved
here too.

Thank you again.
Nagu

On Jul 3, 6:36 pm, Dan Ellis <[EMAIL PROTECTED]> wrote:
> There are no licensing issues with either Python or Django, which are
> both distributed under very liberal licenses (Python Software
> Foundation License and the BSD license respectively).
>
> http://www.python.org/psf/license/http://www.opensource.org/licenses/PythonSoftFoundation.phphttp://code.djangoproject.com/browser/django/trunk/LICENSE
>
> MySQL licensing is complicated, largely because it's gone through a
> few changes over the years. Check the MySQL web site and the Wikipedia
> article (http://en.wikipedia.org/wiki/MySQL#Support_and_licensing),
> but you won't have any problem if all you want to do is to deliver a
> web site that uses MySQL in its back end.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Defaults with "choices"

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 18:28 -0700, Leaf wrote:
> I'm working on an app called Dj Styles. It generates stylesheets
> dynamically. Anyway, I'm laying out the Style model, and I need to
> know: If you're using the "choices" parameter on a CharField, then
> which do you put for the "default" parameter - the value that gets
> recorded to the database or the verbose, user-friendly name? Or will
> either suffice?

The value that is sent to the database. More correctly, this is the
value that is stored in the model's attribute (it might be munged in
some way during transmission to and from the database).

Regards,
Malcolm



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



Defaults with "choices"

2008-07-04 Thread Leaf

I'm working on an app called Dj Styles. It generates stylesheets
dynamically. Anyway, I'm laying out the Style model, and I need to
know: If you're using the "choices" parameter on a CharField, then
which do you put for the "default" parameter - the value that gets
recorded to the database or the verbose, user-friendly name? Or will
either suffice?

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



Re: DateTimeField 12-hour input form. Easy way?

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 14:17 -0700, mw wrote:
> Hello,
> 
> I get the feeling that this isn't the easiest thing to accomplish
> given the different posts about it on the list, the lack of response
> to questions around in in IRC, and etc, though it strikes me as
> something that should be easy to do
> 
> I want to switch the DateTimeField to having a 12-hr clock input such
> that in places like the admin interface or in your own forms, a user
> could simply type 12:00 a.m.  or have a Jquery plugin help out and let
> them choose 12:00 a.m.  Right now, this will be rejected as a bad
> input.
> 
> I'm having problems finding clear instructions on how to actually make
> this happen.  I wish it was a simple as modifying the DATETIME_FORMAT
> variable in settings.py, but that doesn't do the trick.

There are at least two solutions that immediately jump to mind:

1. Use Javascript to modify the submitted input so that it's converted
from a.m./p.m. to the format the server expects after the form
submission button is pressed and before it is sent to the server. The
drawback here is that when the server returns the data to the form
(either as initial data somewhere or for error reporting), you'll need
to convert it back to 12-hour time.

2. Since the problem you are seeing is simply with field validation, use
different field validation. It is trivial to write your own form fields
-- just have a look at the existing fields in django/newforms/fields.py.
So write a field that has a clean() method which handles the input
formats you like and use that.

Regards,
Malcolm



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



Re: Help with templatetags

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 08:44 -0700, [EMAIL PROTECTED] wrote:
> i setup a custom template tag for my index page called recent_news.
> 
> i tried to setup a second template tag for the page called
> more_news.py. the first is working as recent_news.py.
> 
> recent_news.py gets the more recent entry, i have more_news.py set to
> get 2-6. i have {% load more_news %} since the file is more_news.py,
> it's in the same directory as recent_news.py and is the same file as
> recent_news.py other than the limits in what query results are getting
> and i'm getting the TemplateSyntaxError that the 'more_news' is not a
> valid tag library. what's up?

"And then I thought I'd post the same thing I did a couple of days ago
to start a new thread, rather than following on from the old one." :-)

Basic debugging 101: work out what has changed, back up until things
work and then go forwards one step at a time.

You claim that more_news.py is the same as recent_news.py with the
exception of some limits. That means you should be able to remove (or
"move aside") the more_news.py file, edit recent_news.py to use the
limits from more_news.py and it should work, right? Verify that. Now you
know that the code itself works.

Then you can diff the recent_news.py and more_news.py files to make sure
that the *only* differences are the tag names and the limits. So now you
know what has changed. Then you can check that in your template the
*only* thing you have changed to switch from using the tags in
recent_news.py to more_news.py is the "{% load ... %}" template tag.

At this point, you've changed things one step at a time:
1. start from a known, working recent_news.py
2. change it to behave like you want the new tag to behave.
3. rename the file to its target name and change the tag name
4. change the templates to use the new tag name

Everything should still be working by that point. If it's not, you've
found the problem. If it is and there are differences with your original
more_news.py file, then you know what to investigate.

There is no limitation on having multiple files in a templatetags/
directory or anything. The problem is somewhere in your code or in your
template. So just work through things one step at a time until something
breaks and then work out what caused that.

Regards,
Malcolm


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



Re: Dynamic models keyError

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 09:28 -0700, mwebs wrote:
> Hello,
> 
> I am trying to generate models at runtime. For this purpose I am using
> the method create_model() provided at
> http://code.djangoproject.com/wiki/DynamicModels
> 
> create_model(name, fields, module='app.models' )
> 
> When I am doing like this i get a keyError '__module__'
> 
> then I tried to pass the whole path:
> 
> create_model(name, fields, module='project.src.app.models' )
> 
> Still got an keyError, but this time it looked like this: keyError
> 'project.src.app.models'
> 
> Any ideas what I am doing wrong.

Quite seriously, if you're not able to debug this sort of error
yourself, given the source code for create_model() and the internals of
Django it calls, then you probably shouldn't be creating dynamic models.
Creating models at runtime is a very advanced piece of functionality and
certainly not recommended (models in Django are backed by database
tables almost always, so runtime creation hardly ever makes sense).

We can't really help anyway, since you don't tell us where you get the
KeyError. However, you can work through it fairly easily. Looking at the
traceback you see, you should be able to work out which line in
create_model() is the jumping off point for the problem, then work out
what might have changed in the Django core code it's calling. It will
take some time, but you will learn stuff about Django's internals whilst
doing it.

Regards,
Malcolm



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



Re: syncdb

2008-07-04 Thread [EMAIL PROTECTED]

Thanks a lot!!  I am used to rails.  Hopefully django will have some
sort of db migrate ability in the future.

On Jul 4, 5:02 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Jul 4, 2008 at 7:37 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > I have a new user question.  I am working on a sight using the .96
> > version of django.  I created a model with fields and ran "python
> > manage.py syncdb", which worked fine.  After doing some work I
> > realized I needed to add a new field to one of the models.  How do I
> > tell django to re-sync the db?  I tried "python manage.py syncdb", but
> > that did do anything.  Thanks.
>
> Syncdb won't alter existing tables.  You can use manage.py reset to
> completely reset the application (losing any data in it), or manually modify
> the table using your database's native utility for this (whether/how you can
> do this varies by database), or search this list for schema migration or
> evolution -- there are at least a couple of external projects aimed at
> providing this function.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "Eval" in templates?

2008-07-04 Thread [EMAIL PROTECTED]

I don't think it would be difficult to implement, either as a block
tag, or as a regular tag with context.

On Jul 4, 7:29 pm, Ben Kovitz <[EMAIL PROTECTED]> wrote:
> Is there an easy way in Django to do the following?
>
> In blah.html:
>
>    {{ buttonDecidedAtRunTime }} blah blah blah
>
> In the Context passed to blah.html at run-time:
>
>    buttonDecidedAtRunTime: '{% include "button4.html %}'
>    thisPage: "/some/path"
>
>    Naturally, the included template might be button1.html,
> button2.html, etc., depending on run-time decisions.
>
> In button4.html:
>
>    html  for button #4 a>
>
> The kicker is the {{ thisPage }} inside button4.html.  I'm hoping to
> pass thisPage in the context sent to blah.html.  This would make the
> code really simple.  Of course, the code you see above will just show
> the string literal '{% include "button4.html %}' right in your
> browser.
>
> What's needed is something like eval for template tags.  I could
> imagine:
>
>    {% eval %}{% buttonDecidedAtRunTime %}{% endeval %}
>
> or maybe even better would be:
>
>    {% eval buttonDecidedAtRunTime %}
>
> Is there a way to do this?  If it's not already in Django, does it
> look easy to implement?  I haven't yet implemented a custom tag, but I
> read the chapter in the book, and it doesn't look too hard.  On the
> other hand, I don't want to spend days mired in it if it's hard.
>
> Or, is there a better way to do what I'm trying to do?  Right now, I
> see two other options:  render button4.html and pass the result as the
> value of buttonDecidedAtRunTime (this complicates the Python code a
> bit, since thisPage must be passed to the subroutine that decides
> which button to render); or use {% if %} tags in blah.html (kind of
> ugly, involves difficulties with parameter-passing, and we need to do
> this all over the place, though we could stuff the {% if %} logic into
> an included template).
>
> Ben Kovitzhttp://decisionero.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



"Eval" in templates?

2008-07-04 Thread Ben Kovitz

Is there an easy way in Django to do the following?

In blah.html:

   {{ buttonDecidedAtRunTime }} blah blah blah

In the Context passed to blah.html at run-time:

   buttonDecidedAtRunTime: '{% include "button4.html %}'
   thisPage: "/some/path"

   Naturally, the included template might be button1.html,
button2.html, etc., depending on run-time decisions.

In button4.html:

   html  for button #4


The kicker is the {{ thisPage }} inside button4.html.  I'm hoping to
pass thisPage in the context sent to blah.html.  This would make the
code really simple.  Of course, the code you see above will just show
the string literal '{% include "button4.html %}' right in your
browser.

What's needed is something like eval for template tags.  I could
imagine:

   {% eval %}{% buttonDecidedAtRunTime %}{% endeval %}

or maybe even better would be:

   {% eval buttonDecidedAtRunTime %}

Is there a way to do this?  If it's not already in Django, does it
look easy to implement?  I haven't yet implemented a custom tag, but I
read the chapter in the book, and it doesn't look too hard.  On the
other hand, I don't want to spend days mired in it if it's hard.

Or, is there a better way to do what I'm trying to do?  Right now, I
see two other options:  render button4.html and pass the result as the
value of buttonDecidedAtRunTime (this complicates the Python code a
bit, since thisPage must be passed to the subroutine that decides
which button to render); or use {% if %} tags in blah.html (kind of
ugly, involves difficulties with parameter-passing, and we need to do
this all over the place, though we could stuff the {% if %} logic into
an included template).


Ben Kovitz
http://decisionero.com


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



Re: Editing content in Django Admin change-list

2008-07-04 Thread Itai Tavor

On 03/07/2008, at 11:23 AM, David Melton wrote:

>
> I would like to be able to change the status of an item (Yes/No Field)
> in a list of items from the change-list view without having to open
> the item and change it within the change form. Is there an easy way
> (built in) to the Django admin framework to allow this?

Hi David,

You can do this quite easily by adding a custom column to the admin  
list. You don't need to change any admin templates for this.

It looks something like this:

In models.py:

 def boolean_switch(field):
 def _f(self):
 v = getattr(self, field.name)
 url = '%d/%s/switch/' % (self._get_pk_val(), field.name)
 return '' % (url, ('no','yes')[v], v)
 _f.short_description = field.verbose_name
 _f.allow_tags = True
 return _f

 class MyModel(models.Model):
 name = models.CharField()
 featured = models.BooleanField()

 featured_switch = boolean_switch(featured)
 featured_switch.admin_order_field = 'featured'

 class Admin:
 list_display = ['name', 'featured_switch']

In views.py:

 from django.db.models import get_model
 from django.http import HttpResponseRedirect
 from django.shortcuts import get_object_or_404
 from django.core.exceptions import PermissionDenied

 def switch(request, url):
 """
 Set/clear boolean field value for model object
 """
 app_label, model_name, object_id, field = url.split('/')
 model = get_model(app_label, model_name)

 if not request.user.has_perm('%s.%s' % (app_label,  
model._meta.get_change_permission())):
 raise PermissionDenied

 object = get_object_or_404(model, pk=object_id)
 setattr(object, field, getattr(object, field) == 0)
 object.save()

 msg = '"%s" flag changed for %s' % (field, object)
 request.user.message_set.create(message=msg)
 return HttpResponseRedirect(request.META.get('HTTP_REFERER',  
'/'))

In urls.py, add this line before '^admin/':

 url('^admin/(?P.*)/switch/$', 'switch', name='switch'),

That should do it... I actually keep all this code in a separate app  
so I can apply it to any boolean field by just importing  
boolean_switch and including a urls module.

Itai


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



Re: MySQL Errors Using syncdb

2008-07-04 Thread Karen Tracey
On Fri, Jul 4, 2008 at 6:01 PM, Arif <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I hope someone can shed some light on this as I have been trying to
> get Django to work for hours and hours.
>
> If I run a Django site that does not have a database connection the
> localserver starts correctly, however if I run a site that requires a
> database connection I get the following error when I run:
>
> python manage.py syncdb
>

[error traceback snipped]

Posting the contents of your models.py file someplace like dpaste.com might
help someone pinpoint what is going wrong.  You seem to have something in
your models file called during validation that requires that the underlying
database tables already exist.  Possibly something to do with choices
specified on some field?

Karen

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



Re: syncdb

2008-07-04 Thread Karen Tracey
On Fri, Jul 4, 2008 at 7:37 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> I have a new user question.  I am working on a sight using the .96
> version of django.  I created a model with fields and ran "python
> manage.py syncdb", which worked fine.  After doing some work I
> realized I needed to add a new field to one of the models.  How do I
> tell django to re-sync the db?  I tried "python manage.py syncdb", but
> that did do anything.  Thanks.
>

Syncdb won't alter existing tables.  You can use manage.py reset to
completely reset the application (losing any data in it), or manually modify
the table using your database's native utility for this (whether/how you can
do this varies by database), or search this list for schema migration or
evolution -- there are at least a couple of external projects aimed at
providing this function.

Karen

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



Re: Type error: Cannot resolve keyword 'name' into field

2008-07-04 Thread Karen Tracey
On Fri, Jul 4, 2008 at 6:02 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

>
> I'm having troubles with an admin portion. I am brand new at django,
> so any help would be greatly appreciated. I am trying to make a class
> of family members.
>
> This works correctly when I use the admin to add new names to it. But
> when I try to change an element I get this error:
> TypeError at /admin/main/name/4/
> Cannot resolve keyword 'name' into field
>
>
Based on the fact your model specified maxlength, not max_length, I guess
you are using a 0.96.x release of Django.  Using 0.96.1, I get the same
error.  Switching to an SVN checkout, it goes away.  Not sure but you may be
hitting this bug:

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

which was only completely fixed after the 0.96 release, so you'll need to
upgrade to an SVN checkout to get the fix.

Karen

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



syncdb

2008-07-04 Thread [EMAIL PROTECTED]

I have a new user question.  I am working on a sight using the .96
version of django.  I created a model with fields and ran "python
manage.py syncdb", which worked fine.  After doing some work I
realized I needed to add a new field to one of the models.  How do I
tell django to re-sync the db?  I tried "python manage.py syncdb", but
that did do anything.  Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Determining Multi-Table Child Type

2008-07-04 Thread Karen Tracey
On Fri, Jul 4, 2008 at 6:52 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:

>
> So I've got a Multi-Table parent model, CalendarEvent, and two child
> models: Regatta and Meeting.
>
> I've got a calendar view that shows all of the upcoming events like
> this:
> events = CalendarEvent.objects.all()
>
> But I want to determine what kind of event each of these are (Regatta
> or Meeting) from the object's CalendarEvent instance. I could've sworn
> I found some good way to do this, but have completely forgotten. I'd
> really hate to have to make a field to set the event type in, it seems
> counter to the entire idea.
>

This issue was recently discussed in this thread:

http://groups.google.com/group/django-users/browse_thread/thread/d4f4a2954d12d79e/615a88094b67a84f

Karen

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



Re: Include django views in other web sites

2008-07-04 Thread Alessandro Ronchi
2008/7/4, Alaa Salman <[EMAIL PROTECTED]>:

> If i understand you correctly, what you need is just AJAX. Just have
>  your views produce xml or json or perhaps even html snippets. And use
>  any javascript suite to call this view and then insert the data into
>  your page. I prefer spitting out data in a json format, and then using
>  something like YUI or jquery to call and then parse.

Do you have any example?
-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Determining Multi-Table Child Type

2008-07-04 Thread Greg Taylor

So I've got a Multi-Table parent model, CalendarEvent, and two child
models: Regatta and Meeting.

I've got a calendar view that shows all of the upcoming events like
this:
events = CalendarEvent.objects.all()

But I want to determine what kind of event each of these are (Regatta
or Meeting) from the object's CalendarEvent instance. I could've sworn
I found some good way to do this, but have completely forgotten. I'd
really hate to have to make a field to set the event type in, it seems
counter to the entire idea.

It'd be awesome to be able to do something like:

for event in events:
  if event.child_class == Regatta:
do stuff

Any ideas for this? I noticed there are methods on each CalendarEvent
'regatta' and 'meeting', worse case I could check each of these for
non-null values and return something, but this seems kludgey.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MySQL Errors Using syncdb

2008-07-04 Thread Arif

Hi,

I hope someone can shed some light on this as I have been trying to
get Django to work for hours and hours.

If I run a Django site that does not have a database connection the
localserver starts correctly, however if I run a site that requires a
database connection I get the following error when I run:

python manage.py syncdb

Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/core/management/
commands/runserver.py", line 47, in inner_run
self.validate(display_num_errors=True)
  File "/Library/Python/2.5/site-packages/django/core/management/
base.py", line 112, in validate
num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.5/site-packages/django/core/management/
validation.py", line 60, in get_validation_errors
for c in f.choices:
  File "/Users/Arif/Sites/Acquisition App/acquisitionapp/../
acquisitionapp/app/models.py", line 184, in __iter__
for o in Organisation.objects.filter(models.Q(administrator=user)
| models.Q(participants=user)).distinct():
  File "/Library/Python/2.5/site-packages/django/db/models/query.py",
line 164, in _result_iter
self._fill_cache()
  File "/Library/Python/2.5/site-packages/django/db/models/query.py",
line 586, in _fill_cache
self._result_cache.append(self._iter.next())
  File "/Library/Python/2.5/site-packages/django/db/models/query.py",
line 252, in iterator
for row in self.query.results_iter():
  File "/Library/Python/2.5/site-packages/django/db/models/sql/
query.py", line 204, in results_iter
for rows in self.execute_sql(MULTI):
  File "/Library/Python/2.5/site-packages/django/db/models/sql/
query.py", line 1609, in execute_sql
cursor.execute(sql, params)
  File "/Library/Python/2.5/site-packages/django/db/backends/util.py",
line 18, in execute
return self.cursor.execute(sql, params)
  File "build/bdist.macosx-10.5-i386/egg/MySQLdb/cursors.py", line
166, in execute
  File "build/bdist.macosx-10.5-i386/egg/MySQLdb/connections.py", line
35, in defaulterrorhandler
_mysql_exceptions.ProgrammingError: (1146, "Table
'acquisitionapp.app_organisation' doesn't exist")

Any help would be really appreciated.

Many thanks.

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



Type error: Cannot resolve keyword 'name' into field

2008-07-04 Thread [EMAIL PROTECTED]

I'm having troubles with an admin portion. I am brand new at django,
so any help would be greatly appreciated. I am trying to make a class
of family members.

This works correctly when I use the admin to add new names to it. But
when I try to change an element I get this error:
TypeError at /admin/main/name/4/
Cannot resolve keyword 'name' into field



here is my class:
class Name(models.Model):
first_name = models.CharField(maxlength=40, blank=True,null=True)
middle_name = models.CharField(maxlength=40, blank=True,null=True)
last_name = models.CharField(maxlength=40, blank=True,null=True)
suffix = models.CharField(maxlength=4,choices=SUFFIX_CHOICES,
blank=True, null=True)
gender=models.CharField(maxlength=1, choices=GENDER_CHOICES,
blank=True, null=True)
birth_state = models.CharField(maxlength=30, blank=True,
null=True)
birth_country = models.CharField(maxlength=30, blank=True,
null=True)
death_state = models.CharField(maxlength=30, blank=True,
null=True)
death_country = models.CharField(maxlength=30, blank=True,
null=True)
birth_date=models.DateField(null=True,blank=True)
death_date=models.DateField(null=True,blank=True)
mother=models.ManyToManyField("self", blank=True, null=True)
father=models.ManyToManyField("self", blank=True, null=True)
sibblings=models.ManyToManyField("self" ,blank=True, null=True)
kids=models.ManyToManyField("self",blank=True, null=True)
spouse=models.ManyToManyField("self",blank=True,null=True)

class Admin:
pass

def __str__(self):
return '%s %s %s' % (self.first_name,self.last_name,
self.suffix)

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



Re: Simple object creation in postgresql with django views code...

2008-07-04 Thread Daniel Roseman

On Jul 4, 5:00 pm, RossGK <[EMAIL PROTECTED]> wrote:
> I'm trying to do a bit of simple Django access to a postgresql
> database, and must be missing something. Using the tutorial info, I've
> had mixed success.   I can pull a bit of stuff form the database, but
> have some curious behaviour that is slowing me down.  See the example
> details below...
>
> Problems:
> a) I am able to get an SList object by specifying the id, but the .id
> attribute is not accessible.
> If I use the django shell, it behaves as expected, but not when
> implemented in my views.py
>
> b) I could not create and save a new object in my database, so I tried
> it in the interactive shell where it worked as expected, then upon
> trying it again in with the dev server running, and executing the
> populateDB in views below, it worked.
> However, I can only create an SList object by explicitly specifying
> the id= field.  It should allow me to make one without specifying
> that  (see doghop example below).
>


What are the symptoms of a and b "not working"? Does nothing happen,
do you get a traceback, what?

The more details, the better. It might also help to post the db part
of your settings.py file.

--
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DateTimeField 12-hour input form. Easy way?

2008-07-04 Thread mw

Hello,

I get the feeling that this isn't the easiest thing to accomplish
given the different posts about it on the list, the lack of response
to questions around in in IRC, and etc, though it strikes me as
something that should be easy to do

I want to switch the DateTimeField to having a 12-hr clock input such
that in places like the admin interface or in your own forms, a user
could simply type 12:00 a.m.  or have a Jquery plugin help out and let
them choose 12:00 a.m.  Right now, this will be rejected as a bad
input.

I'm having problems finding clear instructions on how to actually make
this happen.  I wish it was a simple as modifying the DATETIME_FORMAT
variable in settings.py, but that doesn't do the trick.

Any advice from the list?

Thanks super very much in advance,
mw


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



Re: streaming upload

2008-07-04 Thread umrzyk

On 29 Cze, 22:15, umrzyk <[EMAIL PROTECTED]> wrote:
> hi there,
> i would like to give my users ability to upload a huge (i.e. 10-20 MB)
> files, mostly images. standard uploading using django newforms and
> FileField is at the moment not an option. it kills my
> server immediately. recently i read about streaming upload, and.. wow,
> that's it! so i patched my django sources with 2070-r7728.patch (no
> conflicts) and gave it a try.
[cut]
ok, the issue is resolved now. after an hour of IRC chatting with
Mike, it occured that was problem neither with apache/nginx nor with
my code. I have just pulled older revision from svn and applied 2070
patch by myself. Although there were no conflicts then, something was
not working. Today i updated django from svn once again. as Mike said
2070 has been commited to the trunk few days ago so there is no need
to apply it again by hand. Now everything works like a charm.

thanks for your help,
michal.

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



Re: Displaying Child Records in a list of the Parent Records

2008-07-04 Thread Lee Hinde

On Jul 3, 2:49 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Jul 3, 7:43 pm, Lee Hinde <[EMAIL PROTECTED]> wrote:
>
>
>
> > Say I have invoices (parent) and payments (child) and I want to show
> > each payment made against the invoices while displaying the list of
> > invoices.
>
> > I've read other discussions here about the problems of automatically
> > loading child records using select_related().
>
> > (http://groups.google.com/group/django-users/browse_frm/thread/
> > 53f30fd617f13f1d/18ecb827406d2b8f?
> > lnk=gst&q=select_related#18ecb827406d2b8f)
>
> > I'm assuming the work around involves a separate query for each
> > Invoice. But I'm not sure how to implement such a thing. (and then
> > reference it in the template.)
>
> > I'm after something that might look like:
>
> > {% for i in  invoice %}
> >    {{i.customer.name}} {{i.invoice.invdate}}
> >         {% for p in  i.payment %}
> >               {{p.paymentdate}} {{p.paymentamount}}
> >         {% endfor %}
>
> > {% endfor %}
>
> > As always, thanks in advance.
>
> >   Lee
> > --
> > The reason I prefer groups to IRC is that in groups, I get to thank
> > you.
>
> You're almost there. The only thing to change is your "for p in..."
> line, which should be:
> {% for p in i.payment_set.all %}
>
> Seehttp://www.djangoproject.com/documentation/db-api/#backwardfor
> the explanation.
> --
> DR.

I ended up using that concept, but in a model method, rather than the
template. I'll add this to the notes.

Thanks 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with templatetags

2008-07-04 Thread mccomas . chris

Yeah I did.

I actually tested it on my development server, also on a production
server (actually restarted apache several different times)...

On Jul 4, 2:22 pm, Brian Luft <[EMAIL PROTECTED]> wrote:
> Have you tried restarting the development server?  I've noticed that
> Django seems to cache template tag definitions when it starts up and
> won't pick up changes.  They may have addressed this but I've gotten
> in the habit of just restarting the development server whenever I'm
> mucking around with custom template libraries.
>
> -Brian
>
> On Jul 4, 8:44 am, [EMAIL PROTECTED] wrote:
>
> > i setup a custom template tag for my index page called recent_news.
>
> > i tried to setup a second template tag for the page called
> > more_news.py. the first is working as recent_news.py.
>
> > recent_news.py gets the more recent entry, i have more_news.py set to
> > get 2-6. i have {% load more_news %} since the file is more_news.py,
> > it's in the same directory as recent_news.py and is the same file as
> > recent_news.py other than the limits in what query results are getting
> > and i'm getting the TemplateSyntaxError that the 'more_news' is not a
> > valid tag library. what's up?
>
> > here's the code:
>
> > TEMPLATE
> > {% load more_news %}
> > {% get_morenews_list %}
> > {% for news in more_news %}
> > {{ news.title }}
> > {% endfor %}
>
> > MORE_NEWS.PY
> > from myproject.site.models import Blog
> > from django.template import Library,Node
>
> > register = Library()
>
> > def build_morenews_list(parser, token):
>
> > return NewsObject()
>
> > class NewsObject(Node):
> > def render(self, context):
> > context['more_news'] = Blog.blog_live.all().order_by('-
> > pub_date')[2:6]
> > return ''
>
> > register.tag('get_morenews_list', build_morenews_list)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inputting Date/Time in a Django Form

2008-07-04 Thread Tim Sawyer

Thanks anyway, I got it to work using a jQuery date popup and manually writing 
the forms html.

Cheers,

Tim.

On Thursday 03 Jul 2008, TiNo wrote:
> Ah yeah.
> Maybe:
>
> collection_datetime =
> forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
> collection_datetime.widget.widgets = (input1.. , input2..)
> would do the trick?
>
> I don't have a development env here so I am only guessing.
> Anybody else has suggestions on this? Because it looks a little hacky...
>
> TiNo
>
> On 7/2/08, Tim Sawyer <[EMAIL PROTECTED]> wrote:
> > Sorry, still not working.  I get:
> >
> > __init__() got an unexpected keyword argument 'widgets'
> >
> > Is that because widgets isn't a parameter to __init__ ? (I'm still
> > getting to
> > grips with python, it's so much more expressive than the Java I'm used
> > to!)
> >
> > My code is:
> >
> > collection_datetime = forms.SplitDateTimeField(widget=
> >
> > forms.SplitDateTimeWidget(widgets=
> >
> >  
> >   (
> >
> > forms.TextInput({'class':'vDateField required'}),
> >
> > forms.TextInput({'class':'vTimeField required'})
> >
> > )
> >
> > )
> >   )
> >
> > ta,
> >
> > Tim.
> >
> > On Wednesday 02 Jul 2008, TiNo wrote:
> > > Have a look at the source (widgets.py in newforms):
> > > class SplitDateTimeWidget(MultiWidget):
> > > """
> > > A Widget that splits datetime input into two 
> >
> > boxes.
> >
> > > """
> > > def __init__(self, attrs=None):
> > > widgets = (TextInput(attrs=attrs), TextInput(attrs=attrs))
> > > super(SplitDateTimeWidget, self).__init__(widgets, attrs)
> > >
> > > So maybe:
> > >
> > > collection_datetime =
> > > forms.SplitDateTimeField(
> > >
> > > widget=forms.SplitDateTimeWidget(
> > >
> > > widgets=(TextInput({'class':'vDateField required'}),
> > >
> > > TextInput({'class':'vTimeField'}
> > >
> > > will work?
> > >
> > >
> > > On Wed, Jul 2, 2008 at 11:03 PM, Tim Sawyer
> > > <[EMAIL PROTECTED]>
> > >
> > > wrote:
> > > > Thanks.
> > > >
> > > > I've got the class in the html but not the buttons for the date or
> > > > time popup.
> > > > I also have two date popups and I think I should have one that has
> > > > the class
> > > > vTimeField not vDateField.
> > > >
> > > > collection_datetime =
> >
> > forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget({'class':'vDate
> >
> > > >Field required'}))
> > > >
> > > > in my form is generating:
> > > >
> > > > Collection
> > > > datetime: > > > type="text" class="vDateField required" name="collection_datetime_0"
> > > > />
> > > >
> > > > in my html.
> > > >
> > > > Any ideas?
> > > >
> > > > Cheers,
> > > >
> > > > Tim.
> > > >
> > > > On Wednesday 02 Jul 2008, TiNo wrote:
> > > > > Sorry, I was a little too quick. I used it like this:
> > > > > date =
> >
> > forms.DateField(label=_("Date"),widget=forms.DateTimeInput(attrs={'class'
> >
> > > >:'
> > > >:
> > > > >vDateField'}))
> > > > >
> > > > > I am not sure on how to do this on a SplitDateTimeField though.
> > > > >
> > > > > On Wed, Jul 2, 2008 at 10:52 PM, Tim Sawyer
> > > > > <[EMAIL PROTECTED]>
> > > > >
> > > > > wrote:
> > > > > > Sorry, I don't understand where I have to put the attrs bit.
> > > > > >
> > > > > > Can you give me an example?
> > > > > >
> > > > > > delivery_datetime =
> > > > > > forms.SplitDateTimeField(attrs={'class':'vDateField'}) doesn't
> >
> > work,
> >
> > > > > > is that what you meant?
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Tim.
> > > > > >
> > > > > > On Sunday 29 Jun 2008, TiNo wrote:
> > > > > > > add:
> > > > > > >
> > > > > > >  > > >
> > > > type="text/javascript"
> > > >
> > > > > > > >
> > > > > > >
> > > > > > >  > > > > > > type="text/javascript" >
> > > > > > >  >
> > > > > > > type="text/javascript" >
> > > > > > >
> > > > > > > to your template, use SplitDateTimeField and pass the fields:
> > > > > > >
> > > > > > > attrs={'class':'vDateField'}
> > > > > > >
> > > > > > > That way you have the same date and time input as the admin
> > > >
> > > > interface.
> > > >
> > > > > > > TiNo
> > > > > > >
> > > > > > > On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer
> > > > > > > <[EMAIL PROTECTED]
> > > > > > >
> > > > > > > wrote:
> > > > > > > > Hi Folks,
> > > > > > > >
> > > > > > > > What's the simplest approach for me to have a form that makes
> >
> > it
> >
> > > > easy
> > > >
> > > > > > for
> > > > > >
> > > > > > > > the
> > > > > > > > user to enter a Date/Time combination?
> > > > > > > >
> > > > > > > > I have my form class specified (the field in question is a
> > > > > > > > forms.DateTimeField()), but I need to make it easy for users
> > > > > > > > of the
> > > > > >
> > > > > > site
> > > > > >
> > > > > > > > to enter a date/time pair for the field.
> > > > > > > >
> > > > > > > > Is there a simple way to do this?  I'm using jQuery for
> > > > > > > > javascript
> > > >
> > > > on
> > > >
> > > > > > the
> > > >

tweaking auth, making usernames unique within a company

2008-07-04 Thread brydon

Hey,

I'm assuming I can always fork auth and modify the User class
directly, however, I'd prefer to avoid that.

I'd like to add a new model class called Company. Data and users
within a company are mutually exclusive. I'd therefore like to allow
usernames to be unique in the context of a Company.

If I hacked auth.User then I'd be doing something like...

unique_together = (("username", "company"),)

For now, the user's company is available through their profile,
User.get_profile().company.

Any thoughts how to accomplish this without forking auth??

thanks,
brydon

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



Re: Help with templatetags

2008-07-04 Thread Brian Luft

Have you tried restarting the development server?  I've noticed that
Django seems to cache template tag definitions when it starts up and
won't pick up changes.  They may have addressed this but I've gotten
in the habit of just restarting the development server whenever I'm
mucking around with custom template libraries.

-Brian

On Jul 4, 8:44 am, [EMAIL PROTECTED] wrote:
> i setup a custom template tag for my index page called recent_news.
>
> i tried to setup a second template tag for the page called
> more_news.py. the first is working as recent_news.py.
>
> recent_news.py gets the more recent entry, i have more_news.py set to
> get 2-6. i have {% load more_news %} since the file is more_news.py,
> it's in the same directory as recent_news.py and is the same file as
> recent_news.py other than the limits in what query results are getting
> and i'm getting the TemplateSyntaxError that the 'more_news' is not a
> valid tag library. what's up?
>
> here's the code:
>
> TEMPLATE
> {% load more_news %}
> {% get_morenews_list %}
> {% for news in more_news %}
>         {{ news.title }}
> {% endfor %}
>
> MORE_NEWS.PY
> from myproject.site.models import Blog
> from django.template import Library,Node
>
> register = Library()
>
> def build_morenews_list(parser, token):
>
>     return NewsObject()
>
> class NewsObject(Node):
>     def render(self, context):
>         context['more_news'] = Blog.blog_live.all().order_by('-
> pub_date')[2:6]
>         return ''
>
> register.tag('get_morenews_list', build_morenews_list)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Do you code django with Komodo?

2008-07-04 Thread Eric Holscher

I'd be interested in this as well. I currently use Komodo Edit, and
love the Vi emulation!

On Jun 26, 1:02 pm, rskm1 <[EMAIL PROTECTED]> wrote:
> On Jun 24, 4:22 pm, Tye <[EMAIL PROTECTED]> wrote:
>
> > Semi-off-topic:
> > Does anybody know how to get notepad to save as UTF-8 by default? It
> > keeps trying ANSI, and I keep hating.
>
> Unlikely; Notepad is REALLY lightweight.
> Wordpad is MUCH better; it handles files >64K, files with UNIX-style
> linebreaks, and files with foreign characters.  So if you're stuck
> with Windows and don't want to install any third-party stuff, just use
> Wordpad and forget that Notepad even exists.
>
> Personally, I'm running Linux with KDE, and "kwrite" and "kdevelop"
> both have pretty good Python syntax recognition builtin.  "kdevelop"
> even has tabs and a navigator like the Eclipse IDE, but seems to be
> less "bloated".  (haven't tried Komodo; freeIDE>$IDE =)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Oracle syncdb

2008-07-04 Thread El Marto

thanks i will try that

On Jul 3, 11:36 pm, Ian <[EMAIL PROTECTED]> wrote:
> On Jul 3, 3:23 pm, El Marto <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all!
>
> > I've developed and tested an application in MySQL and everything
> > worked fine fine fine. Now i am migrating to Oracle, the app works
> > fine but I am having a lot of trouble with the Django admin.
>
> > Whenever i run syncdb, it creates one table and throws an exception
> > like this:
>
> > ORA-00955: name is already used by an existing object
>
> > Luckily every time I run it, it creates another table and crashes. So
> > by running the syncdb command SEVERAL times, I get all the tables.
> > (this should all be a sign that something is not working ok with
> > oracle). But this is not the problem. When the tables are complete, I
> > run it again and i get
>
> > ORA-01400: cannot insert NULL into
> > ("ORACLE"."DJANGO_CONTENT_TYPE"."ID")
>
> > and i dont seem to have a workaround for this.
>
> > What can i do? please please please help me :D
>
> It sounds like what's happening is that for each table, it succeeds in
> creating the table, but then fails to create the corresponding
> sequence, because the name is already in use.  Since it raises an
> error at the sequence, the AutoField trigger doesn't get created
> either, and so you get the second error when trying to save objects.
>
> Did you perhaps create the schema once before, but then dropped all
> the tables without also dropping the sequences?  Try clearing out the
> schema entirely and then running syncdb again.
>
> Ian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Dynamic models keyError

2008-07-04 Thread mwebs

Hello,

I am trying to generate models at runtime. For this purpose I am using
the method create_model() provided at
http://code.djangoproject.com/wiki/DynamicModels

create_model(name, fields, module='app.models' )

When I am doing like this i get a keyError '__module__'

then I tried to pass the whole path:

create_model(name, fields, module='project.src.app.models' )

Still got an keyError, but this time it looked like this: keyError
'project.src.app.models'

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



localization

2008-07-04 Thread Ramdas S
Is there a bog app, with multi language support, whose code I can see. or
any other simple app.

Kindly provide link



-- 
Ramdas S
+91 9342 583 065
My Personal Blog: http://ramdas.diqtech.com

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



Re: Include django views in other web sites

2008-07-04 Thread Alaa Salman


On Jul 4, 6:41 pm, "Alessandro Ronchi" <[EMAIL PROTECTED]>
wrote:
> 2008/7/3, Jeff Anderson <[EMAIL PROTECTED]>:
>
> >  I have used the django template system to generate web pages independent of
> > a django project.
>
> >  First I created a settings.py that only has the TEMPLATE_DIRS setting.
> >  Next, I created my template.
> >  Last, I created a cgi script that loads and renders my template. I used a
> > more generic python CGI module to handle post data.
>
> >  If you don't want to use the django template system exclusively, consider
> > using an iframe for a "browser side include".
>
> I cannot use any server side technologies and I cannot use iframes.
>

If i understand you correctly, what you need is just AJAX. Just have
your views produce xml or json or perhaps even html snippets. And use
any javascript suite to call this view and then insert the data into
your page. I prefer spitting out data in a json format, and then using
something like YUI or jquery to call and then parse.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Non editable fields in admin

2008-07-04 Thread Alex Rades
Hi,
I'm writing an application which makes a pretty heavy use of the
newforms-admin administrative site.

One recurring need is displaying of informative fields (fields which should
not be editable from the admin site, but only viewed).
For example, imagine to have a DateField field into a Story class, which is
automatically updated every time a user writes a new story. It is
desiderable to see this value in the admin site, but has no sense (actually
is wrong) to allow modifications to it.

Note that this is different from the purpose of the 'editable' attribute,
what I'm talking about is a presentation-only feature, and for this reason
we could put it into ModelAdmin classes:

class StoryOptions(admin.ModelAdmin):
readonly_fields = ('lastupdate',)

People have been asking this a lot of times, at least here:

http://code.djangoproject.com/ticket/342
http://code.djangoproject.com/ticket/611
http://code.djangoproject.com/ticket/1714
http://code.djangoproject.com/ticket/3990

Is there a working solution to display this kind of readonly data in the
admin site?

Thank you

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



Re: html templates - 'for' cycle without a variable

2008-07-04 Thread [EMAIL PROTECTED]

Create a 20-elemnt list inside your view and set it as a context
variable?

On Jul 3, 10:21 am, antony_h <[EMAIL PROTECTED]> wrote:
> How could I repeat my  20 times?
> I've found how I can repeat it 5 times:
> {% for a in 12345|make_list %}
> 
> {% endfor %}
> But it's not so great for e.g. a hundred
> Usage: my designer wants to test his layout and I don't want to create
> a custom tag for such a simple task
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Simple object creation in postgresql with django views code...

2008-07-04 Thread RossGK

I'm trying to do a bit of simple Django access to a postgresql
database, and must be missing something. Using the tutorial info, I've
had mixed success.   I can pull a bit of stuff form the database, but
have some curious behaviour that is slowing me down.  See the example
details below...

Problems:
a) I am able to get an SList object by specifying the id, but the .id
attribute is not accessible.
If I use the django shell, it behaves as expected, but not when
implemented in my views.py

b) I could not create and save a new object in my database, so I tried
it in the interactive shell where it worked as expected, then upon
trying it again in with the dev server running, and executing the
populateDB in views below, it worked.
However, I can only create an SList object by explicitly specifying
the id= field.  It should allow me to make one without specifying
that  (see doghop example below).

Am I missing something?  This seems very non-functional, so it must be
me.


>My models.py file contains a model:

class SList(models.Model):
def __str__(self):
return self.SListName
SListName = models.CharField(maxlength=16)  # opportunity to
group sports
class Admin:
pass

 And my views.py file:

from myproject.trial.models import SList
def populateDB(request):

print('PopDB called successfully')
sl1 = SList.objects.get(id=1)
print('try a get: ' + sl1.SListName)#this works fine

print('id: ' + sl1.id)  #this won't work (see a)

s = SList(id=5, SListName='monkeyjump') #worked only after
interactive session
s.save()

t = SList(SListName='doghop')   #doesn't work (see b)
t.save()

return null

I'd appreciate any guidance on what I'm missing...

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



FormPreview in admin site (newforms-admin).

2008-07-04 Thread Adam J. Forster

Hi all,

I'm pretty sure that this isn't possible, but does anybody know if you
can add the form preview functionality to the admin site (using
newforms-admin branch)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Help with templatetags

2008-07-04 Thread mccomas . chris

i setup a custom template tag for my index page called recent_news.

i tried to setup a second template tag for the page called
more_news.py. the first is working as recent_news.py.

recent_news.py gets the more recent entry, i have more_news.py set to
get 2-6. i have {% load more_news %} since the file is more_news.py,
it's in the same directory as recent_news.py and is the same file as
recent_news.py other than the limits in what query results are getting
and i'm getting the TemplateSyntaxError that the 'more_news' is not a
valid tag library. what's up?

here's the code:

TEMPLATE
{% load more_news %}
{% get_morenews_list %}
{% for news in more_news %}
{{ news.title }}
{% endfor %}

MORE_NEWS.PY
from myproject.site.models import Blog
from django.template import Library,Node

register = Library()

def build_morenews_list(parser, token):

return NewsObject()

class NewsObject(Node):
def render(self, context):
context['more_news'] = Blog.blog_live.all().order_by('-
pub_date')[2:6]
return ''

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



Re: Include django views in other web sites

2008-07-04 Thread Alessandro Ronchi
2008/7/3, Jeff Anderson <[EMAIL PROTECTED]>:

>  I have used the django template system to generate web pages independent of
> a django project.
>
>  First I created a settings.py that only has the TEMPLATE_DIRS setting.
>  Next, I created my template.
>  Last, I created a cgi script that loads and renders my template. I used a
> more generic python CGI module to handle post data.
>
>  If you don't want to use the django template system exclusively, consider
> using an iframe for a "browser side include".

I cannot use any server side technologies and I cannot use iframes.

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Developer needed Client Management / Client Screening system

2008-07-04 Thread Lee Dreams

We have a proprietary Client Screening and management software program
created in Django and Python.

We are an adult industry service company.

Our designer has moved on and we're looking for a young mind to not
only continue work but take it in a new direction.

It's currently running on slicehost system which is Centos 5.1, system
mySql 4,
Our client Database is about 1100 clients. This project is open to
College students who have a firm grasp of Python - Django or even ruby

1) We need a rebuild of this software

2) Time frame is As soon as possible

The Process:

Person fill's out the form:

Once submitted the process is:

a) A thank you form mail using some of the entered data is sent to the
applicant.

b) A database dup check on several fields is performed.

c) data scrapes to several web sites, several of them require login.
For now in the admin backend I'll settle for clicking on a link and
having it propergate the necessary information to that sites web form
and I'll take from there manually. Example of the kinds of sites would
be: http://www.zabasearch.com/advanced.php
http://www.intelius.com/background-check.html

d) A client code of a specific schema is generated

e) Once the truth of the information provided is found to be
acceptable or not the correct form e-mail (approval or denial) is user
selected and information is passed to the form mail by predefined
fields and sent by the program. The ability to create different
letters for various situations is important.

f) User status in the system is then defined -- ie approved..declined
etc.

>From the backed of course we can do client look ups to verify their
status

We also want to be able to provide this screening service to other
clients so the form has to be brandable to the look and feel of the
host site.

That's the basic system and we'll need modification from there down
the road.

Preference to those who live in the USA makes PHONE communication SO
much cheaper. In you live in KY,OH,TN a major bonus.

We're not married to Django if you think you can accomplish this in
another platform make your case all we want is something that WORKS
reliably.

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



Re: Unsorted user selection widget after changeset 7806 (nfa)

2008-07-04 Thread spacetaxi

On 4 Jul., 15:52, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> You've waited one day right at the beginning of a big holiday weekend in the
> US; [...]

Ooops, sorry. I didn't think about this. Thanks for your feedback!

-Stephan


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



Re: Unsorted user selection widget after changeset 7806 (nfa)

2008-07-04 Thread Karen Tracey
On Fri, Jul 4, 2008 at 9:21 AM, spacetaxi <[EMAIL PROTECTED]> wrote:

> Hm, it seems to me that nobody has a solution? Do I have to replace
> the many-to-many-relation (editors) with an additional ArticleEditor-
> class, containting a one-to-many relation to the User class and a one-
> to-many relation to Article? Is this the only way to get a sorted User
> selection widget?
>

You've waited one day right at the beginning of a big holiday weekend in the
US; I'd guess rather that no one has had a chance to look into this yet.  If
you want to make sure it doesn't get lost, open a ticket for it, but it's a
bit early I think to be concluding you need to restructure your application
to get around the change.

Karen


>
> Kind regards
> -Stephan
>
> On 3 Jul., 13:56, spacetaxi <[EMAIL PROTECTED]> wrote:
> > Hello, currently I'm a little bit lost on this one... Maybe some kind
> > soul can give me a hint?
> >
> > Look at this excerpt of a model class:
> >
> > -
> > from django.db import models
> > from django.contrib.auth.models import User
> > class Article(models.Model):
> > # (...snip...)
> > editors = models.ManyToManyField(User,
> > related_name='articles_from_editor')
> > # (...snip...)
> > -
> >
> > Everything was fine up to changeset 7806, which removed the default
> > ordering of the User class:http://code.djangoproject.com/changeset/7806
> >
> > After changeset 7806 the user selection widget in the admin form for
> > my Article class contains *unsorted* usernames. This is a major
> > problem when there are a lot of users existing in the database...
> >
> > So what's the easiest and most elegant way to get the user selection
> > widget sorted again?
> >
> > BTW, I'm using the newforms-admin branch.
> >
> > TIA
> > -Stephan
>
>

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



Re: Usability: stripping white space from form fields

2008-07-04 Thread Karen Tracey
On Fri, Jul 4, 2008 at 3:51 AM, Greg Fuller <[EMAIL PROTECTED]> wrote:

> I want to mention what I consider to be a usability issue with Django
> forms.  It has to do with there being no option to strip  leading and
> trailing whitespace from CharFields, URLFields, EmailFields, etc.
> Ticket #4969 was to address this issue but was closed with as a
> 'wontfix', and I have seen other discussions on this issue.
>

I think you mean #4960 (http://code.djangoproject.com/ticket/4960), not
#4969.  There is also another ticket opened for this, #6362 (
http://code.djangoproject.com/ticket/6362) which is in design decision
needed.

I agree that an option to strip leading/trailing wihtespace from form fields
would be useful, and is probably more often than not the behavior that is
desired by default.

Karen

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



Re: Unsorted user selection widget after changeset 7806 (nfa)

2008-07-04 Thread spacetaxi

Hm, it seems to me that nobody has a solution? Do I have to replace
the many-to-many-relation (editors) with an additional ArticleEditor-
class, containting a one-to-many relation to the User class and a one-
to-many relation to Article? Is this the only way to get a sorted User
selection widget?

Kind regards
-Stephan

On 3 Jul., 13:56, spacetaxi <[EMAIL PROTECTED]> wrote:
> Hello, currently I'm a little bit lost on this one... Maybe some kind
> soul can give me a hint?
>
> Look at this excerpt of a model class:
>
> -
> from django.db import models
> from django.contrib.auth.models import User
> class Article(models.Model):
>     # (...snip...)
>     editors = models.ManyToManyField(User,
> related_name='articles_from_editor')
>     # (...snip...)
> -
>
> Everything was fine up to changeset 7806, which removed the default
> ordering of the User class:http://code.djangoproject.com/changeset/7806
>
> After changeset 7806 the user selection widget in the admin form for
> my Article class contains *unsorted* usernames. This is a major
> problem when there are a lot of users existing in the database...
>
> So what's the easiest and most elegant way to get the user selection
> widget sorted again?
>
> BTW, I'm using the newforms-admin branch.
>
> TIA
> -Stephan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Create field from two others

2008-07-04 Thread Luke Seelenbinder
Thanks, for the reply I have since defined a function to handle this.

On Thu, Jul 3, 2008 at 11:35 PM, James Bennett <[EMAIL PROTECTED]>
wrote:

>
> On Thu, Jul 3, 2008 at 8:59 PM, lukeqsee <[EMAIL PROTECTED]> wrote:
> >
> > Can you take a first_name & a last_name field and then in the same
> > model make a field that is full_name? ie
> > first_name = models.CharField(max_length=75)
> > last_name = models.CharField(max_length=75)
> > full_name = models.CharField(value=first_name + last_name,
> > max_length=100)
>
> Not like this, no, but you seem to be hung up on trying to use field
> classes for everything. This is not necessary (and in this case would
> be a bad idea: you'd have duplicated data and you'd need to constantly
> watch out to prevent the fields getting out of sync with each other),
> because you can define perfectly normal Python attributes and methods
> on your models.
>
> Most likely you want to use a property with both a getter and a
> setter, as shown in the examples in the documentation:
>
> http://www.djangoproject.com/documentation/models/properties/
>
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>

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



Re: Include django views in other web sites

2008-07-04 Thread Alessandro Ronchi



On 3 Lug, 15:26, David Christiansen <[EMAIL PROTECTED]> wrote:
> Just a thought, but can you put this information in an iframe?

Yes I've done, but this solution has two problems:

1) Blogger.com and other sites doesn't permits iframes
2) Referrers tracking is wrong with iframes, because if the user
clicks a link it seems to come to the included domain, not from the
referring domain.

So, the solution should be to use the same technics of statistics
sites, but I don't know hot to do it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Share models among applications and split them in multiple files

2008-07-04 Thread Alex Rades
Ok I've got it working. I had to import models in
models_app/models/__init__.py as Malcom suggested. I've used app_label
instead of app_name in the Meta classes to make it work, is this ok?

On Fri, Jul 4, 2008 at 12:33 PM, Malcolm Tredinnick <
[EMAIL PROTECTED]> wrote:

>
>
> On Fri, 2008-07-04 at 12:22 +0200, Alex Rades wrote:
> [...]
>
> > So for now there is only this models_app which should contain the
> > models. When I try to run syncdb, models under models/ are not
> > imported. Is there any magic to do into
> > models_app/models/__init__.py ?
>
> You need to import them into the models/ namespace, because Django only
> looks in .models for any model definitions. So your
> __init__.py will be a bunch of imports from your subfiles (with
> judicious use of __all__ in the subfiles, it's just going to be a list
> of "from component import *" sort of lines).
>
> Regards,
> Malcolm
>
>
> >
>

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



Re: Bound forms and form_from_instance

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 12:20 +0200, Florencio Cano wrote:
> I'm trying to understand Django forms and I have a doubt.
> Imagine that you define a Form class called AddressClass.
> You can instantiate it like this:
> 
> address_form = AddressClass()
> 
> address_form will be an unbound form object and when you if you show
> it in the template all the fields will be blank.
> 
> Now with the same class definition, first you declare a dictionary
> with some values:
> aDict = {'street':'somestreet', 'number':3}
> address_form = AddressClass(aDict)
> 
> Now address_form is a bound form object and if you show it in a
> template the street field and the number street will be filled.
> form_from_instance work very similar and this is my doubt!
> If you create the form from an address object:
> an_address = Address.objects.all[0]
> AddressForm = form_from_instance(an_address)
> address_form2 = AddressClass()
> 
> address_form2 will be a bound object very similar to address_form?
> Because if you show it in the html now you have some values filled,
> haven't you? What differences will exist between them?

The difference is that data passed to a form's constructor is the data
that was submitted to populate the form (typically, request.POST). It's
user-supplied. The data extracted from the instance in a ModelForm or
form_for_instance() is used as initial data to populate the form fields.
It's not bound data or data submitted by the user, it's purely initial
default stuff. It's the way an unbound form can have initial values for
display.

Regards,
Malcolm



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



Re: Share models among applications and split them in multiple files

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 12:22 +0200, Alex Rades wrote:
[...]

> So for now there is only this models_app which should contain the
> models. When I try to run syncdb, models under models/ are not
> imported. Is there any magic to do into
> models_app/models/__init__.py ?

You need to import them into the models/ namespace, because Django only
looks in .models for any model definitions. So your
__init__.py will be a bunch of imports from your subfiles (with
judicious use of __all__ in the subfiles, it's just going to be a list
of "from component import *" sort of lines).

Regards,
Malcolm


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



Re: Share models among applications and split them in multiple files

2008-07-04 Thread Adi J. Sieker

On Fri, 04 Jul 2008 12:22:33 +0200, Alex Rades <[EMAIL PROTECTED]> wrote:

> So for now there is only this models_app which should contain the  
> models. When I try to run syncdb, models under models/ are not imported.  
> Is there any magic to do into models_app/models/__init__.py ?

There is no magic in the models. You just need to make sure you added  
models_app
to your INSTALLED_APPS directive in the settings.py.
syncdb only install models from installed apps.

Regards
   adi

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



Re: Share models among applications and split them in multiple files

2008-07-04 Thread Alex Rades
On Fri, Jul 4, 2008 at 11:26 AM, Malcolm Tredinnick <
[EMAIL PROTECTED]> wrote:

>
>
> On Fri, 2008-07-04 at 11:08 +0200, Alex Rades wrote:
> > Hi,
> > I have a project with 3 application which could (should) share their
> > models. Morover, I'd like to put models into a separate directory,
> > splitted into multiple files. Something like:
> >
> > myproject/
> >models/
> >   box.py
> >   firmware.py
> >   component.py
> >myapp1/
> >myapp2/
> >myapp3/
> >
> > Is it possible to organize the project in this way?
>
> Not really. Each model "belongs to" ("is defined in") a single
> application. All that means (and exactly what it means) is that the
> model's "app_name" is that application's name and there are a few cases
> (e.g. default database table) where we use  +  to
> generate identifiers.
>
> However, you might be approaching this the wrong way. Any application
> can import models from any other application. So if you want to split
> out certain pieces of business logic or presentation logic into other
> applications -- which isn't necessarily a bad thing -- then put those
> items into one app and they can import the models from the models'
> originating app.
>
> Now, as for putting the models into separate files: that's possible and
> it has to be under the models/ directory in one of your apps. The only
> thing to know here is that you must then set the "app_name" attribute on
> the inner Meta class for each model to be the name of the app directory.
> For example, with this structure:
>
>myapp1/
>   models/
>  component.py
>  ...
>
> any model in component.py will have to say something like
>
>class Component(models.Model):
>   ...
>   class Meta:
>  app_name = 'myapp1'
>
> So "app_name" is just the application's directory name (*just* that
> directory name, nothing with dots in it or anything like that).
>
> Hope that gives you some ideas.
>

Hi Malcom,
My 3 applications have all the same level of relation with the models so I'd
rather prefer not to privilege one of them as the main app/models owner.
Anyway, I could create an application whose only function is models
container, I can live with this :)

As for the models splitting, I've tried the approach you suggested, but it
doesn't work yet. My project structure is the following

|-- models_app
|   |-- models
|   |   |-- __init__.py
|   |   |-- backend.py
|   |   |-- box.py
|   |   `-- release.py
|   `-- __init__.py
|-- __init__.py
|-- app.db
|-- manage.py
|-- settings.py
`-- urls.py

So for now there is only this models_app which should contain the models.
When I try to run syncdb, models under models/ are not imported. Is there
any magic to do into models_app/models/__init__.py ?

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



Bound forms and form_from_instance

2008-07-04 Thread Florencio Cano

I'm trying to understand Django forms and I have a doubt.
Imagine that you define a Form class called AddressClass.
You can instantiate it like this:

address_form = AddressClass()

address_form will be an unbound form object and when you if you show
it in the template all the fields will be blank.

Now with the same class definition, first you declare a dictionary
with some values:
aDict = {'street':'somestreet', 'number':3}
address_form = AddressClass(aDict)

Now address_form is a bound form object and if you show it in a
template the street field and the number street will be filled.
form_from_instance work very similar and this is my doubt!
If you create the form from an address object:
an_address = Address.objects.all[0]
AddressForm = form_from_instance(an_address)
address_form2 = AddressClass()

address_form2 will be a bound object very similar to address_form?
Because if you show it in the html now you have some values filled,
haven't you? What differences will exist between them?

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



Re: Share models among applications and split them in multiple files

2008-07-04 Thread Malcolm Tredinnick


On Fri, 2008-07-04 at 11:08 +0200, Alex Rades wrote:
> Hi,
> I have a project with 3 application which could (should) share their
> models. Morover, I'd like to put models into a separate directory,
> splitted into multiple files. Something like:
> 
> myproject/
>models/
>   box.py
>   firmware.py
>   component.py  
>myapp1/
>myapp2/
>myapp3/
> 
> Is it possible to organize the project in this way?

Not really. Each model "belongs to" ("is defined in") a single
application. All that means (and exactly what it means) is that the
model's "app_name" is that application's name and there are a few cases
(e.g. default database table) where we use  +  to
generate identifiers.

However, you might be approaching this the wrong way. Any application
can import models from any other application. So if you want to split
out certain pieces of business logic or presentation logic into other
applications -- which isn't necessarily a bad thing -- then put those
items into one app and they can import the models from the models'
originating app.

Now, as for putting the models into separate files: that's possible and
it has to be under the models/ directory in one of your apps. The only
thing to know here is that you must then set the "app_name" attribute on
the inner Meta class for each model to be the name of the app directory.
For example, with this structure:

myapp1/
   models/
  component.py
  ...

any model in component.py will have to say something like

class Component(models.Model):
   ...
   class Meta:
  app_name = 'myapp1'

So "app_name" is just the application's directory name (*just* that
directory name, nothing with dots in it or anything like that).

Hope that gives you some ideas.

Regards,
Malcolm

> 
> Thank you
> 
> > 


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



Saving date/times from a form

2008-07-04 Thread Tim Sawyer

Folks,

I have an input form where users enter a new date and time.  If the user 
enters 2007-01-01 and 01:00:00 I get the following error at submit:

invalid input syntax for type timestamp with time 
zone: "(datetime.datetime(2007, 1, 1, 1, 0),)"

Here's the code:

forms.py: collection_datetime = 
forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget({'class':'vDateField'}))

html: {{ Form.as_table }}

and then back on my model object I'm doing:

lCollection.collection_datetime = pForm.cleaned_data['collection_datetime'],

I guess I've missing something somewhere. Can anyone point me in the right 
direction?

Thanks,

Tim.



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



Share models among applications and split them in multiple files

2008-07-04 Thread Alex Rades
Hi,
I have a project with 3 application which could (should) share their models.
Morover, I'd like to put models into a separate directory, splitted into
multiple files. Something like:

myproject/
   models/
  box.py
  firmware.py
  component.py
   myapp1/
   myapp2/
   myapp3/

Is it possible to organize the project in this way?

Thank you

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



Re: error with syncdb

2008-07-04 Thread allisongardner

IGNORE ME!! For some reason best known to my computer and Django it
now works Go figure!

On Jul 4, 10:36 am, allisongardner
<[EMAIL PROTECTED]> wrote:
> I have created my models, validated them etc and looked at the sqlall
> output and everything was fine. However when i went to syncdb my
> database it created 5 of 10 tables but and error on the 6th table
> (suddenly found multiple primary keys!) caused the process to stop. I
> fixed the problem in my models with the problem table (well i
> commented it) but when i run sqlall the original sql shows up and
> syncdb still won't create the remaining tables. Why won't the sql
> change when i change my models and what should i do. I looked at the
> database in phpmyadmin and 5 of the tables are present.
> In addition (but this maybe a separate issue I don't know) when i try
> to look at the admin pages for the cretaed tables I get an error:
> ProgrammingError: (1146, "Table 'amyprot.django_session' doesn't
> exist"
> Help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



error with syncdb

2008-07-04 Thread allisongardner

I have created my models, validated them etc and looked at the sqlall
output and everything was fine. However when i went to syncdb my
database it created 5 of 10 tables but and error on the 6th table
(suddenly found multiple primary keys!) caused the process to stop. I
fixed the problem in my models with the problem table (well i
commented it) but when i run sqlall the original sql shows up and
syncdb still won't create the remaining tables. Why won't the sql
change when i change my models and what should i do. I looked at the
database in phpmyadmin and 5 of the tables are present.
In addition (but this maybe a separate issue I don't know) when i try
to look at the admin pages for the cretaed tables I get an error:
ProgrammingError: (1146, "Table 'amyprot.django_session' doesn't
exist"
Help!

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



Re: Admin functionality: someadmin.articles.models.article_genre'> instance needs to have a primary key value before a many-to-many relationship can be used.

2008-07-04 Thread [EMAIL PROTECTED]

I do understand that situation. But think of it...

I want to create user associating him to certain groups
By that time user itself is not created. But it needs to create user
and then keep the relations between
user and groups in another table right...

I do want same behaviour. In my case it throws this
 instance needs to
have a primary key value before a many-to-many relationship can be

Here I want to create new article. I associated him to multiple
genres..Now it should first save the article and then
store the relation in another table. Instead it is trying to store
relation first I guessAny solution for this ?

Thank you,
Sateesh.


On Jul 2, 7:47 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 2, 2008 at 4:01 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> wrote:
>
>
>
>
>
> > Hi all,
> >  I am using django admin to show my tables.
> >  I used ManyToMany field, and facing this error.
>
> >         instance needs to
> > have a primary key value before a many-to-many relationship can be
> > used.
>
> >  Actually I am trying to create new record of article which has many
> > to many field to article_genre table...
> > First of all the error is wrong. Next how to over come it.
> > I searched the group, and could see some solutions with out using
> > admin interfacebut could not able to
> > solution in which I can still use admin interface...
> >  Please let me know if some one have used many to many field and
> > could still see their tables using django
> > admin..
>
> I think the error message identifying the wrong Model has been fixed
> recently (seehttp://code.djangoproject.com/ticket/7026).
>
> Can't comment on the rest of the question because I don't understand it.  To
> avoid this error, you have to ensure both sides of the ManyToMany
> relationship have been saved (and thus have a primary key) before attempting
> to save the relationship.  How do you have your models specified that this
> requirement cannot be satisfied in the context of the admin app?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Usability: stripping white space from form fields

2008-07-04 Thread Greg Fuller

I want to mention what I consider to be a usability issue with Django
forms.  It has to do with there being no option to strip  leading and
trailing whitespace from CharFields, URLFields, EmailFields, etc.
Ticket #4969 was to address this issue but was closed with as a
'wontfix', and I have seen other discussions on this issue.

As a developer, I know better than to enter spaces in a field, or to
blank an existing  entry with spaces.  But non-technical users more
often than not do not make this distinction.  Here are some
implications of not stripping these fields:

1. It let's the user get past required=True. You can set this behavior
if you go to to admin-->sites, edit the display name by blanking it
out with spaces, and save.  The "this field is required" message is
not displayed and the record is saved.  Of course technically the
field is not empty, but for all practical purposes it is.

2. An example of an even more serious problem is what happens if you
blank out the domain name field of a site with spaces.  Then you
cannot even select the site from the list  to edit it.  There is no
way to correct the error through normal procedures.

3.  In another situation, it  causes confusion on field errors.
Consider an email field that is not required, but must be valid if it
is entered.  If the user enters an email address, then blanks it out
with spaces, or just leaves one space before saving , he or she will
get an error message to enter a valid email.  This is very confusing,
not to developers of course, but to others.  They see an error message
to enter a valid email on a field that is not required, and the field
appears to be blank.

4. It also results in unwanted leading and trailing spaces.  In most
use cases, you don't want leading or trailing spaces in a char field
and URL field, an email field, etc.

I know this has been discussed before, but I hope this ticket can be
reopened,  and that stripping white space can at  least be an option.
I'm sure there are use cases where leading and trailing white space is
significant, but  in most use cases,  not stripping white space causes
usability issues that I  feel compelled to address one way or another.

This is not just theoretical - I have seen  parallel  problems in past
applications during usability testing and with customer support.

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



Re: SQL Relay

2008-07-04 Thread Dave Pederson

http://groups.google.com/group/django-users/browse_frm/thread/21ecac21fcbcd0af/6a50bf1c98c4b6c4#6a50bf1c98c4b6c4

Doesn't look like its reliable really.

On Jul 3, 10:54 pm, Dave Pederson <[EMAIL PROTECTED]> wrote:
> Has anyone out there used django with a database load balancer like
> sqlrelay?  Is it even feasible?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---