Open Django Central - June 8/9

2012-05-08 Thread Steve Holden
OK, anyone want to help build the broader Django community? Open
Django Central is on June 8 and 9 - http://opendjango/central/ the
registration site is open and the hotel is taking reservations at an
amazingly low rate if you are flying in from elsewhere.

Chicago locals please note I am flying in to talk to the Chicago
Djangonauts Spring Meetup on Wednesday May 16th - they live over on
the django-chicago Google group - and hope to see you there to swell
their numbers! I'll be taking input about the event there, and will be
happy to hear your ideas to make it even better.

regards
 Steve

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



Open Django East

2012-04-22 Thread Steve Holden
I realize it is way past time I publicized this conference to the
Django users group - sorry for the omission. Open Django is a series
of three conferences, so we hope to have at least one that's
reasonable for you to travel through.

  http://opendjango.com/

There's less than a month to go now, and it would be encouraging to
see more registrations!

regards
 Steve

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



Re: Django (and Python) speakers

2012-02-08 Thread Steve Holden
We can ask, I suppose. I understood that one of the reasons he didn't
make the last DjangoCon US was our tardiness in putting the schedule
together. I don't know what other factors may have played into that
decision. The speaker expenses bill would, of course, be high ...

regards
 Steve

On Feb 7, 9:30 pm, Jeremy Dunck  wrote:
> I'd also like to see Malcolm again, but I fear that'll take a trip to Sydney. 
> :)
>
>
>
>
>
>
>
> On Tue, Feb 7, 2012 at 9:29 PM, Jeremy Dunck  wrote:
> > The original musketeers, Jacob, Simon, and Adrian, are all great
> > speakers, of course.
>
> > I thought Jeff Balough, Mike Malone, and Eric Florenzano did very well
> > on their talks.  David Cramer represents Disqus well and has recently
> > released Sentry 2.
>
> > As a particular pain points for me, I'd like to hear from someone
> > using MySQL and Django at scale. Similarly, a walkthrough of how to
> > work with celery under evented IO would be useful.
>
> > Coverage of puppet (my preference) or Chef would also be interesting.
>
> > PyPy deserves attention as well as the general progress towards Python 3.
>
> > I'd like to hear Jeff Croft talk about design and open source.
>
> > I fear I've given too many topics, but there you go. :)
>
> > On Tue, Feb 7, 2012 at 5:00 PM, Steve Holden  wrote:
> >> I don't know if readers have heard the news that PyCon has closed
> >> registration early because it is full. So you may be interested in six
> >> new conferences, three about Python and three about Django, that we
> >> have just announced:
>
> >>  http://www.prweb.com/releases/2012/1/prweb8945991.htm
>
> >> With this announcement I would like to solicit suggestions for
> >> speakers. Who do you think does an excellent job of covering their
> >> material? Whom do you enjoy hearing? Who has information you need. The
> >> conferences will be two-day single-track events, and besides having
> >> guest speakers we will also be including some talks submitted by the
> >> community. So we'll be trying to retain the "community" feel of
> >> DjangoCon and PyCon.
>
> >> Amy other ideas for speakers or other activities please get in touch!
>
> >> regards
> >>  Steve
>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Django (and Python) speakers

2012-02-08 Thread Steve Holden
Thanks for your ideas!

On Feb 7, 9:29 pm, Jeremy Dunck  wrote:
> The original musketeers, Jacob, Simon, and Adrian, are all great
> speakers, of course.
>
Indeed, though they are all so busy we can't rely on them having time
to speak to us.

> I thought Jeff Balough, Mike Malone, and Eric Florenzano did very well
> on their talks.  David Cramer represents Disqus well and has recently
> released Sentry 2.
>
Thanks.

> As a particular pain points for me, I'd like to hear from someone
> using MySQL and Django at scale. Similarly, a walkthrough of how to
> work with celery under evented IO would be useful.
>
The Django crowd seems to prefer PostgreSQL collectively, but I know
there are a million sites out there using MySQL, so that would
probably resonate with people. Sort of the "frank Wiles of the mySQL
world"?

> Coverage of puppet (my preference) or Chef would also be interesting.
>
It's almost starting to be there are as many deployment systems as web
frameworks!

> PyPy deserves attention as well as the general progress towards Python 3.
>
I agree that the convergence of Python 3, Django and PyPy is an
exciting prospect. Few better qualifies to speak on that topic than
Alex Gaynor, I'd have said.

> I'd like to hear Jeff Croft talk about design and open source.
>
> I fear I've given too many topics, but there you go. :)
>
Hey, I asked! Thanks again for your enthusiastic input!

regards
 Steve
>
>
>
> On Tue, Feb 7, 2012 at 5:00 PM, Steve Holden  wrote:
> > I don't know if readers have heard the news that PyCon has closed
> > registration early because it is full. So you may be interested in six
> > new conferences, three about Python and three about Django, that we
> > have just announced:
>
> >  http://www.prweb.com/releases/2012/1/prweb8945991.htm
>
> > With this announcement I would like to solicit suggestions for
> > speakers. Who do you think does an excellent job of covering their
> > material? Whom do you enjoy hearing? Who has information you need. The
> > conferences will be two-day single-track events, and besides having
> > guest speakers we will also be including some talks submitted by the
> > community. So we'll be trying to retain the "community" feel of
> > DjangoCon and PyCon.
>
> > Amy other ideas for speakers or other activities please get in touch!
>
> > regards
> >  Steve
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Django (and Python) speakers

2012-02-07 Thread Steve Holden
I don't know if readers have heard the news that PyCon has closed
registration early because it is full. So you may be interested in six
new conferences, three about Python and three about Django, that we
have just announced:

  http://www.prweb.com/releases/2012/1/prweb8945991.htm

With this announcement I would like to solicit suggestions for
speakers. Who do you think does an excellent job of covering their
material? Whom do you enjoy hearing? Who has information you need. The
conferences will be two-day single-track events, and besides having
guest speakers we will also be including some talks submitted by the
community. So we'll be trying to retain the "community" feel of
DjangoCon and PyCon.

Amy other ideas for speakers or other activities please get in touch!

regards
 Steve

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



Bumper DjangoCon this year

2011-08-23 Thread Steve Holden
Early signs were that we would comfortably break the 255 limit we had to
place on last year. This year, with the change of venue, we can accommodate
more delegates. Just as well, because today the attendance went past the 300
mark with two weeks still to go!

Thanks to everyone who is supporting DjangCon so magnificently. For those of
you who are going, I look forward to seeing you there.

regards
 Steve
-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-23 Thread Steve Holden
And, as luck would have it, the US Call For Papers was just published:

  http://djangocon.us/blog/2011/06/22/call-papers/

regards
 Steve

On Wed, Jun 22, 2011 at 9:37 AM, Shawn Milochik  wrote:

> Cal,
>
> That sounds awesome. I wish you could present it at DjangoCon US too. :o/
>
> Shawn
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>


-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



DjangoCon US 2011: Call for Tutorial Proposals

2011-06-02 Thread Steve Holden
The DjangoCon US team is looking at running half-day tutorials for the first
time this year. We are therefore seeking proposals from well-qualified
speakers who would like to present tutorials on Monday, September 5. This
year we anticipate running at most four tutorials, though that number may be
exceeded if sufficient popular proposals are received. There is no
restriction on the topics that can be offered. Tutorial presenters will
receive a fee proportional to the size of their registered audience.

Selection will be by popularity: places at a maximum of ten tutorials
selected by the organizers will be offered for sale, and those attracting
most sales will run. Anyone who has subscribed to a non-running tutorial
will be offered a free transfer into the tutorial of their choice (subject
to availability) or a refund of their tutorial fees.

Since the conference web site has not yet been deployed please send your
proposals to steve at holdenweb dot com. I will also be happy to receive
suggestions from non-authors about the topics people would like to see
offered, either in reply to this email or to the address above.

regards
 Steve
-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django 1.1 performance versus django 1.2 performance

2011-05-03 Thread Steve Holden
Don't know whether this is relevant or not but the Python Software
Foundation has just decided to establish a facility that allows speed
comparison of different Python releases. The thinking behind this is (at
least) twofold:

1) People will more easily be able to determine which is the best Python
implementation for them to use on their specific problems, and

2) Developers will be able to see relatively easily whether their changes
make a positive or negative difference to performance, which /might/ help
eliminate the performance sawtoooth (gets worse with a major release and
then minor releases incre,entally improve it).

I don't know whether we can share our shiny new hardware with anyone else,
though ;-)

regards
 Stefe

On Sat, Apr 23, 2011 at 1:19 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> > On Fri, Apr 22, 2011 at 9:22 PM, Shawn Milochik 
> wrote:
> >>
> >> This was mentioned in Eric Florenzano's talk at DjangoCon 2010. Each
> >> version has gotten slower.
> >>
> >> I haven't heard anything about the cause or plans to fix this, though.
> >> If you've got a good test suite you can always use tools like Python's
> >> profile module to track down slowdowns in your Django code and
> >> contribute that knowledge to the developers' list.
> >>
>
> On Sat, Apr 23, 2011 at 11:26 AM, Peter Portante
>  wrote:
> > Is there a plan in place to address this?
>
> No - there isn't a plan to address this, because it isn't clear what "this"
> is.
>
> While it is known that there has been a slowdown between versions,
> that slowdown has been accompanied by a massive increase in
> functionality -- for example, the 1.1->1.2 transition introduced
> support for multiple databases. To the best of my knowledge, the
> performance slowdown highlighted by Eric at Djangocon was relatively
> small - 5-10%, not on the order of 30-50% slowdown. This matches with
> my personal experience of upgrading.
>
> There are two performance issues in database operations that I'm aware
> of that people commonly point to.
>
> Firstly -- deep cloning of query sets. Cloning a queryset is an
> expensive operation, and if you are making extensive use of operations
> that clone (e.g., very long chains of complex filters) you may see
> performance issues. This isn't something that can be easily avoided --
> in order to preserve the API guarantees of a query set, deep cloning
> is required.
>
> Secondly, the backwards compatibility infrastructure introduced in
> order to support multiple databases. In order to guarantee backwards
> compatibility, the value preparation methods on fields needed to use
> some moderately expensive introspection methods. However because these
> methods were introduced for 1.2, and we're currently preparing 1.4,
> these introspection methods have just been removed from trunk.
>
> Beyond these two issues -- we're always interested in improving
> performance, so if you can identify a specific performance issue,
> we're happy to look at it. The more evidence you can provide (profile
> runs, sample queries that are observably slower, and so on), the
> easier it will be to address these problems.
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: DjangoCon US 2011

2011-03-31 Thread Steve Holden
I have already started nagging people about this. It's only just over five
months to go, and it's definitely time the CfP went out. Expect to see
movement in the next two weeks.

Regards
Steve
On Mar 31, 2011 6:19 PM, "Shawn Milochik"  wrote:
> It's a bit early, in the year, but I'd expect something in the next
> couple of months here:
>
> http://djangocon.us/
>
> Since it's not till September there's still plenty of time.
>
> That said, if @holdenweb is reading this -- any updates? ^_^
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: django-admin-py?

2011-03-19 Thread Steve Holden
Last I looked (though it's been a,while) the Django install dropped
django-admin.pt somewhere on the executable path. How did you install
Django?

Regards
Steve
On Mar 17, 2011 5:05 PM, "gh"  wrote:
> Hi
>
> I´m new to django and maybe this is a simple thing but I need some
> advise what's wrong.
>
> I try to create a project and I have moved the dajango-admin.py to the
> Python bin folder but I allways get this result when I´m typing the
> following and even if I try django-admin.py --version
>
>
> C:\DjangoProject\djangotest>django-admin.py startproject djangotest
>
>
> Usage: django-admin.py subcommand [options] [args]
>
> Options:
> -v VERBOSITY, --verbosity=VERBOSITY
> Verbosity level; 0=minimal output, 1=normal
> output,
> 2=all output
> --settings=SETTINGS The Python path to a settings module, e.g.
> "myproject.settings.main". If this isn't
> provided, the
> DJANGO_SETTINGS_MODULE environment variable
> will be
> used.
> --pythonpath=PYTHONPATH
> A directory to add to the Python path, e.g.
> "/home/djangoprojects/myproject".
> --traceback Print traceback on exception
> --version show program's version number and exit
> -h, --help show this help message and exit
>
> Type 'django-admin.py help ' for help on a specific
> subcommand.
>
> Available subcommands:
> cleanup
> compilemessages
> createcachetable
> dbshell
> diffsettings
> dumpdata
> flush
> inspectdb
> loaddata
> makemessages
> reset
> runfcgi
> runserver
> shell
> sql
> sqlall
> sqlclear
> sqlcustom
> sqlflush
> sqlindexes
> sqlinitialdata
> sqlreset
> sqlsequencereset
> startapp
> startproject
> syncdb
> test
> testserver
> validate
>
> C:\DjangoProject\djangotest>
>
>
> Regards
> glenn
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: django advent for 1.3

2011-02-02 Thread Steve Holden
:-)

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



Re: django/contrib/auth/models.py goes nuts

2010-12-23 Thread Steve Holden
On 12/23/2010 11:54 AM, John Fabiani wrote:
> On Thursday, December 23, 2010 12:39:44 am bruno desthuilliers wrote:
>> On 23 déc, 06:33, John Fabiani  wrote:
>>
>> (snip)
>>
>> John, may I suggest that instead of trying whatever comes to mind and
>> wonder what happens, you spend some times learning Python, specially
>> the part about modules, import and the modules search path ? Your
>> problem - which has nothing to do with Django BTW - is obviously that
>> something in your PYTHONPATH shadows the stdlib modules. Launch an
>> interactive django / python shell ("./manage.py shell" command in your
>> terminal), then execute the following code:
>>
>> import sys
>> print "\n".join(sys.path)
>> import datetime
>> print datetime
>>
>> This should tell you where your modules are searched for by Python,
>> and where your datetime module is actually imported from.
> 
> You can do more than suggest.  I learn daily.  And so today I learn where and 
> how to determine where/which module is used for an import.  
> 
> But still your suggestion does not solve the issue at hand.  Your code reports
> import datetime
 print datetime
> 
> 
> I believe that is the correct datetime module which explains nothing!  Most 
> important in my mind is how did anything I did cause a difference!  
> 
> 1. I changed the way I import-ed datetime in my views.py.  Just a simple name 
> change on the theory that somewhere I had re-defined datetime.  I also 
> removed 
> two un-used imports.  At first I thought they might have been an issue but I 
> could not see where they conflicted with anything and it did nothing to 
> change 
> the error.
> 
> 2. Deleted the django models.pyc (note the pyc).  On the theory that some how 
> the file was corrupt.
> 
> 3. Rebooted the Linux box.  I hated to do this act.  In the past I have 
> always 
> found ways around rebooting a linux box.  
> 
> But suddenly everything started working again!
> 
> But let's assume you are correct I had added some sort of conflicting module. 
>  
> BTW that was my thought almost immediately!  I changed the code causing the 
> immediate error with the following (used only for testing):
> 
> try:
>now = datetime.datetime.now()
> except:
>   import datetime
>   now = datetime.datetime.now()
> 
> But suddenly I got a second error from the password method and again the 
> error 
> was  'None' has no Attribute   The problem with that error was everything 
> in the password method is contained in the same module.  So if it did not 
> require anything outside of the module how could it be 'None'.  All these 
> errors from the same module (models.py).  
> 
> All of this has me very concerned because I was about to deploy  (after all 
> the website has been tested for the last two weeks).  I do believe this has 
> something to do with my code (I believe there had to be some sort of conflict 
> - but where).
>   
> But as to your statement this has nothing to do with Django I can NOT agree.  
> Like all programs Django should protect it's modules and do everything they 
> can to insure the correct access to the correct imports.  All frameworks need 
> to protect their code.  Yes it true it is hard to protect against someone 
> willing to shoot them self's in the foot.  But some effort is still required!
> 
> Johnf
> 
John:

I know it's disturbing when computers appear to behave in a
non-deterministic way. Perhaps when the system is failing you could copy
and paste the whole traceback?

Your original statement of the problem is far from clear. You said:

"""
The error first appeared as datetime has no Attribute 'None' for a line
in my
views.py
user = User.objects.create_user(c.registration_id, c.email,
request.POST['txtPassword'])

The error was from in django/contrib/auth/models.py
now = datetime.datetime.now()
"""

Presumably that line appeared in the traceback but was only the
*indirect* cause of the failure? You don't say *which* line number that
line is from the django.contrib.auth.models.py, let alone which function
or method was active when the exception occurred. While there are many
fine minds in this group you aren't really giving them much of a chance
to help you.

With more information someone might not only be able to diagnose the
error but also to help you avoid it.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: Custom SQL questions

2010-12-19 Thread Steve Holden
On 12/19/2010 3:48 PM, Maksymus007 wrote:
> you get array of arrays.

Technically, in strict Python terms what you get is a list of tuples.

Each element of the list is a tuple where each column from the query
provides an element of each tuple.

> First array contains rows. Every row is just an array of fields, order
> is the same as in your query.
> 
> On Sun, Dec 19, 2010 at 9:45 PM, Andy  > wrote:
> 
> I need  to execute some SQL queries involving joins and it seems like
> custom SQL is the way to go. A couple of  questions:
> 
> 1) In the doc  (http://docs.djangoproject.com/en/1.2/topics/db/sql/
> #executing-custom-sql-directly
>  #executing-custom-sql-directly>) there's an example:
> cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
> What is the "self.baz" argument? What does it do?
> 
That is just to show how to put data into your queries to parameterize
them. The first argument to .execute() is a query string with parameter
marks inside it (the parameter mark can be something other than "%s" but
I believe that works for both PostgreSQL and MySQL.

The second argument should be a sequence (I use a tuple, as some
database drivers insisted on that in the past) of data elements that
will be used to replace the parameter markers.

> 2) After I execute a SELECT query, how do I access the different
> fields and different rows of the results?
> 
See above. After you have called the cursor's .execute() method you then
have to call a method the fetch the data. Most people will use the
.fetchall() method, but there is also .fetchone() (that returns a single
tuple containing the data for the next row in the result) and
.fetchmany(N), which returns N rows if that many are left, otherwise all
remaining rows.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: registering app level signal handlers

2010-12-16 Thread Steve Holden
On 12/16/2010 6:28 PM, Graham Dumpleton wrote:
> Are you talking about UNIX process signals?
> 
He's almost certainly talking about Django signals.

I've never seen a definite recommendation as to how to do things exactly
once early on in the life of your server process, so I am afraid I
cannot offer any advice.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: Help for for loop

2010-12-10 Thread Steve Holden
On 12/9/2010 12:24 PM, Cal Leeming [Simplicity Media Ltd] wrote:
> Uh, you *might* be able to use:
> 
> {% for x in mylist %}
> {% if x % 2 %}
> yay: {{x}}
> {% else %}
> nay: {{x}}
> {% endif %}
> {% endfor %}
> 
Blerch! This is a really good indication of why it's much better to
perform the appropriate translations in the view.

regards
 Steve

> On 09/12/2010 11:18, Phani Chand wrote:
>> Can i use   filter(lambda x: x%2, mylist) directly in my html page --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.


-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: django to php

2010-11-30 Thread Steve Holden
On 11/30/2010 9:15 PM, Kenneth Gonsalves wrote:
> On Tue, 2010-11-30 at 13:53 -0500, CLIFFORD ILKAY wrote:
>>> I have a webapp created in django. Now I want to convert the entire
>>> code into PHP. Is it possible?? If yes, how?
>>
>> I have a Porsche that I'd like to trade for an ox cart. Any takers? 
>> Seriously, why would you want to do that? 
> 
> well, if you are in a location where there is no one to maintain your
> Porsche and has a surfeit of ox cart drivers ...

Except, of course, that a thousand oxen can't travel at two thousand
miles an hour. So there's no way to get "equivalent" performance. In
most places I suspect the oxen would be more useful. The more so as the
oil disappears.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: If logged in show X, if not Y

2010-11-28 Thread Steve Holden
On 11/28/2010 6:50 PM, robos85 wrote:
> Hi,
> I've read about {% if user.is_authenticated %} and m template is going
> to have the same structure, but some block will have different content
> for logged users. Additionally there will by some more buttons.
> I wondered if there's some other way to divide it.
> By no I have that plan:
> define 1 mainframe template. In it I'll include some sub-templates. In
> that sub-templates I'll make {% if user.is_authenticated %} and
> include the destination template or do the stuff.
> 
> Is this plan ok?

It seems like a perfectly sensible plan to me. You will probably find
that you can define a hierarchy of templates, with the basic look and
feel provided by the top-level templates.

Sub-templates aren't always necessary.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: WEB SERVICE IN DJANGO USING ZSI

2010-11-27 Thread Steve Holden
On 11/27/2010 10:37 AM, sami nathan wrote:
> But i am not havin python intreptor i use my command prompt this way
> Microsoft Windows [Version 6.1.7600]
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
> 
> C:\Users\ezhil>python
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on 
> wi
> 32
> Type "help", "copyright", "credits" or "license" for more information.
 wsdl2py --extende --file=D:\soap\FlyppSms.wsdl
>   File "", line 1
> wsdl2py --extende --file=D:\soap\FlyppSms.wsdl
>   ^
> SyntaxError: invalid syntax

> shouldn't i use this way
> 
No. You typed "python" at the command line. You need, probably, to type

wsdl2py --extende --file=D:\soap\FlyppSms.wsdl

at the command line.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: PIL issue opening an image file

2010-11-26 Thread Steve Holden
On 11/26/2010 9:58 AM, Sithembewena Lloyd Dube wrote:
> Thanks for breaking this down, Tom. I'll play around with it and see if
> I'm grasping this.

For the record, while it might have seemed to you that Bruno was being
"snooty", in fact he was probably (I have no direct evidence) simply
crediting you with more knowledge than you actually had.

Misunderstandings can be frustrating, and we all give in to the
frustration sometimes.

regards
 Steve
-- 
DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/

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



Re: Static files ...

2010-11-21 Thread Steve Holden
On 11/21/2010 10:52 AM, jonno wrote:
> I think I'm getting there, and thanks Steve! I've switched my
> directory structure around a bit, but I'm now able to make changes
> with predictable results.  Still no image, however, but I can't be too
> far off.  I'll return to the context processor thing as soon as I see
> an image.  I now have:
> 
> STATICFILES_ROOT = '/Users/jonno/django_projects/MCOt/static/'
> 
> My template calls:
> 
> 
> 
> and Chrome reports:
> 
> Request URL:http://localhost:8000/static/imgs/cellohome.jpg
> 
> This seems correct, but it's still a 404.  Thanks again --  Jon.

You say it "seems correct", but if it's a 404 have you actually set
Django or another web server to serve those files?

http://docs.djangoproject.com/en/dev/howto/static-files/

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: A Model to store links to other models

2010-11-19 Thread Steve Holden
On 11/19/2010 8:51 PM, Micah Carrick wrote:
> I'm having trouble coming up with a pretty solution to a seemingly
> simple task. I'm relatively new to Django.
> 
> I want to allow the end user to control various lists of links on the
> site used for navigation. The admin should allow the creation of "link
> groups" which have a collection of "links". These links would reference
> a pre-determined list of models. Let's say, for example, that there is a
> "link group" created for the footer links of a website. In the admin
> section, a user could add a link to a specific blog (from the Blog
> model), another link to the about us page (flatpages), etc.
> 
> In other words, I'm trying to associate individual records from a number
> of tables together as a group of objects having a URL. I'm trying to
> find a nice, abstract solution. Obviously I don't want actual URLs in
> the database. This is something I would use frequently so I want to see
> if I can find or write an app to do this--if I can come up with an
> elegant solution.
> 
> This would be nice, but, I can't imagine how it could be possible:
> 
> 
> class LinkGroup(models.Model):
> site = models.ForeignKey(Site)
> name = models.CharField()
> 
> class Links(models.Model):
> link_group = ForeignKey(LinkGroup)
> model_type = ???
> model_id = ForeignKey() # no
> can do!
> sort_order = PositiveIntegerField(default=100)
> 
> 
> This is an idea, however, I don't like having to reference the import in
> the DB. It's just begging for problems.
> 
> 
> class LinkModel(models.Model):
> name = models.CharField() # such as "Flat Page"
> model = models.CharField() # such as "myapp.models.FlatPage"
> 
> class LinkGroup(models.Model):
> site = models.ForeignKey(Site)
> name = models.CharField() # such as "Navigation Links"
> 
> class Link(models.Model):
> text = CharField() # such as "About Us"
> link_group = ForeignKey(LinkGroup)
> model = ForeignKey(LinkModel)
> model_id = PositiveIntegerField() # such as the PK for the
> myapp.models.FlatPage model
> sort_order = PositiveIntegerField(default=100)
> 
> 
> Any suggestions?
> 
What's wrong with the first approach? I use a similar technique to put
pages in sections at http://holdenweb.com/ - here are the relevant models:

class Section(models.Model):
secid = models.IntegerField(primary_key=True) # This field type is
corrected
sectitle = models.CharField(max_length=50)
secpath = models.CharField(max_length=50)
secbgcolor = models.CharField(max_length=50)
secstcolor = models.CharField(max_length=50)
secpos = models.CharField(max_length=1)
secsequence = models.IntegerField() # This field type is corrected
sechandler = models.CharField(max_length=50)
sechomeslot = models.IntegerField() # This field type is corrected
sechometitle = models.CharField(max_length=50)
secnews = models.CharField(max_length=20, null=True)
class Meta:
db_table = 'section'
unique_together = (('secpath', ), ('sectitle', ))
class Admin:
list_display = ('sectitle', )
def __str__(self):
return self.sectitle

class Page(models.Model):
pagpath = models.CharField(primary_key=True, max_length=50)
pagdoctitle = models.CharField(max_length=250)
pagtitle = models.CharField(max_length=200, blank=True, null=True)
pagsecid = models.ForeignKey(Section, blank=True, null=True,
db_column='pagsecid') # This field
type is corrected
pagsequence = models.IntegerField() # This field type is corrected
pagtplname = models.CharField(max_length=50)
paggenerated = models.SmallIntegerField()
paglinkpath = models.CharField(max_length=50, blank=True, null=True)
pagcontent = models.TextField()
pagnavbarstuff = models.TextField(null=True, blank=True)
pagctype = models.CharField(max_length=1, default="R") # This field
type is corrected
pagid = models.IntegerField() # Note this should eventually become
the PK
pagnews = models.CharField(max_length=20, blank=True, null=True)
class Meta:
db_table = 'page'
def __str__(self):
return self.pagpath

What is it that the first model didn't do for you?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Models not being updated when accessed by multiple processes

2010-11-19 Thread Steve Holden
On 11/19/2010 5:35 PM, Iqbal Abdullah wrote:
> Hi,
> 
> This might be a gotcha on the models side, but I would like
> clarification and guidance on how to write the code better concerning
> multiple process accessing the same data via models.
> 
> I have a backend script that runs the following code in multiple
> processes:
> 
> 1 object = MyModel.object.get(id=1)
> 2 print object.value# starting value is 5
> 3 while object.fail_to_get_lock():
> 4sleep(5)
> 5 object = MyModel.object.get(id=1)  # Re-get the object so we can
> have the latest state
> 6 object.value = object.value - 1
> 7 print object.value# returns 4
> 8 object.release_lock()
> 
> If the above code fails to get the lock because another process is
> running the code, it goes to sleep until the other process finishes.
> The other process will also be decrementing object.value, so if we
> have 2 processes running the above script at the same time, I would
> expect the later process to return line 7 as 3 and not 4.
> 
Shouldn't some saving occur for that to be true?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Static files ...

2010-11-19 Thread Steve Holden
On 11/19/2010 1:56 PM, jonno wrote:
> And I have:
> 
> {% load staticfiles %}
> {% get_staticfiles_prefix as STATIC_PREFIX %}
> 
> at the top of my template.  Sorry to trouble all with this again!
> Thanks for any help -- Jon.

PS: You might want to consider injecting STATIC_PREFIX into your
contexts with a context processor. That way it happens without any need
for template code.

In particular, see

http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-static

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Static files ...

2010-11-19 Thread Steve Holden
On 11/19/2010 1:56 PM, jonno wrote:
> Hello,
> 
> Sorry not to have replied for so long, but I thought I'd better just
> try and dig through it!  In the meantime, I have upgraded to Django
> (1, 3, 0, 'alpha', 1) and follow the instructions in the development
> documentation.  I am just trying to serve my static files for
> development purposes, but no matter what I do, I get 404s for my image
> and css files.  Google Chrome reports:
> 
> Request URL:http://localhost:8000/static/%20/admin/img/images/
> cellobutton.jpg
> 
> with that strange %20 in the middle of my link, which seems to relate
> to the curly braces in my link:
> 
> 
> 
Bingo! (I hope).

Try



regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: OT: getting strange attempted gets

2010-11-16 Thread Steve Holden
On 11/16/2010 10:52 AM, Scot Hacker wrote:
> On Nov 15, 8:45 pm, Steve Holden  wrote:
>>
>> Perhaps he did, but that's no reason to believe him until we know that
>> his assessment of the situation  is likely to be realistic. Don't forget
>> that a lot of people who post here aren't particularly experienced and
>> so may not appreciate exactly what's going on.
> 
> I dunno. When you sit there watching runserver registering hits on
> bizarre URLs and you know you're not the one clicking through the test
> site, it's pretty obvious that something else is going on.
> 
But until we've seen the URLs we have no idea whether they really are
unrelated, do we?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: OT: getting strange attempted gets

2010-11-15 Thread Steve Holden
On 11/15/2010 12:03 PM, Scot Hacker wrote:
> On Nov 14, 11:25 am, Federico Capoano 
> wrote:
>> > No one is attacking your server, that's just the django server telling
>> > you what's going on in your app (when you perform any action the
>> > server logs it).
> Right, but he said he's seeing requests that *can't* be explained by
> his own requests.
[...]

Perhaps he did, but that's no reason to believe him until we know that
his assessment of the situation  is likely to be realistic. Don't forget
that a lot of people who post here aren't particularly experienced and
so may not appreciate exactly what's going on.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Automatically assume "models." prefix in models.py

2010-11-14 Thread Steve Holden
On 11/13/2010 11:20 PM, James wrote:
> Forgive a django newbie...
> 
> Maybe I'm the laziest person in the world, but sometimes I get tired
> of typing "models.WhatEver" for every single model I have to write. Is
> there anyway a shortcut could be added that would 'assume' the
> 'models.' prefix when I am defining a model?
> 
> e.g. instead of:
> 
> class SomeModel(models.Model):
> something = models.SomeField(someoption=something)
> # some other things
> 
> Could a shortcut be added so that I can write:
> 
> class SomeModel(models.Model):
> something = SomeField(someoption=something)
> # some other things
> 
> 
> 
> I realized that not everything I will write will have the "models."
> prefix, but I think _most_ of what I write in models.py will have it.
> 
> So... I'm a being too lazy, or perhaps just stupid?
> 
You can import names individually from a module. In your examoke you
would do this:

from models import Model, Somefield, OtherField

class SomeModel(Model):
something = SomeField(someoption=something)

and so on.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Create User from an User extension

2010-11-12 Thread Steve Holden
On 11/12/2010 1:31 PM, Karim Gorjux wrote:
> Hi all, I successfully extended the User as described in the
> authorization documentation. Now I would like to use and edit the User
> and my class Persona not like two entity but just one.
> 
> When I want to create a Persona, I have also to create a User first.
> Now the steps are too long, how I can create an admin.TabularInline?
> I tried this:
> 
> class UserInline(admin.TabularInline):
> model = User
> 
> class PersonaAdmin(admin.ModelAdmin):
> inlines = [
> UserInline,
> ]
> 
> But when I try to add a Persona I get the exception "has no foreign key"
> 
> I guess I have to do the reverse add an PersonaInline to the
> UserAdmin, but I'm a little confused.
> 

It's logical enough when you think about it. Your Persona model
definition probably includes a foreign key into User to construct a
one-one relationship between them. While it would work equally well from
a database point of view to have the foreign key in User that would
require changes to the User model, which would not be helpful in other
contexts.

When you add a Persona the UserInline lets you enter a User record, but
the User has to be saved before the Persona. You could do this by
extending the Persona.save() method to save the User as well.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django 1.3 alpha 1 released

2010-11-11 Thread Steve Holden
On 11/11/2010 5:04 PM, Russell Keith-Magee wrote:
> It won't be 100% frozen until the final release

Shouldn't that be "first beta"?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Steve Holden
On 10/26/2010 12:40 PM, Phlip wrote:
> Note that "isabelle_item" appears twice. We are following the auditing
> rule "always write new records to change data - never edit previous
> records". Someone edited isabelle_item's payload data (not shown), so
> we add a new record without touching the existing record.

I hope the auditors are only forcing you to do this with records that
aren't referenced as part of relationships, otherwise your database is
going to get hammered updating all the foreign keys.

Wouldn't it make more sense (not that auditors will necessarily be
persuaded by sensible arguments) to dump a copy of a row (plus possibly
a timestamp field) to an archival table before update? This coild easily
be done on a pre-save signal ...

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: how to use tkinter widget in django

2010-10-26 Thread Steve Holden
On 10/26/2010 8:50 AM, jimgardener wrote:
> thanks for the replies..
> I am wondering if javascript is the only alternative if I want to use
> such a custom widget.
> If anyone knows about any such python widget please tell me..
> regards
> jim
> 
Jim:

The reason you can forget using Python is that Python isn't available on
the browser. You have to deliver content from Django that the user's
browser can execute, and that isn't likely to include Python in most cases.

  http://www.learnthenet.com/learn-about/how-the-web-works/

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: how to use tkinter widget in django

2010-10-26 Thread Steve Holden
On 10/26/2010 7:17 AM, jimgardener wrote:
> is it possible to use the sliderlike Scale widget from tkinter in
> django?I am coding a web app where I need to get a numerical value
> entered by the user.I thought ,instead of asking the user to enter a
> value in a textfield ,I would provide a slider which he can move
> between the minimum and maximum values.
> Originally I designed the model and form like this
> 
> class MyModel(django.models.Model):
> user_enrty=models.IntegerField()
> 
> class  MyModelForm(django.forms.ModelForm):
> class Meta:
> model=MyModel
> 
> In tkinter ,I can create a scale widget like
> master = Tk()
> w = Scale(master, from_=0, to=100)
> w.pack()
> and get the current position using w.get()
> 
> How can I use this in django?Can I directly put the tkinter widget in
> my model like ,
> class MyModel(django.models.Model):
> user_enrty=tkinter.Scale(...)
> 
Unfortunately you cannot do this. Tkinter assumes direct control of the
desktop, whereas Django is a web system that must use HTML (or similar)
to deliver markup to the user's desktop using HTTP. Tkinter just isn't a
web technology.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: What does an ideal django workflow setup look like?

2010-10-24 Thread Steve Holden
On 10/25/2010 2:02 AM, Kenneth Gonsalves wrote:
[shacker]
>> Another approach to this problem:
>> 
>> settings.py IS in version control and includes settings
>> that are universal to all environments (local dev, staging,
>> production), but has dummy info or empty strings for
>> passwords or paths or other information that vary between
>> environments.
> this is a better approach - much more professional (I *did* say I
> am an amateur;-))

A technique I use, having picked it up from Jacob Kaplan Moss, IIRC, is
to keep settings.py under source control but have it include as its last
statement

from local_settings import *

The local_settings.py file is then maintained outside source control on
each target platform. This works very nicely, and allows you to maintain
common settings without having to edit a file that's under code control
to vary settings between platforms.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: call more than one view action from an uri path?

2010-10-21 Thread Steve Holden
On 10/21/2010 2:24 PM, ringemup wrote:
> #urls.py
> #note: untested regex, but a regex should be able to do this
> url('^((\w+)/(\d+)/)+$', 'myview', ...)
> 

Oops. I omitted to point out (though the OP picked it up) that a
repeated group in a regex only leaves behind its last match in the match
object's groups. It's all going to get a bit painful trying to do this
with a urlconf.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: call more than one view action from an uri path?

2010-10-21 Thread Steve Holden
On 10/21/2010 2:24 PM, ringemup wrote:
> You can't do something like this?
> 
> #urls.py
> #note: untested regex, but a regex should be able to do this
> url('^((\w+)/(\d+)/)+$', 'myview', ...)
> 
> #views.py
> # note: this is pseudocode
> def myview(request, *args, **kwargs):
>   # iterate through args two at a time
>   for func, arg in args:

This, sadly, does not iterate over the arguments two at a time.

>>> for a, b in [1, 2, 3, 4]:
... print a, b
...
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not iterable
>>>

But you said it was pseudocode, so you are forgiven.

You could try something like:

args = iter(args)# may need args.__iter__() in earlier Pythons?
for func in args:
arg = next(args) # may need args.next() in earlier Pythons?
   ...

> if func in list_of_allowed_funcs:
>   func(arg)
>   return HttpResponse('whatever')
> 
regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: call more than one view action from an uri path?

2010-10-21 Thread Steve Holden
On 10/21/2010 9:36 AM, Phlip wrote:
> On Oct 21, 5:26 am, Scott Gould  wrote:
> 
>> What's your use case? Are "nest, pest and rest" always "nest, pest and
>> rest" -- or could they be "rest, pest and nest", or "nest, best, and
>> rest"?
> 
> Tx but - the use case is we can't do it like you said. C-:
> 
> The point is a REST path that can go arbitrarily shallow or deep
> without excessive code.
> 
REST, however, has a fairly rigid one-URL-one-action structure which is
ideally suited to Django's URL dispatch. The only way to get what you
want is to layer another dispatching service atop Django's. I don't
think you can do it with urlconfs alone.

> What I looked for was a lambda here (simplified):
> 
>   url( 'nest', lambda *a,**k: doit(a, k) )
> 
> but that terminates the lookup on the last item (rest), instead of
> calling the lambda on the way down!
> 
By the way, what are you imagining the functions nest(), pest() and
rest() will return? They cannot all return HTTP responses, since there
can only be a single response to a single request?

Perhaps a somewhat more detailed description of your requirements is in
order.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: /admin list help ASAP

2010-10-20 Thread Steve Holden
On 10/20/2010 11:55 PM, Mike Dewhirst wrote:
> On 21/10/2010 1:24pm, Bobby Roberts wrote:
>> hi all.  I have two models setup let's call them
>>
>> Gallery
>> Photos
>>
>> photos has a field as such:
>>
>> GalleryId = models.ForeignKey('Gallery', verbose_name=_('Gallery Id'),
>> related_name='Gallery_Id',blank=False, null=False, help_text=_("Please
>> choose the gallery to which you wish to associate this photo."))
>>
>> Ok now here's the question.
>>
>> In the listing page for my photos, I want to print Gallery.Title
>>
>> the two models are related on Photos.GalleryId=Gallery.Id
>>
>> How do I return Gallery title in the listing page in /admin?
>>
> 
> You can write a function in __unicode__() to display the two ...
> 
> def getGallery(self):
> pass # not sure how to get the Gallery title
> 
> def __unicode__(self):
> return u'%s: %s' % (self.getGallery,
> self.title)
> 
Shouldn't that be

def __unicode__(self):
return u'%s: %s' % (self.getGallery(),
self.title)

You actually have to _call_ the getGallery method.

Note that the __unicode__ and getGallery methods Mike describes should
be methods of your photos model.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: about site price

2010-10-20 Thread Steve Holden
On 10/20/2010 4:17 PM, Lic. José M. Rodriguez Bacallao wrote:
> hi folks, I have a client that need to develop a bet site like this:
> http://www.webapuestas.com/
> the problem is that I am new in the business and I don't know how much
> money can I ask for a
> this work, can someone help me and take a look to the site and give me
> an approximate cost for
> a site like this?
> 
> PS: sorry for my English, it's not so good.
> 
This really is a dangerous question.

First, you have to ask what it will cost you to develop. Do you have any
clear idea of that cost?

Next you have to ask yourself what it's worth to the customer.

If the second figure is lower than the first, stop right there.

I would seriously advise you not to undertake a large paid gig such as
building a betting site without first getting enough industry experience
and learning a lot more about building web sites than you apparently do
at the moment.

If you don't gain the experience, you risk exposing yourself to large
liabilities.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Displaying a template table using a query set

2010-10-20 Thread Steve Holden
On 10/20/2010 7:58 AM, Pranav wrote:
> 
> 
> On Oct 20, 4:13 pm, Daniel Roseman  wrote:
>> On Oct 20, 8:29 am, Pranav  wrote:
>>
>>
>>
>>
>>
>>> I'm trying to display a table in template using the result retrieved
>>> from a query set, but i get problem when i try to display the table
>>> iterating through each row'' and column''
>>
>>> view file:
>>> from django.shortcuts import get_object_or_404, render_to_response
>>> from models import Organization
>>
>>> def startpage(request):
>>> table_data = Organization.objects.all()
>>> return render_to_response('display_table.html', {'table_data':
>>> table_data})
>>
>>> display_table template file:
>>>   
>>> {% for row in table_data %}
>>> 
>>> {% for value in row %}
>>> 
>>> {{ row }}
>>> 
>>> {% endfor %}
>>> 
>>> {% endfor %}
>>> 
>>
>>> when i try to run this i get an error saying the object is not
>>> itreable for the second for loop. please provide a solution to this
>>> issue...
>>
>>> Thanks and Regards
>>> Pranav
>>
>> `value` is an Organisation instance, and model instances are not
>> iterable, as you could see by trying it in the shell.
>>
>> You could try passing a values_list instead of a queryset:
>> table_data = Organization.objects.all().values_list()
>> as these are iterable.
>> --
>> DR.
> 
> Hi Dan,
> Thanks for the fix it worked.
> I guess Organization.objects.all().values_list() returns a list.
> But what if i want to refer to a particular field say Organization.id
> inside my template?
> 
> like:
> 
> {% for row in table_data %}
>   
>   
>  {{ row.Organization.id }} 
>   
>   
> <% endfor %}
> 
> 
> I guess I'll have to pass another query set object to do this,
> will this have any effect on the throughput of the database?
> Is it possible to access cached result of the query set inside the
> template?
> 
The point is that normally you don't just want to iterate over the
columns of a retrieved row, since they have differences in meaning that
normally require differences in display formatting and the like as well.

Therefore the solution you offer above is more or less what you actually
do.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Different logins in same browser session and login_required

2010-10-20 Thread Steve Holden
On 10/20/2010 5:20 AM, PyMan wrote:
> 
> 
> On 20 Ott, 10:28, Daniel Roseman  wrote:
>> On Oct 20, 8:11 am, PyMan  wrote:
>>
 Firefox has long had its "profile" functionality.
>>
 firefox -no-remote -ProfileManager
>>
 You can create multiple firefox profiles, then run multiple instances of
 firefox at once - so long as you use different profiles for them.  A bit
 fiddly, but obviously useful for development/testing.
>>
>>> First of all thanks for your answers to both of you :)
>>
>>> Yeah, I know about FX profiles and I already knew it was a working
>>> solution, but it's not a good solution. I mean we're speaking about
>>> users that don't even know what a browser is. Telling them to do that
>>> is just mess.
>>
>> What's your case for getting end users to log in as two separate
>> profiles? If they're non-technical, they shouldn't have to be worrying
>> about this level of detail in any case. It's going to be confusing for
>> them no matter what you do.
>> --
>> DR.
> 
> It shouldn't happen, but it could. It's an office or it's a warehouse,
> people could work with the same user and/or (above all) people may
> work on the same machine...so they should pay attention on what they
> do...but even no.
> 
> Just an example when the problem can occurs:
> The djangoapp has more users, some of these have privileges to access
> the django-admin to change some user permissions
> 
> With just one opened browser window the user U1 (not superuser/staff)
> is logged on, then going on the django-admin (in a new window because
> the link opened there, or jsut the user opened a new window by himself
> or whatever) a login is required. Logging on with a different user,
> the first window still seems (especially when the whole application is
> ajax based) to use the U1 user and something of not expected (to the
> user) may occurs.
> 
> I understand it's normal, the end-user may not.
> 
In which case the solution is to instruct them not to share logins,
which they would have to do to experience those problems.

I agree it can be a pain when they do that, but if they are so
unsophisticated that they let two different users interact with the
system through a single login account they must expect trouble with
authenticated systems.

As is so often the case, education is the answer. And, as is so often
the case, the users would rather sacrifice security for convenience
(then make it the system designer's fault when they realize they can't
have both).

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: MaxValueValidator to validate a model

2010-10-18 Thread Steve Holden
On 10/15/2010 9:18 PM, refreegrata wrote:
> Now works.
> validators=[MaxValueValidator(Decimal('14.5'))
> 
> But I must to do an explicit declaration Decimal('14.5').
> 
> Somebody knows why?

Because only decimal numbers can give exact comparisons to arbitrary
decimal values. You would not want your input to validate correctly with
an entry of (say) 14.501, which might be possible if the
limit was expressed as a floating-point number.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Escaping text for raw SQL?

2010-10-12 Thread Steve Holden
On 10/12/2010 4:34 PM, Nick Arnett wrote:
> 
> 
> On Tue, Oct 12, 2010 at 9:00 AM, Javier Guerra Giraldez
> mailto:jav...@guerrag.com>> wrote:
> 
> On Tue, Oct 12, 2010 at 10:46 AM, Nick Arnett  > wrote:
> > Anybody know a good way to do this?
> 
> Words.objects.filter(foo__in=mylist)
> 
> 
> Didn't even occur to me to not use raw SQL for this, but I could...
> trouble is, I wanted this to be reusable in a way that will be clumsy in
> the ORM.  But maybe I'll go that route.  I'm using raw SQL for a lot of
> this because the ORM is way too slow for what I'm doing.
> 
In which case be *extremely* careful not to introduce SQL injection
vulnerabilities into your code. The safest way is to use parameterized
queries. Some back-ends will let you write (untested):

cursor.execute("SELECT foo, bar FROM proj_words WHERE foo IN %s",
  my_list)

but I can't off-hand remember which ones. If the back-end doesn't allow
that then you have little option but to generate your own SQL. The
required escape function is extremely simple:

  def sqlesc(s):
  return replace("'", "''")

and the SQL generation would read something like (again, untested):

  sql = "SELECT foo, bar FROM proj_words WHERE foo IN (%s)" % \
", ".join("'%s'" % sqlesc(s) for s in my_list)

Personally I would do everything I could to avoid this construct, however.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: trouble creating first project

2010-10-12 Thread Steve Holden
On 10/12/2010 4:02 PM, Robbington wrote:
> I mention this because some one has said that it is to do with your
> Python path, and this isnt true, its to do with the way you installed
> django in the first place.

It's nothing to do with the Python path (which is held in sys.path, and
is essentially the list of directories that the interpreter searches for
importable modules).

It's to do with the shell search path (under most shells, the $PATH
environment variable) which is a colon-separated list (Windows: a
semicolon-separated) list of directories which the shell searches for
programs to execute.

I'd be very surprised, by the way, to find the ls program in
/usr/local/bin. It normally lives (as do most other system binaries) in
/bin.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: trouble creating first project

2010-10-11 Thread Steve Holden
On 10/11/2010 1:47 AM, Phil wrote:
> Hi,
> 
> I am having trouble creating my first project. I am running the latest
> version of Ubuntu and I installed Django from svn, when I run 'import
> django' i get no errors back so I assume its installed OK.
> 
> When I run 'django-admin.py startproject myproject' I get back an
> error saying 'django-admin.py: command not found'.
> 
> How can I solve/get around this error? Appreciate any help/ advice
> offered
> 
When you install Django from svn it doesn't add django-admin to any of
the directories that your system looks for programs in (i.e. those
directories on your path).

When you install Django with setuptools (i.e. using setup.py) then you
should find that django-admin is placed where it can be found.

The simplest way around this is to make a symbolic link from one of the
directories on your path to the django-admin.py file.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: I can't select day with calendar widget

2010-10-09 Thread Steve Holden
As others have observed, I see the correct dates for holidays I created,
including 2010-10-10.

regards
 Steve

On 10/9/2010 7:46 AM, Rene Vielma wrote:
> Hello
> 
> I've upload the sandbox project whit develop server to 
> http://200.63.96.245:8000/admin/
> user and p: test
> 
> For you can check this problem
> 
> I hope any comment
> 
> thanks..
> 
> On 7 oct, 18:25, "renevie...@gmail.com"  wrote:
>> Hello.
>>
>> I've a problem with the calendar widget.
>>
>> I created a sandbox project with just one entity and one date attribute
>> then I registered in the admin
>>
>> nothing else
>>
>> the problem happens when I select 2010-10-10  in the widget , then
>> 2010-10-09 is set in the field.
>> I don't know if this happens with others dates.
>>
>> what happen?
>>
>> my setting.py doesn't have any significant changes
>>
>> thanks
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: dictionary doesn't get properly updated

2010-10-07 Thread Steve Holden
I don't believe so, guess you have to keep looking.

regards
 Steve

On 10/7/2010 11:46 AM, jimgardener wrote:
> I am using the development server..will that cause such a problem?
> jim
> 
>> Are you sure that everything is being run in the same process? If (for
>> example) you are using Apache as a front-end then, as I understand it,
>> there are no guarantees about that.
>>
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: dictionary doesn't get properly updated

2010-10-07 Thread Steve Holden
On 10/7/2010 10:20 AM, jimgardener wrote:
[...]
> 
> When the view add_new_threadobj() is executed a couple of times,this
> is the print output
> adding for the first time,
> tm= 
> TM::before::threads: {}
> TM::  add_thread()::added=threadname1
> TM::after::threads: {'threadname1': daemon)>}
> 
> adding another,
> tm= 
> TM::before::threads: {}
> TM::after::threads: {'threadname2': daemon)>}
> 
> This is what I couldn't make out, the dictionary should now contain 2
> kv pairs.Since the tm instance is the same,the self.threads should
> have  printed  the initially added thread's name and instance.
> Please tell me if I am missing something
> 
Are you sure that everything is being run in the same process? If (for
example) you are using Apache as a front-end then, as I understand it,
there are no guarantees about that.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

2010-10-07 Thread Steve Holden
On 10/7/2010 3:24 AM, Jyrki Pulliainen wrote:
>> So -- my original analysis still stands -- albeit for slightly more
>> > complex reasons. The issue here is that your code was previously in
>> > error, and now we're a little more vigilant about reporting the
>> > potential problem.
> Now that you've explained the problem a bit more deeply I think I have
> to agree with you that my software was faulty. And I so hoped that the
> flaws of my software could be accounted either by the flaws in the
> framework or by the flaws in the programming language itself ;)
> 
> - Jyrki

Don't we all, sometimes?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: data synchronization

2010-10-06 Thread Steve Holden
On 10/6/2010 9:17 PM, hooda_28 wrote:
> good day django peeps, i don't know if this is the right place to post
> here but im giving it a try,
> 
> website A is a publishing company, then website B is an agent of
> website, as an agent some of the orders from website B are given to
> website A. both websites run in django.
> 
> how will i synchronize the order from website B to website A? any
> suggestion on how will i do this?
> 
The easiest way would surely be to have the views in website B make
calls to REST views in website A to transfer the necessary order data.
It's very easy to write RESTful Django views, and you can easily use
either JSON or XML (among other possible formats) to transfer the data
between the two sites.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: admin site not working, problem with urls.py?

2010-10-06 Thread Steve Holden
It's much more likely that your CSS style sheets are not being served
correctly - you can check this by looking at the page's HTML source and
then pasting the style sheet's URL into your browser's location bar.

The Django 1.0 admin is a reasonably well-styled layout, so you
certainly shouldn't be seeing anything "funky".

regards
 Steve

On 10/6/2010 11:59 AM, Lisa Gandy wrote:
> Thanks for the help,
> This ended up working
> (r'^admin/(.*)', admin.site.root)
> 
> Now, when I look at the admin panel, its really funky looking, it
> definitely works, but its like its missing a template.
> Do yout hink its b/c the version of django on teh server is old?
> Its 1.0.4
> 
> If thats the problem, what is the easiest way to upgrade django on
> Ubuntu 8.10?
> 
> Thanks!
> Lisa
> 
> 
> On Tue, Oct 5, 2010 at 6:34 PM, Sandro Dutra  <mailto:hexo...@gmail.com>> wrote:
> 
> You have to check if you enable the "admin" application on your
> settings.py.
> 
> 2010/10/5 Sithembewena Lloyd Dube  <mailto:zebr...@gmail.com>>
> 
> Hey Lisa,
> 
> Look at this line (supplied by you):
> 
> 
>  # (r'^ccu/', include('ccu.foo.urls')),
> 
> ^^ the line above is correct.
> 
> Now, the line that's giving you trouble is:
> 
>  (r'^admin/', include(admin.site.urls)),
> 
> ^^ spot the difference?
> 
> I think you should use quotes around your argument to the
> include function. That function expects a string, I believe :)
> 
> 
> 
> On Wed, Oct 6, 2010 at 12:01 AM, Lisa  <mailto:lisagand...@gmail.com>> wrote:
> 
> Hi all,
> I'm sure I have a pretty simple problem...
> here's my url.py file
> 
> from django.conf.urls.defaults import *
> 
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
> 
> urlpatterns = patterns('',
># Example:
># (r'^ccu/', include('ccu.foo.urls')),
> 
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> 
># Uncomment the next line to enable the admin:
>(r'^stories/$','ccu_gen.views.all_stories'),
>(r'^stories/(?P\d+)/$', 'ccu_gen.views.one_story'),
>(r'^admin/', include(admin.site.urls)),
> 
> )
> 
> stories works fine, but for the admin url, I'm getting the error
> __import__() argument 1 must be string, not instancemethod
> 
> any ideas?
> 
> Thanks!
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django app that uploads media files and servers them through a view?

2010-10-06 Thread Steve Holden
On 10/6/2010 7:17 AM, Kenneth Gonsalves wrote:
> On Thu, 2010-09-30 at 04:20 -0700, Stodge wrote:
>> Is anyone aware of a Django app that lets you upload media files (not
>> necessarily in the admin site) but serves them through a view instead
>> of as static files via the web server? I need to control access to the
>> media using permissions. Thanks 
> 
> I do not understand this - I was under the impression that django always
> serves files through a view in a template. So you can control what the
> viewer sees in your view.

That's not the case. Most sites have a front-end server (typically nginx
or Apache) serve the static content directly. For things like CSS style
sheets and graphics permissions aren't usually that important. Stodge's
case appears to be different.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django Registration password reset problem

2010-10-05 Thread Steve Holden
On 10/5/2010 4:45 PM, Joel Klabo wrote:
> Need to bump this, sorry. I don't get it.
> 
> On Oct 5, 1:04 pm, Joel Klabo  wrote:
>> This is the error and location of the problem:http://gist.github.com/612210,
>> I can't see what it's looking for. It seems like I could hard code the
>> arguments it wants into the reverse() but that doesn't seem like the
>> correct way to do it. Any advice?
> 
I can quite see how 41 minutes would appear to be an infinity to someone
who is wanting the answer to a problem. Please remember, though, that
people who post on this list aren't paid to do so, and mostly have
full-time jobs.

So a little patience will make it more likely people will help you.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: treating different versions of website urls as one

2010-10-05 Thread Steve Holden
On 10/5/2010 1:35 PM, harryos wrote:
> The user can enter a website address which will be tracked by the
> program for certain info and then a message is sent to the user's
> mail.The  user can enter many such addresses.The problem is that he
> may accidently enter different variations of the url..and if I don't
> validate it for duplicates ,the program will be doing the same work
> again unnecessarily.
> if user gives http://www.djangocon.us and djangocon.us or http://djangocon.us
> ,the program will use those in urllib.urlopen(urlstring) ,and the read
> page /data will be the same.
> .This is why I need to consider the validation for duplicates
> thanks for the replies
> harry
> 
> On Oct 5, 10:00 pm, Steve Holden  wrote:
>> What aboutwww.mysite.com/default.asp?It might be helpful if you could
>> give us a little more insight into the real requirement here, rather
>> than a technical question based on some interpretation of the requirement.
>>
> 
But then the problem is that you don't actually *know* that
www.example.com and example.com are equivalent, let alone whether the
root page in a directory is represented by index.html, index.php,
default.asp, default.aspx or some other bizarre default imposed by a
site administrator.

The site is effectively a black box - you cannot truly know which URLs
are equivalent without knowing how it's configured.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: treating different versions of website urls as one

2010-10-05 Thread Steve Holden
What about www.mysite.com/default.asp? It might be helpful if you could
give us a little more insight into the real requirement here, rather
than a technical question based on some interpretation of the requirement.

regards
 Steve

On 10/5/2010 12:57 PM, Alec Shaner wrote:
> Definitely sounds like a regular expression is what you need.
> 
> Not sure what you mean by etcare you saying any variation of a web
> address for mysite.com, i.e., with or without www prefix, with our
> without protocol http://, and with our without the index page, which
> itself could be any variation of index.html, index.php, or
> index.whatever?
> 
> On Tue, Oct 5, 2010 at 12:17 PM, harryos  wrote:
>> hi
>> I am trying out a web app where it needs to process user given website
>> addresses .My problem is that ,I need to treat
>>  http://mysite.com ,
>> www.mysite.com,
>> mysite.com,
>> www.mysite.com/index.html,
>> www.mysite.com/index.php ...etc as the same and not different urls.How
>> can I do the validation in this case?Do I have to manually do the
>> string parsing and validate?
>> Any suggestions most welcome
>> thanks
>> harry
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: convert list into a comma separated string

2010-10-04 Thread Steve Holden
On 10/4/2010 8:49 AM, ashy wrote:
> Hi All,
> 
> my code is as below:
> li = ['2l','1l']
> str = ",".join(li)
> 
> but print str does not work for me :(
> 
"Does not work" is hardly a sufficient description of your problem, I
suspect. If I tell you my car "does not work", would you be able to tell
me how to fix it?

How are you running Django? If you are running it using

  python manage.py runserver

for testing then print statements *should* cause output to appear in the
standard output stream. If you are running under Apache, however, that
is not the case.

Also note that "str" is not a happy choice of name, since it is also the
name of one of Python's basic types and you may wish to use it as such.
Having a variable called "str" in your code stops you from doing so.

A little more information will allow us to help you better.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Any way to select which Model to initialize without resorting to "if-elfi" statements?

2010-10-03 Thread Steve Holden
On 10/3/2010 4:04 AM, Andy wrote:
> I need to model many different product categories such as TV, laptops,
> women's apparel, men's shoes, etc.
> 
> Since different product categories have different product attributes,
> each category has its own separate Model: TV, Laptop, WomensApparel,
> MensShoes, etc.
> 
> And for each Model I created a ModelForm. Hence I have TVForm,
> LaptopForm, WomensApparelForm, MensShoesForm, etc.
> 
> Users can enter product details by selecting a product category
> through multi-level drop-down boxes. Once a user has selected a
> product category, I need to display the corresponding product form.
> 
> The obvious way to do this is to use a giant `if-elif` structure:
> 
> # category is the product category selected by the user
> if category == "TV":
> form = TVForm()
> elif category == "Laptop":
> form = LaptopForm()
> elif category == "WomensApparel":
> form = WomensApparelForm()
> ...
> 
> Unfortunately there could be hundreds if not more of categories. So
> the above method is going to be error-prone and tedious.
> 
> Is there any way I could use the value of the variable `category` to
> directly select and initialize the appropriate `ModelForm` without
> resorting to a giant `if-elif` statement?
> 
> Something like:
> 
> # This doesn't work
> model_form_name = category + "Form"
> form = model_form_name()
> 
> Is there any way to do this?
> 
Let's suppose (just for the moment) all your models are defined in a
single module called "forms". Then the easiest way would be:

model_form_name = category + "Form"
form = getattr(forms, model_form_name)

This will raise an exception if there is no form of the required category.

And if the forms aren't all defined in the same module? The easiest
solution would be to write a forms module like this:

from thismodule import WomensApparelForm, TVForm, CandyForm
from thatmodule import LaptopForm
from theothermodule import CarForm, TruckForm

and so on. All you are doing is juggling namespaces, but as "import
this" reminds us, "namespaces are one honking good idea. Let's do more
of those".

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django documentation search not working

2010-10-02 Thread Steve Holden
On 10/2/2010 4:45 PM, NoviceSortOf wrote:
> I used to be able to go to the following link and
> seach django documents.
> 
> http://docs.djangoproject.com/en/dev//search/
> 
>>From there I could search anything from 'widgets' to
> 'login()' and find the related document/page discussion that time.
> 
> Now on that page search yields no results irregardless of what
> I search for .
> 
> Using the search field on
> http://docs.djangoproject.com/en/1.2/
> 
> Also does not yield any results.
> 
> Strange thing is that I can search from www.google.com
> django login() and get access to django docs but can't search
> django docs from the django website any explanation?
> 
Are you maybe running NoScript or some other script inhibiting extension
to your browser? The search feature's working just fine for me.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django website down?

2010-10-02 Thread Steve Holden
On 10/2/2010 5:50 PM, diogobaeder wrote:
> Hi, guys,
> 
> Is the Django website down? I've been trying to access it for days,
> but I just can't get in. Has anyone here been able to access it
> normally these days?
> 
> Thanks!
> 
> Diogo
> 

http://www.downforeveryoneorjustme.com/djangoproject.com

Seems fine to me.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Error

2010-10-01 Thread Steve Holden
On 10/1/2010 1:12 PM, Tsolmon Narantsogt wrote:
> Hi there
> 
> i got this error
> 
> *Exception RuntimeError: 'maximum recursion depth exceeded while calling
> a Python object' in  
> help me
> 
Was this *really* the only output you got? [I suppose it's possible,
given the nature of the error]. Or did you just copy a partial output
thinking that it would be enough? The full "traceback", as it's called,
would allow a more detailed analysis.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Full Text Search

2010-09-30 Thread Steve Holden
On 9/30/2010 8:26 PM, Nick Arnett wrote:
> Brain is mush, though.

Obviously, otherwise you'd have left it in the hope that someone else
would reply with an answer before you recovered consciousness. Great
heavens, this community is *so* anxious to help. Kudos for trying with a
frazzled brain!

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread Steve Holden
On 9/30/2010 1:55 PM, Miguel Araujo wrote:
> Hi Michael,
> 
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that
> my rule system is kind of the same thing of your role system, except
> mine is less flexible. I'm going to look a little bit the code, install
> it and see if I can help you with anything.
> 
> Only thing that cached my eye is that code is Copyrighted. Why not using
> an Open-source license? 
> 
There is a copyright on Python itself.  This doesn't stop it being
distributed under an open source license.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: DjangoCon 2011

2010-09-30 Thread Steve Holden
On 9/30/2010 10:36 AM, sserrano wrote:
>> I live in Argentina, If I wanted to go to the DjangoCon in
>> Portland, it would require a Bus to Buenos Aires, then take an
>> international flight to a US mayor city and then another to reach
>> Portland, overall I would be travelling more nearly an entire day
>> to reach the conference.
>> 
>> New York, San Francisco, Los Angeles and Washington have direct 
>> flights from almost every country. I'm sure if the conference is
>> place in a city with easy access it would have more people going.
>> 
Thank you for your input. What you say is true. Unfortunately (for
people in your position) growth in numbers isn't a primary goal for
DjangoCon US and Portland seems to attract sufficient delegates to make
it successful.

I am not unmindful of these factors, but on the other side of the coin
it's likely (for precisely the convenience reasons you state) that those
locations with convenient international airports will have hotels that
are significantly more expensive than places like Portland.

Cost *is* a major inhibitor of attendance, and unless the Django
community advise otherwise a high priority will be trying to keep the
2011 cost as close to this year's level as I can.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: url not going to view

2010-09-30 Thread Steve Holden
Just as "^" means "start of string" so "$" mean "end of string", so "^$"
means a string where the end is next to the beginning.

You can read the Python documentation for the "re"module for more
insight into all this.

regards
 Steve

On 9/30/2010 11:20 AM, Bradley Hintze wrote:
> LOL, let me rephrase.
> 
> What is the significance of the '$' (or what does it mean) in the URLs
> as pointed out in previous messages?
> 
> On Thu, Sep 30, 2010 at 11:15 AM, Carlton Gibson
>  wrote:
>> Its the plural of $.
>>
>> On 30 Sep 2010, at 16:02, Bradley Hintze wrote:
>>
>>> Why $s, if you don't mind me asking?
>>>
>>> On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
>>>  wrote:

 On 30 Sep 2010, at 15:42, Bradley Hintze wrote:

> urlpatterns = patterns('',
>(r'^', home_view),
>(r'^here/', here),
># Example:
> )

 your first pattern matches all URLs which have a beginning, which is all 
 URLs. You need to add the $s at the end:

 urlpatterns = patterns('',
   (r'^$', home_view),
   (r'^here/$', here),
   # Example:
 )

 HTH

 Regards,
 Carlton

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


>>>
>>>
>>>
>>> --
>>> Bradley J. Hintze
>>> Graduate Student
>>> Duke University
>>> School of Medicine
>>> 801-712-8799
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
> 
> 
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: template syntax errors in production admin site (version problem?)

2010-09-30 Thread Steve Holden
On 9/30/2010 9:50 AM, bobbymanuel wrote:
> Hi all - i've got a mysterious problem with my admin templates and I
> think its a version problem but can't figure it out.
> 
> The contrib.admin templates seem to be throwing some very crazy
> TemplateSyntaxError(s) in many of the admin templates when i moved my
> app to my production environment.  I'm thinking this must be some kind
> of version problem so I removed django completely and reinstalled the
> production version and still have the same problems.  Now, the same
> exact project works perfectly on my development server, but the
> service[debian/lighttpd/fcgi] that I set up for production displays
> these issues - oddly enough when I first installed it, before taking
> the project live, it seemed to work.  I'm using the exact same path to
> template loaders in production/dev.
> 
> Anyone have any ideas what's going on?  Has anyone else experienced
> this problem?
> 
> Here are 2 examples of errors being thrown:
> ---
> 
> TemplateSyntaxError at /admin/
> In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> templates/admin/base.html, error at line 31
> Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> 21
> 22
> 23
> 24{% block branding %}{% endblock %}
> 25
> 26{% if user.is_active and user.is_staff %}
> 27
> 28{% trans 'Welcome,' %}
> 29{% filter force_escape %}{% firstof
> user.first_name user.username %}{% endfilter %}.
> 30{% block userlinks %}
> 31{% url django-admindocs-docroot as docsroot %}
> 32{% if docsroot %}
> 33{% trans
> 'Documentation' %} /
> 34{% endif %}
> 35{% url admin:password_change as password_change_url
> %}
> 36{% if password_change_url %}
> 37
> 
> and
> 
> TemplateSyntaxError at /admin/auth/group/add/
> In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> templates/admin/includes/fieldset.html, error at line 18
> Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> 8 {{ line.errors }}
> 9 {% for field in line %}
> 10 class="field-box"{% endif %}>
> 11{% if field.is_checkbox %}
> 12{{ field.field }}{{ field.label_tag }}
> 13{% else %}
> 14{{ field.label_tag }}
> 15{% if field.is_readonly %}
> 16{{ field.contents }}
> 17{% else %}
> 18{{ field.field }}
> 19{% endif %}
> 20{% endif %}
> 

Is there any possibility that your server is trying to report a 500
error, and that it's actually the 500 template it's complaining about?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: UnicodeEncodeError

2010-09-29 Thread Steve Holden
It might be helpful to provide rather more of the traceback information.

Also, check your database encoding. Somehow you are requiring Django to
convert a Unicode string in to an ASCII string.

regards
 Steve

On 9/29/2010 2:01 PM, jean polo wrote:
> hi Steve
> 
> do you have any advices for where to look for this to happen ?
> 
> I have a basic 'Bien' class and a *very basic* 'Image' class (with a
> ForeignKey to Bien).
> BienAdmin has a ImageInline and that's all.
> 
> I am a bit confused..
> 
> cheers,
> _y
> 
> 
> 
> On Sep 29, 7:39 pm, Steve Holden  wrote:
>> It sounds to me as though the image is being transmitted with the wrong
>> MIME Type. Image files are binary data, but something in your
>> application is treating is as a string.
>>
>> regards
>>  Steve
>>
>> On 9/29/2010 1:05 PM, werefr0g wrote:
>>
>>
>>
>>>  Hi,
>>
>>> You should check that your file is actually utf-8 encoded and add the
>>> folliwing right after shebang:
>>> # -*- coding: utf-8 -*-
>>
>>> Le 29/09/2010 18:59, jean polo a crit :
>>>> Hi.
>>>> I get an 'UnicodeEncodeError' if I upload a file (ImageField) with non-
>>>> ascii chars in my application (django-1.2.1).
>>
>>>> I added:
>>
>>>> export LANG='en_US.UTF-8'
>>>> export LC_ALL='en_US.UTF-8'
>>
>>>> in my /etc/apache2/envvars as stated here:
>>>> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...
>>
>>>> but I still have the same error (after restarting apache).
>>>> Any hint much appreciated.
>>
>>>> cheers,
>>>> _y
>>
>>>> ps:
>>
>>>> Traceback (most recent call last):
>>>> [snip]
>>>>   File "/usr/languages/python/2.6/lib/python2.6/genericpath.py", line
>>>> 18, in exists
>>>> st = os.stat(path)
>>
>>>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in
>>>> position 53: ordinal not in range(128)
>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> DjangoCon US 2010 September 7-9http://djangocon.us/
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: UnicodeEncodeError

2010-09-29 Thread Steve Holden
It sounds to me as though the image is being transmitted with the wrong
MIME Type. Image files are binary data, but something in your
application is treating is as a string.

regards
 Steve

On 9/29/2010 1:05 PM, werefr0g wrote:
>  Hi,
> 
> You should check that your file is actually utf-8 encoded and add the
> folliwing right after shebang:
> # -*- coding: utf-8 -*-
> 
> Le 29/09/2010 18:59, jean polo a écrit :
>> Hi.
>> I get an 'UnicodeEncodeError' if I upload a file (ImageField) with non-
>> ascii chars in my application (django-1.2.1).
>>
>> I added:
>>
>> export LANG='en_US.UTF-8'
>> export LC_ALL='en_US.UTF-8'
>>
>> in my /etc/apache2/envvars as stated here:
>> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror
>>
>> but I still have the same error (after restarting apache).
>> Any hint much appreciated.
>>
>> cheers,
>> _y
>>
>> ps:
>>
>> Traceback (most recent call last):
>> [snip]
>>   File "/usr/languages/python/2.6/lib/python2.6/genericpath.py", line
>> 18, in exists
>> st = os.stat(path)
>>
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in
>> position 53: ordinal not in range(128)
>>
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: What is the correct way to copy an object from one model to a similar model?

2010-09-29 Thread Steve Holden
On 9/29/2010 5:25 AM, Daniel Roseman wrote:
> On Sep 29, 6:06 am, Yo-Yo Ma  wrote:
>> I have two models that are identical in structure except one has 2
>> extra fields. The second one is used for record keeping and is never
>> edited by users. The system takes the first model and copies it to the
>> second model, adding some extra meta information, all when a certain
>> action is performed against the first model.
>>
>> What is the best practice for this?
>>
>> spam.attribute_one = foo.attribute_one
>> spam.attribute_two = foo.attribute_two
>>
>> Or, is there a pattern that works well?
> 
> You can use the get_all_field_names method in model._meta to get all
> the actual fields, and set them on the duplicate:
> 
> for field in foo._meta.get_all_field_names():
> setattr(spam, getattr(foo, field))
> 
I believe that last line should read

setattr(spam, field, getattr(foo, field))

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: How to get an ajax call to return both QuerySet and paging info in Django

2010-09-28 Thread Steve Holden
On 9/28/2010 10:42 PM, Dmitrij wrote:
> I am trying to implement paging across ajax calls. The page should not
> refresh when the user wants to see the next x num of results.
> 
> Here is my problem. Returning the QuerySet is super simple. I just do
> (sumaJson is custom)
> 
> data = serializers.serialize('sumaJson', result_page.object_list,
> relations=('first_major', 'country_of_origin', 'second_major'))
> return HttpResponse(data, mimetype="application/json")
> 
> Now I also want to return things like
> 
> result_page.has_previous()
> result_page.has_next()
> result_page.paginator.count
> 
> and so on. I for the life of me can't figure out how to get both
> across in one response. I can't add this info to
> result_page.object_list because then the serializer fails. If I
> something of the sort of
> 
> simplejson.dumps(paging_info + result_page.object_list)
> 
> Then in the javascript the QuerySet is no longer a list of objects but
> just a big string of characters which can't be interpreted with
> 
> $.each(data.data, function(index, item){
> 
> I tried some bad hacks like creating a fake object and putting it in
> the object_list, serializing this and then deleting the object. This
> allows me to get the data across. However, I don't want to be creating
> and deleting fake objects.
> 
> I don't want to meddle with the serializer. I don't want to send a
> second ajax request once I get the querySet back to get the paging
> info.
> 
> Am I missing something? Is there an easy way to get both across in one
> response? Thanks!
> 
I don't know about a fake object, but surely if you put everything you
want in a Python dict and then serialize that it will arrive in
JavaScript as an object with named fields, which you can use as you want
by referencing the fields as object attributes. Or am I missing something?

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Model field choices

2010-09-28 Thread Steve Holden
On 9/28/2010 10:39 PM, Derek wrote:
> I have a model which has choices specified for the "offer_type" field:
> 
> class Coupon(models.Model):
>   offer_types = (
>   (1, 'Percentage Off'),
>   (2, 'Amount Off'),
>   (3, 'Free'),
>   )
> 
>   business = models.ForeignKey(Business)
>   offer_type = models.IntegerField(choices=offer_types)
> 
> How do I then retrieve the "human readable" values when referencing a
> Coupon object?  Right now Coupon.objects.get(id=1).offer_type returns
> the numeric value only ("3" instead of "free"... which I suppose is to
> be expected).
> 
> Thanks!
> 
You should find that your model instances have a
get_offer_type_display() method that you can call to retrieve the value
that the user sees in the interface. These methods are added for each
field with choices set in its definition.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: DjangoCon 2011

2010-09-28 Thread Steve Holden
On 9/28/2010 9:44 AM, Dana Spiegel wrote:
> Steve,
> 
> This seems totally reasonable.
> 
> Looking at this from a different perspective, given that there are a
> large and increasing number of python-based startups in NYC, would it
> make a difference re: which city was chosen if we (in NYC) were able
> to solicit sponsorships from VCs and tech firms here (in NYC)?
> 
It might, though the sponsors would need to commit in advance.

The main issue would be the cost of accommodation, which can be very
high in the city. Do you think you could get sponsors to offset those
costs? I'm finding it difficult to imagine how that could practically be
done.

regards
 Steve

> On Sep 28, 8:54 am, Steve Holden  wrote:
>> Without wishing to seem non-responsive, can I just point out that we
>> can't keep extending the search indefinitely. First of all, we need to
>> make a decision reasonably quickly.Secondly, these venue searches take
>> time. While it costs nothing to "toss something out there", there *are*
>> costs involved with investigating available venues.
>>
>> Consequently I am unlikely to look at any particular place unless it is
>> clearly supported by a number of people. And having had Chicago, New
>> York and Washington DC in our sights I am not inclined to extend that
>> list without a strong indication of support from a broad cross-section
>> of the community.
>>
>> I hope nobody takes this the wrong way.
>>
>> regards
>>  Steve
>>
>> On 9/28/2010 8:48 AM, Rev. Johnny Healey wrote:> It seems like no one has 
>> suggested New Orleans yet, so I'm just going
>>> to toss that out there.
>>
>>> -Johnny
>>
>> --
>> DjangoCon US 2010 September 7-9http://djangocon.us/
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: DjangoCon 2011

2010-09-28 Thread Steve Holden
Without wishing to seem non-responsive, can I just point out that we
can't keep extending the search indefinitely. First of all, we need to
make a decision reasonably quickly.Secondly, these venue searches take
time. While it costs nothing to "toss something out there", there *are*
costs involved with investigating available venues.

Consequently I am unlikely to look at any particular place unless it is
clearly supported by a number of people. And having had Chicago, New
York and Washington DC in our sights I am not inclined to extend that
list without a strong indication of support from a broad cross-section
of the community.

I hope nobody takes this the wrong way.

regards
 Steve

On 9/28/2010 8:48 AM, Rev. Johnny Healey wrote:
> It seems like no one has suggested New Orleans yet, so I'm just going
> to toss that out there.
> 
> -Johnny
> 
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Fwd: Re: DjangoCon 2011

2010-09-28 Thread Steve Holden
On 9/28/2010 1:19 AM, Kenneth Gonsalves wrote:
> On Mon, 2010-09-27 at 22:51 -0400, Steve Holden wrote:
>> I'd just like to briefly report back on the inquiries Nancy and I have
>> been making into East coast venues for DjangoCon 2011. 
> 
> just curious - why a hotel? In India we hold such conferences in
> universities/colleges - they provide all facilities free of cost (except
> accomodation - although some make their guest houses available for the
> VIPs), and in fact, compete with each other to offer hosting. We have
> just finished Pycon India where we got three state of art auditoriums
> free of cost.

The choice of venue was made in advance for this year - effectively we
took over an existing contract. This is the first time anyone has
suggested a non-hotel venue.

I haven't really heard much support for a university venue from the
community at large. They have both advantages and disadvantages. Of
course PyCon used a university location for the first three years. After
we outgrew the original location the conference's size made it difficult
to find university locations large enough (according to the people who
made the choices - I only chaired for three years).

It would be best not to cast the net too wide, given that a year ahead
is a relatively short planning time frame for a conference of this size.

regards
 Steve

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



Re: DjangoCon 2011

2010-09-28 Thread Steve Holden
There seemed to be a general feeling that a change of venue should head
Eastwards rather than South. So we are looking primarily for East coast
locations as an alternative to Portland for 2011.

regards
 Steve

On 9/27/2010 11:49 PM, David Zhou wrote:
> Is the bay area right out for cost reasons?
> 
> dz
> 
> Sent from my iPhone
> 
> On Sep 27, 2010, at 8:48 PM, Samuel Baldwin  
> wrote:
> 
>> 2010/9/27 Franklin Einspruch :
>>> May I humbly suggest Boston?
>>
>> Another for Boston.
>> --
>> Samuel Baldwin - logik.li
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
> 

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



Re: DjangoCon 2011

2010-09-27 Thread Steve Holden
On 9/27/2010 11:02 PM, Shawn Milochik wrote:
> > I live on the east coast, but the past two DjangoCons have caused me
> > to fall in love with Portland. It would be a treat for me to get to
> > go there again in 2011.
> >
> > In fact, if it's in Portland next year I plan to make a family
> > vacation of it.
> >
> > So, that's my vote, for whatever it's worth. Hope to see everyone in
> > Portland next year!
On 9/27/2010 11:04 PM, Russell Keith-Magee wrote:
> > I don't have any objections to another year in Portland. It's a great
> > city with great transport and nightlife. If another year in Portland
> > will give us the breathing room to secure better options on the east
> > coast, I'm all for it. It's certainly a more attractive option than a
> > week in an airport Hilton with a cab ride needed for every restaurant
> > trip.
> >
That was my reasoning too. It's not all over yet (there are still
options in Arlington, which is rather more cosmopolitan, that we are
still awaiting replies from) but in the absence of some alternative
which allows us to keep the price within 5-10% of this year it does seem
attractive.

We could then take the opportunity to plan an East coast venue with a
longer time frame, giving us more chance of meeting the community's
parameters.

Atlanta, Orlando and Boston have also been suggested. It will never be
Orlando for me (sorry, I just can't bring myself to like the place as a
conference venue, great as it may be for a family vacation). While the
other two cities might be possibilities for future years I don't think
they are any more likely to be practical for 2011 than Chicago or New
York, and for much the same reasons.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



DjangoCon 2011

2010-09-27 Thread Steve Holden
I'd just like to briefly report back on the inquiries Nancy and I have
been making into East coast venues for DjangoCon 2011. This is not a
final answer, simply reassurance that things have actually been happening.

Sadly, New York is out for 2011. Those (very few) venues whose costs are
low enough are already booked up. Those with space are *much* too
expensive. If we want to look at a New York DjangoCon US we should
probably plan at least two years ahead, and still expect it to be quite
a lot more expensive than Portland (even without factoring in the higher
cost of eating out and so on in New York).

Chicago is also quite a lot more expensive than Portland for 2011, so we
have had to rule that out too. Again, a longer planning time frame
*might* help.

We did receive responses from a couple of hotels close to Dulles airport
where the costs might be acceptable and they do have space for next
year. Sadly both facilities (and particularly the one whose costs are
closest to the Doubletree in Portland) are quite isolated (i.e. anything
else is a cab ride away). This doesn't seem like it would fit with a
group that enjoys visiting local bars and restaurants.

We are currently waiting for replies from one or two more hotels more
"in the thick of things" in the DC area. This would probably mean a bit
more difficulty getting to the venue from the airports, but it would
mean that Djangonauts who want to venture out from the hotel would find
more facilities close by.

I will let you know more when I hear more. In the meantime, I am
wondering whether it might be more practical to have a third year at the
Doubletree in Portland, and adopt a longer time frame for 2012 planning
for an East coast conference. Feedback on that question would be welcome.

regards
 Steve

PS: When is @alex_gaynor's birthday?
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Where do you put your business logic in django? Organizing big projects in django.

2010-09-27 Thread Steve Holden
On 9/27/2010 11:31 AM, Thomas Weholt wrote:
> On Mon, Sep 27, 2010 at 4:52 PM, bruno desthuilliers
>  wrote:
>> On 27 sep, 12:55, Thomas Weholt  wrote:
>>> On Mon, Sep 27, 2010 at 12:40 PM, Steve Holden  wrote:
>>>> I think the point is to learn enough Python that you don't need
>>>> Django-specific advice.
>>>
>>>> [Thinks: definitely time for a "Python for Djangonauts" class].
>>>
>>> I`m asking for a best-practice advice, and have gotten plenty of good
>>> examples of ways to solve this "problem", but I still think this
>>> should be covered by the standard django docs anyhow,
>>
>> What would you suggest exactly ?
> 
> I section under "The model layer -> Advanced" called "Organizing
> models and code in larger projects". Details on how to splitting
> models over several files, if and how you should seperate logic from
> models etc.
> 
>>> especially since
>>> there are some django specific magic related to the files generated by
>>> using manage.py startapp.
>>
>> ??? Which "django specific magic" ???
> 
> I was referring to syncdb. As far as I know, models defined outside
> any models.py or models module won`t be picked up by syncdb, but I
> might be wrong.
> 
An addition to the documentation about why your models may not be picked
up could well be useful.

>>
>>> It`s obviously not clear to all django users
>>> how to best handle growing projects, split into modules etc
>>
>> I can only second Steve on this : time for "Python for Djangonauts"
>> class then. FWIW, I'm amazed at how many persons seem to pick up
>> django without any background in Python.
> 
> Hmmm ... do you or Steven know anything about my programming
> background? My googling and even answers on this thread seem to
> indicate that I`m not alone pondering about how to organize my django
> code. I know how to structure my code in modules, but for
> re-usability`s sake for instance it would be nice to have some
> guidelines on how to structure your code in larger django projects and
> it would be nice to have those guidelines in the otherwise excellent
> django docs.
> 
Hold hard, there! That's Steve, not Steven, Thomas. And I was musing
about it being an opportunity to write and promote a new training class,
rather than specifically suggesting that you personally needed training.

>>
>>> and just
>>> taking some of the info in this thread, re-writing it and giving a few
>>> examples and then adding it to the std docs would be enough.
>>
>> Mmm... Not sure this would help. A pointer to Python's doc and a
>> strong emphasis on the fact that you definitly have to learn Python to
>> go any further would be more helpful in the long run IMHO. But well,
>> if you think you can contribute something useful, please go ahead and
>> submit your patch to the team - it's an OSS project, isn't it ?
> 
> I`m trying to contribute to the django community by writing code,
> reusable apps, being active on gropus like this etc. I could even try
> to help out writing docs, but if my questions are going to be answered
> by people who question my competence that wouldn`t be very motivating,
> would it?
> 
I don't think anyone's questioning your competence, and your desire to
help in a community-spirited way is very welcome. But you should realize
(and probably will if you think about it) that many people who do ask
questions on this list could use better Python knowledge than they
currently have. If you aren't in that position then fine.

> I`ll take all the hints and advice given in this thread and try to use
> it to organize my ongoing project. Thanks for your time, everyone.
> 
You are correct in saying that the Django docs are excellent, but
there's only so much they can do.

If you do come up with useful guidelines I am sure that nobody is going
to complain if you submit a patch to the docs. One of the issues is that
size is not the only metric of complexity, and it's difficult to frame
generic advice about the organization of large projects.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Where do you put your business logic in django? Organizing big projects in django.

2010-09-27 Thread Steve Holden
On 9/27/2010 4:57 AM, Thomas Weholt wrote:
> On Mon, Sep 27, 2010 at 10:38 AM, bruno desthuilliers
>  wrote:
>> On 27 sep, 09:08, MrMuffin  wrote:
>>> Where do you put your business logic in django?
>>
>> Depends on the definition of "business logic", but :
>>
>>> In my project I`ve put
>>> it into the models.py,
>>
>> That's also what I tend to do for anything that's not a pure utility
>> class or function and that's not strictly tied to the HTTP request /
>> response cycle.
>>
>>> but that file soon become huge and hard to
>>> maintain.
>>
>>
>> Then refactor your "models.py" module into a package.
>>
>>> Of course I can just stuff it into whatever file I like, but
>>> I`d like to have some standard way of doing this. There seems to be
>>> something missing in django when it comes to business logic. It`s all
>>> model, views and templates and that`s all great for small projects,
>>> but both the models.py and views.py very soon gets huge and how do you
>>> re-organize your project when that happens? Splitting views and models
>>> into seperate files is only a partial solution and that requires some
>>> hackish code in __init__.py to make syncdb etc work.
>>
>> Using the package's __init__.py as a facade is certainly not "hackish"
>> - it's one of - if not the main - the raison d'être of this file.
>>
>> Now if your app is really growing that big, it's probably time to
>> refactor it into a set of related, more specialized apps. It's not as
>> easy as just splitting the models / views / whatever as sub-packages
>> of a same app, and doing so afterward will probably be more painful
>> than designing it right from the start, but in both cases it has the
>> benefit that it forces you to think about dependancies management,
>> which can greatly helps when it comes to maintainance.
> 
> Ok, I see your point, but still -  there`s nothing about this in the
> main django documentation as far as I know. The docs should have a
> section about organizing projects where the standard models.py and
> views.py doesn`t fit anymore.
> 
I think the point is to learn enough Python that you don't need
Django-specific advice.

[Thinks: definitely time for a "Python for Djangonauts" class].

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Python unexpectedly quit

2010-09-24 Thread Steve Holden
On 9/24/2010 2:23 PM, Axel Bock wrote:
> Anything wrong here? I must say, the framework for the people "with
> deadlines" is giving me a *really* hard time so far :) .

Maybe you aren't in enough of a hurry? And, by the way, it's
*perfectionists* with deadlines. Maybe you aren't being picky enough?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Why Django Apps Suck

2010-09-22 Thread Steve Holden
On 9/22/2010 8:36 AM, Russell Keith-Magee wrote:
> Lastly, I can't deny that reusability has it's price. Engineering an 
> application to be reusable takes more effort and planning than 
> building an application as a once-off.

Well, Unix certainly came a long way with this philosophy

> The aim is that if you take the effort once to make your application
> reusable, the engineering payoff will happen quickly -- hopefully on
> your second build. However, if you have no intention of using a
> component a second time, then there isn't a whole lot of reason to
> spend the effort making it reusable.

True to a certain extend, but it takes a certain amount of experience to
recognize a true YAGNI.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-22 Thread Steve Holden
On 9/22/2010 4:30 PM, Anton Danilchenko wrote:
> Ihave found solution.
> 
> I have changed only Form class:
> 
> 1) added field for show text input field
> phones = forms.CharField()
> 
> 2) I have create in my Form instance method clear_phones() where I
> check phones and save it all to database and get Phone model ids for
> this phone numbers. And return this ids
> 
> All work well. Simple solution for this task.  Thank you for help!
> 
Most of the help seems to have been self-provided, so well done!

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: multiple servers one database

2010-09-20 Thread Steve Holden
On 9/20/2010 11:11 AM, Tim Arnold wrote:
> hi, I have two machines for a Django-powered site and they are  setup
> to be duplicates to provide redundancy. Each one runs its own apache
> instance and accesses the same Django apps on a shared disk.
> 
> The problem I have is that I need a single database. The users should
> not need to know which machine they're actually connecting to. As I
> understand it, I can't do that with MySQL. I can make one a master and
> one a slave, but that's not duplication of machines. I tried making a
> symlink from /usr/local/mysql/var to a shared disk location for both
> MySQL servers, but that is a Bad Idea (from what I read this weekend).
> 
> So finally, my question is how to solve the problem and maybe whether
> SQLite would be a better database since AIUI, it is simply file-based.
> 
If the two web servers are sharing a disk they are presumably fairly
local to each other. Why not just a single database server with each
Django server connecting to it over a LAN? You may need to think more
deeply abut transaction isolation. Just an idea ...

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: {% url %} template and javascript Get with callback

2010-09-19 Thread Steve Holden
On 9/19/2010 12:52 PM, Ben Kraft wrote:
> I'm trying to do a javascript post to an internal api and use a
> callback to process the JSON result.  I'm referencing the api using,
> 
> {% url %},
> 
> which returns a path url relative to my domain ( /api/... instead of
> http://localhost/api/... for the dev site).
> 
> The problem is js does not recognize that the relative / path url
> returned by {% url %} is on the same domain current page, and refuses
> to execute the callback.  I could mess around with JSONP, but I'd
> rather just put the full url in the template.  Is there a convenient
> way to do this, or am I missing something?  I could just add manually
> add the full url to the request context, but it seems like everyone
> who uses django with JS callbacks would have this problem, and there
> should be a simpler way.
> 
> -Ben
> (and I'm sure the sites are on the same domain -- if I hardcode the
> full url, the callback works fine).
> 
SERVER_NAME and SERVER_PORT are available in HttpRequest.META if you
want to construct full URLs.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Relationship question: What do I do wrong?

2010-09-18 Thread Steve Holden
On 9/18/2010 3:23 PM, werefr0g wrote:
>  Hello,
> 
> I was quite laconic previously in order to spare you my "english". Sorry
> if you found this rude.
> 
> Well, you describe the relashionship from one model perspective (Meal)
> while setting your field (side1).By setting Field side1 in Meal as
> models.ForeignKey, you state that a Meal has a relationship to one Side
> as side1 but you also explicitly state that one Side can be related to
> many Meal through this relashionship.
> 
> If my_meal is your Meal instance, you'll use my_meal.side1 to reach
> related Side through side1 relashionship. With my_side as a Side
> instance, you'll use my_side.meal_set to reach all Meal related to
> my_side regarding the same relashionship.
> 
> Now, taking side2 Field in account, you can use my_meal.side2 but you
> can no longer use my_side.meal_set: you cannot distinguish which
> relashionship is implied this way. The related_name parameters allows
> you to make that distinction. Here you can place 'with main course' and
> 'post main course' and, by the way, I think you should name fields
> with_main_course_side and post_main_course_side or alike.
> 
> You'll find at
> http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects
> more details with an explanation of the nature of side1.meal_set object
> type's nature _ in better english ;)
> 
That's a very clear explanation, and much more concise than the
documentation. Congratulations. I also like your naming recommendation.

Of course, if you wanted the flexibility of an indefinite number of
sides you would usually use a many-to-many relationship between Meals
and Sides, perhaps with using a "through" table (? is that what they are
called) to add one or more status columns to store further attributes of
the relationship such as "post_main_course" / "with_main_course" (useful
for searching).

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: need help with admin list images

2010-09-18 Thread Steve Holden
Read up on the concept of "safe" markup:

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping

regards
 Steve

On 9/18/2010 6:16 PM, Bobby Roberts wrote:
> only thing that does is return this:
> 
>  width="65"/>
> 
> 
> 
> I need the image to show rather than just the html for the image.
> 
> any ideas.
> 
> 
> 
> On Sep 18, 6:07 pm, Wai Yi Leung  wrote:
>> Try:
>>
>>
>>
>>> class PartnerAdmin(admin.ModelAdmin):
>>>list_display = ('xx','AdminTag',)
>>>search_fields = ['AdminTag','Title','Description']
>>
>>>def xx(self, instance):
>>>return '' %
>>> (instance.Thumbnail)
>>>xx.allow_tags=True
>>
>> Since the admin function is for each row ( instance )...
>>
>> Op 18 sep 2010, om 22:52 heeft Bobby Roberts het volgende geschreven:
>>
>>> in my model i have an image field as such:
>>
>>>   Thumbnail= models.ImageField(upload_to="images/partners/
>>> thumbs/", blank=False)
>>
>>> I want the thumbnail to show in my admin list.  My admin class looks
>>> like this below:
>>
>>> class PartnerAdmin(admin.ModelAdmin):
>>>list_display = ('xx','AdminTag',)
>>>search_fields = ['AdminTag','Title','Description']
>>
>>>def xx(self):
>>>return '' %
>>> (self.Thumbnail)
>>>xx.allow_tags=True
>>
>>> The result:
>>
>>> Caught TypeError while rendering: xx() takes exactly 1 argument (2
>>> given)
>>
>>> What am i doing wrong here?
>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/django-users?hl=en.
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django template : For Loop

2010-09-05 Thread Steve Holden
On 9/5/2010 12:29 PM, Jagdeep Singh Malhi wrote:
> 
>> If these objects are lists, say list1 and list2, in your view just
>> create a single object made up of pairs of elements from the original lists:
>>
>>values = zip(list1, list2)
>>
>> Then you can pass that item to your template and iterate over it.
> 
> I tried this, its not working.
> 
Sorry, but "not working" does not constitute useful information.

My car isn't working. Can you fix it? ;-)

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Django template : For Loop

2010-09-05 Thread Steve Holden
On 9/5/2010 7:54 AM, Jagdeep Singh Malhi wrote:
>> I have question about "for loop" used in Templates the correct
>> Syntax of using For Loop in template is : {% for X in VALUE %}
>> 
>> but I want to use For loop with two value Is it possible to use two
>> value in one loop? For example : {% for X, Y   in   VALUE1, VALUE2
>> %} Or {% for X in VALUE1  && Y in VALUE2 %}
>> 
>> These syntaxes are wrong, just for example. Is it possible to use
>> for loop  with two value in django templates? if yes, How?
>> 
>> Thanks
>> 
If these objects are lists, say list1 and list2, in your view just
create a single object made up of pairs of elements from the original lists:

   values = zip(list1, list2)

Then you can pass that item to your template and iterate over it.

In older Django you would have to use dot notation to select the elements:

 {% for x in VALUES %}
First item is x.0
Second item is x.1
 {% endfor %}

I believe in more recent versions you have the option of unpacking the
two elements in the for statement:

{% for x1, x2 in lists %}
...
{% endfor %}

but don't take that as gospel until you've tried it.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Getting last or max "id" value from database

2010-09-05 Thread Steve Holden
On 9/5/2010 3:12 AM, Jagdeep Singh Malhi wrote:
> I try to get the max value of id from database using max() function
> but a face this error.
> {
> TypeError at /add_db/
> 
> 'builtin_function_or_method' object is not iterable
> 
> Request Method:   POST
> Request URL:  http://localhost/django/add_db/
> Django Version:   1.2.1
> Exception Type:   TypeError
> Exception Value:  'builtin_function_or_method' object is not iterable
> 
> Exception Location:   /home/jagdeep/mysite/add_db/views.py in add_db,
> line 19
> Python Executable:/usr/bin/python
> }
> 
> model.py
> from django.db import models
> from django.forms import ModelForm
> 
> class Input(models.Model):
> input1 = models.FloatField()
> input2 = models.FloatField()
> 
> class Output(models.Model):
>   out = models.ForeignKey(Input)
>   output = models.FloatField()
> 
> class InputForm(ModelForm):
> class Meta :
> model = Input
> 
> class OutputForm(ModelForm):
> class Meta :
> model = Output
> 
> 
> 
> View.py
> from django.http import HttpResponseRedirect
> from django.shortcuts import render_to_response, get_object_or_404
> from mysite.add_db.models import *
> from django.template import RequestContext
> from django.core.urlresolvers import reverse
> 
> 
> def add_db(request):
> if request.method == 'POST':
> form = InputForm(request.POST)
> if form.is_valid():
> cd = form.cleaned_data
> input1 = cd['input1']
> input2 = cd['input2']
> form.save()
>   form_output = OutputForm()
>   output = input1 + input2
>   p = get_object_or_404(Input, pk=max(id))
> form_output_final = p.output_set.create(output=output)
> return render_to_response('add_db/output.html', {'form':
> form, 'input1':input1, 'input2':input2, 'output':output},
> context_instance=RequestContext(request))
> else:
> form = InputForm()
> return render_to_response('add_db/add.html', {'form': form},
> context_instance=RequestContext(request))
> 
> 
> I want to get the latest or maximum  "Id" value of INPUT table from
> database.
> 
> please help
> 
I'm not fully up to speed on the aggregate stuff, but I *think* what you
are trying to do is

from django.db.models import Max
maxid = Input.objects.aggregate(Max('id'))
p = Input.objects.get(pk=maxid)

No need to worry about the possibility of an exception, since the maxid
value is guaranteed to exist (as long as there's at least one row in the
table). This does, however, rely on the assumption that auto-increment
primary keys will be monotonically increasing.

Given that the ModelForm save() method actually returns the Input object
it has just created, wouldn't you be better simply saying

p = form.save()

and throwing away the code that does the database searching? Or have I
misunderstood the purpose of your code?

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



DjangoCon Jobs Board

2010-09-04 Thread Steve Holden
Looking to hire someone? Looking to get hired on? DjangoCon wants to help.

If you are an employer looking for staff (and whether or not you will be
at the conference), please sent a letter- or A4-sized original (PDFs
preferred) document that we can print out and attach to the jobs board
for display.

If you are looking for a job (and whether you will be at the conference
or not) please send an 8.5" x 5.5" or A5-sized original (PDFs preferred)
document that we can print our and attach to the jobs board.

We do not guarantee to display anything. This is a best-efforts attempt
to provide a service to the Django community.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: what to do instead of adding to Query.extra_where ?

2010-09-02 Thread Steve Holden
On 9/2/2010 1:44 AM, Paul Winkler wrote:
> Hah. That was a pretty long message relative to how quickly I found
> the answer myself :-p
> Sorry for the noise.
> 
> For posterity, extra(where=...) is indeed the solution. I overlooked
> the obvious:
> the class I was trying to fix is itself a subclass of QuerySet.  So
> given this line:
> 
> clone.query.extra_where += ('db_newsitem.id =
> db_attribute.news_item_id',)
> 
> the replacement is now:
> 
> clone = clone.extra(where=('db_newsitem.id =
> db_attribute.news_item_id',))
> 
> Seems to work fine.
> 
[...]

Once again this group proves itself at least as valuable as a stuffed
bear ;-)

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: How to display many-to-many field as a list of text input fields?

2010-09-02 Thread Steve Holden
On 9/2/2010 4:27 PM, adelein wrote:
> When I display the ToolBoxEditForm it uses a multiple select field.
> But what I want is a form that lets the user edit each tool he has in
> the toolbox as a text field. I cant figure out how to do this with the
> many-to-many field.
> 
A many-to-many relationship represents a constraint on the database,
which is therefore reflected by Django as a constraint in the user input.

What would you expect Django to do if the user enters the name of a
tool in your form that doesn't exist?

regards
 Steve

> class Tool(models.Model):
> tool_name = models.CharField(unique=True, max_length=200)
> ..
> 
> class ToolBox(models.Model):
> tools = models.ManyToManyField(Tool,max_length=300)
> 
> class ToolBoxEditForm (ModelForm):
> tools = ???
> class Meta:
>   model = ToolBox
>   exclude  = ('user', 'popularity',)
> 
> I would appreciate any pointers!
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: multiple oracle database queries in one request problem

2010-09-01 Thread Steve Holden
On 9/1/2010 5:54 PM, Reinout van Rees wrote:
> On 09/01/2010 02:00 PM, Reinout van Rees wrote:
>> Hi,
>>
>> I'm deploying a site on windows with oracle (and I don't know either of
>> them well). Simple apache+wsgi setup for now.
> 
> I'll have to test it out tomorrow when I'm near the windows machine
> again, but I might have found the solution in an existing bug report:
> http://code.djangoproject.com/ticket/13351
> 
> In a threaded situation (which you always have with mod_wsgi on
> windows), you apparently need to pass the cx_oracle database driver a
> threaded=True option (which is off by default).
> 
> So I added the following to my database config and I'm hoping I'll be
> happy tomorrow morning...
> 
> 'OPTIONS': {'threaded': True}
> 
> 
> I'll update the ticket when it helps.
> 
Good work!

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: fetching values from model

2010-09-01 Thread Steve Holden
On 9/1/2010 9:13 AM, Pradnya wrote:
>> ok. Is there any way I can load the model inside HTML template?
>> What is {% load  %} tag all about?
>> 
The {% load %} tag is for loading custom tags. Nothing to do with
accessing the database.

Why do you find it desirable to load records in the template?  What's
wrong with doing it in the view, which is what everyone else does and
how Django is intended to be used? See Jonas' remarks below.

regards
 Steve

>> On Sep 1, 6:02 pm, Jonas Geiregat  wrote:
 You don't write Python code inside your template file. That's
 one of the basic django template rules. You can pass values
 from your views to your template and show them there. Or
 generate the HTML in your view and show it from there, which
 isn't something I could advise if you're creating a larger
 application.
 
 Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
 
 
 
>> Hello,
 
>> Is it possible to fetch a particular record from model
>> using school.object.get(id = 1) inside html template.
 
>> Please suggest.
 
>> Thanks Pradnya
 
>> -- You received this message because you are subscribed to
>> the Google Groups "Django users" group. To post to this
>> group, send email to django-us...@googlegroups.com. To
>> unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com. For more
>> options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
 
 Met vriendelijke groeten,
 
 Jonas Geiregat jo...@geiregat.org
>> 

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



Re: potential issue re in memory django file uploading.

2010-08-30 Thread Steve Holden
Thanks for the reminder. I apologize.

regards
Steve

On Aug 30, 2010 10:04 PM, "Russell Keith-Magee" 
wrote:
>> On 8/30/2010 9:09 PM, dave b wrote:
>>> Do not pass go do not collect profit!
> ...
>>> Put your hands up in the air like you just don't care!
> ...
>>> blahblahblalbha sssh listen.
> ...
>
> On Tue, Aug 31, 2010 at 9:42 AM, Steve Holden  wrote:
>
>> Frankly, at this stage you can stick it up your ass and set fire to it
>> as far as I'm concerned. I like to delude myself that I am pretty
>> tolerant, but an ego the size of yours rubs me up the wrong way and I
>> start to forget my manners.
>
> Ok - before tempers get out of control, let's nip this in the bud.
>
> I don't care if the your weapon of choice is passive-aggressive
> expressions of pop culture, or detailed explorations of the
> appropriate application of incendiary products to bodily orifices --
> this kind of tone doesn't cast the community in a good light.
>
> We try to maintain a civil tone here. If you don't feel that you're
> able to maintain that tone, please walk away from this discussion.
>
> Yours
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: potential issue re in memory django file uploading.

2010-08-30 Thread Steve Holden
On 8/30/2010 9:09 PM, dave b wrote:
>>> Secure by default please!
>>
>> That's an easy epithet to throw around, but I disagree that it is
>> appropriate here. "Security" doesn't mean "stops the user from making
>> mistakes".
> 
> Look like wsgi, apache2 and django all on ubuntu PLACE no size limits
> at all by default. Isn't that neat?
> I think debian is the same too!
> Seriously, are you silly enough to think I was just using the
> development server for testing?
> Do not pass go do not collect profit!
> 
Talking that way to Russell Keith-Magee just makes you look like a
troll. If you think there is even a possibility that he is that silly
then you are clearly sadly deluded. Russell is well know throughout the
Django community (and outside it) for his deep understanding of the
issues and compromises involved in building a professional web framework.

You, on the other hand, are a complete unknown who has walked in off the
street and started to make a lot of noise. All this has achieved is to
demonstrate your total incomprehension of how to achieve practical
results, which despite your focus on only the technical issues that
interest you involves knowing how to interact with people as well.

It's kind of cute that you appear to think you might be smarter than me
(though you certainly don't have as much experience, and frankly I think
I would be likely to win in sheer sex appeal too). It's sheer lunacy to
think you might be smarter than Keith-Magee and Dumpleton (though you
may *just* beat Graham on people skills, he has the definite advantage
that he has demonstrated he knows what he's talking about).
> 
> 
>> it by default (i.e., no size limit). However, this relys on people
>> reading the documentation and determining an appropriate value for the
>> setting -- at which point, we've just duplicated the functionality of
>> Apache without actually changing anything.
> 
> Incorrect. Put it in the changelog etc.
> I meant people are supposed to know about apache and its setup surely
> they should read the changelog when django changes? right.
> 
>> IMHO, Graham is completely right when he says that the webserver is
>> the right place to catch this. Django isn't about to start introducing
>> more settings to duplicate functionality that is better provided by
>> other parts of the tool chain.
> 
> I disagree. Very much so. Stop saying this isn't a django issue and
> start fixing it.
> 
Who are you to tell the Django developers what to be doing? If you have
a demonstrated public record of making sound engineering decisions that
resulted in well-constructed systems, *then* your opinion might count
for something. You don't just need brains, you need to now how to use
them as well.
> 
>> That said, there has been discussion recently about adding a section
>> to Django's docs talking about security issues -- things that may not
>> be immediately obvious about project design and configuration, but
>> would behoove users to think about. A discussion of this problem
>> sounds like it would be a good addition.
> 
> Look you guys are saying that django is secure and then not willing to
> say "ok django might want to do something here". That's a great idea!
> 
> 
>>> Ok still following?
>>
>> Look -- Graham may not use Django on a daily basis, but he's not a
>> fool. For the record, neither am I. A cursory examination of his
>> history on this mailing list would indicate that saying "Add a
>> FileField uploading to /tmp to an existing model" would be more than
>> enough detail to describe your setup here.
>>
>> The part of this problem that you continue to refuse to describe is
>> *THE ONLY PART THAT MATTERS* - the web server configuration that
>> you're using to make your assertion.
> 
> The default wsgi apache2 setup on $distro is a good testing place for
> this if you want to test how people will likely have it setup, or was
> said to me in prior emails here. I have tested it against that setup
> of course and *against* *many* others.
> 
Sigh. It has already been clearly explained to you that the default
installation of anything isn't a reliable way to measure a platform's
fitness for purpose. If you want to run a production server on the
default installation of Apache how far do you think you will get?

The point is, serious people with serious production problems well
understand the issues that can come up, and the don't expect that the
products they use will meet their needs out of the box.

Go to Google and look up the phrase "one-trick pony". That's where I
have you filed right now.
> 
> 
>>> apache setup etc.).
>>
>> The implication here is that you *haven't* tried this with Apache.
>> Worse still, it sounds like you might be trying to use the Django
>> development server as your test case to validate that this is a
>> problem.
> 
> I can assure you I have tested this against apache2 with wsgi running
> with django.
> 
But still you refuse to show us the results? That seems a bit perverse.
> 
>>> What do you say

Re: Overriding flatpages class meta

2010-08-29 Thread Steve Holden
On 8/29/2010 6:51 PM, Goran wrote:
> Thanks for the answer Steve. I'm Django and Python novice and here is
> what I was try. But it doesn't work.
> 
> from django.contrib.flatpages.models import FlatPage
> 
> class NewFlatpage(FlatPage):
> 
> class Meta:

The Meta class would need to subclass FlatPage.Meta, otherwise it won't
have the necessary FlatPage special sauces. I don't guarantee even that
will work, but try

class NewFlatpage(FlatPage):

class Meta(FlatPage.Meta):
verbose_name_plural = "New_name"

regards
 Steve

> verbose_name_plural = "New_name"
> 
> 
> 
> On Aug 26, 4:39 am, Steve Holden  wrote:
>> On 8/25/2010 8:26 PM, Goran wrote:> I need another verbose_name_plural for 
>> Flat pages so i need to
>>> overrideclassmetafor it right? How can I do that?
>>
>> [Caveat: this is a guess from general Python knowledge]
>>
>> Have you tried creating a subclass of Flatpage, whose body simply
>> declares aMetaclasswhich is a subclass of Flatpage.Meta?
>>
>> regards
>>  Steve
>> --
>> DjangoCon US 2010 September 7-9http://djangocon.us/
> 


-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Unable to add two Numbers

2010-08-29 Thread Steve Holden
On 8/29/2010 1:20 PM, Harbhag Singh Sohal wrote:
> i am the new user of Django, i try the tutorials of  django wesite
> http://docs.djangoproject.com/en/1.2/intro/tutorial01/
>  
> 
> 
> Now i create a application in django to add two numbers, After filling form.
> and store the values of two inputs and output after add two numbers in
> databases.
> 
> me able to create form and database using model.py file and using template,
> but me face problem to store the two input value in database after
> filling in form text box.
> 
> me try use request.POST function to get the value, but me also fail to
> get the form values.
> 
> Please suggest me how i get the value from form text fields and store
> in database.
> 
Harbagh:

Your question is the approximate equivalent of:

  "I have a car, but when I try to drive it it doesn't work"

You don't show any code, you don't give us any error messages, you don't
describe the failure mode at all. You simply say that you fail tp get
the form values and you "face a problem" in storing the information in
the database.

Is it that you don't know how to write the code, or that the code you
have written isn't working.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: potential issue re in memory django file uploading.

2010-08-29 Thread Steve Holden
On 8/29/2010 8:07 AM, dave b wrote:
>> An attacker could also assemble a powerful explosive device and detonate
>> it near enough your hosting service to take your site down. What
>> counter-measures are you going to take against that?
> 
> Good question. I have two cats and they like to lick people ^^
> They are a bit friendly I guess. Do you think I can train them to
> pounce on strangers?
> 
> 
>> You perhaps feel people aren't taking your proposal seriously enough.
>> The fact of the matter is that security is never absolute, and on a
>> threat scale of 0 to 10 this issue comes in at about 1.7. If you are
>> running a professional service and you are monitoring it correctly then
>> you ought to notice an attack of this nature before it does too much damage.
> 
> Look I send you guys an email, I send a patch for one of the problems
> and point out the second one. I just can't make you guys happy can I ?
> 
> http://cwe.mitre.org/top25/
> [22]  145 CWE-770 Allocation of Resources Without Limits or 
> Throttling
> http://cwe.mitre.org/top25/#CWE-770
> But ok if you say so ;)
> I wonder how much ram most django commonly found django installations
> that allow file upload on the internet have?  now remember a lot of
> those have a fairly fast download and upload ;)
> bonus points if they have mod_deflate decompressing the user body request ;)
> 
>> I repeat, you may be correct in treating this as a vulnerability, but
>> your estimate of its seriousness appears to disagree with that of
>> others. If you want to have your code seriously considered for inclusion
>> (and why not?) you should raise it in the Django issue tracker - see
>> "Reporting Bugs" in
> 
> I did as I was suggested to do so :)
> Some one first told me on irc in #django that I should raise it here first :)
> 
> Please see http://code.djangoproject.com/ticket/14192

That's cool. Sorry I nagged you unnecessarily. Yes, it might be a
problem. But you'll notice it's #22 on a list of 25 ...

Anyway, since you have done your civic duty there's a good chance that a
fix will find its way into some future version. Thanks for being a good
citizen.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: potential issue re in memory django file uploading.

2010-08-29 Thread Steve Holden
On 8/29/2010 7:43 AM, dave b wrote:
>> OK, so you don't believe the advice you are getting, which is that of
>> the many issues a Django sit will face this is a relatively low
>> probability attack. That's fair enough - a vulnerability is a
>> vulnerability, after all, no matter how improbable, and not everyone
>> will set up their production systems to be correctly protected by a
>> front-end server.
>>
>> If you really want to see this in Django you would be better advised to
>> post it in the issue tracker, where it will not get lost.
>>
>>
> 
> Ok I will do this :-)
> 
> Sure Also, Wow gmail is a horrible email client. I am so used to $else.
> The patch I included in my previous email should not break any *real*
> clients, only evil ones(potentially).
> 
> As I understand it an attacker can abuse gzip user requests, if
> mod_deflate is enabled (AND configured to decompress incoming user
> requests - this is not the default)  in apache2 with a user gziped
> request body.
> 
> So an attack could do effectively have a file like this:
> 
> f = open("rar", "w")
> string = ""
> for i in range(0, 1000):
>   string += " " + "1"
> f.write(string)
> f.close()
> 
> ls -lah 20M 2010-08-29 17:15 rar
> 
> (except replace write with append and do it a lot more ;) )   and then
> send it gziped as in the request body.
> 
> Just for fun ;)
> gzip rar
> ls -lah 19K 2010-08-29 17:15 rar.gz
> 
> So  django will receive the original 20M file (as the httpd has
> uncompressed it for django ) afaik.
> 
> see Input Decompression at 
> http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

An attacker could also assemble a powerful explosive device and detonate
it near enough your hosting service to take your site down. What
counter-measures are you going to take against that?

You perhaps feel people aren't taking your proposal seriously enough.
The fact of the matter is that security is never absolute, and on a
threat scale of 0 to 10 this issue comes in at about 1.7. If you are
running a professional service and you are monitoring it correctly then
you ought to notice an attack of this nature before it does too much damage.

I repeat, you may be correct in treating this as a vulnerability, but
your estimate of its seriousness appears to disagree with that of
others. If you want to have your code seriously considered for inclusion
(and why not?) you should raise it in the Django issue tracker - see
"Reporting Bugs" in

  http://docs.djangoproject.com/en/1.2/internals/contributing/

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: potential issue re in memory django file uploading.

2010-08-29 Thread Steve Holden
On 8/29/2010 12:05 AM, dave b wrote:
> On 29 August 2010 13:33, Graham Dumpleton  wrote:
>>
>>
>> On Aug 29, 1:17 pm, dave b  wrote:
>>> On 29 August 2010 08:28, Steve Holden  wrote:
>>>
>>>> On 8/28/2010 6:10 PM, Graham Dumpleton wrote:
>>>>> On Aug 28, 11:21 pm, dave b  wrote:
>>>>>>>>> So obviously my proposed attack is to simply say "content length is
>>>>>>>>> tiny" and "this file is actually HUGE".
>>>> [...]
>>>>> All up, I would suggest you are getting worked up over nothing.
>>>> +1
>>>
>>> Yes I have :) it "works for me tm".
>>> Also, you have to consider the other problem. If the file is > 2.5 mb
>>> it can be put in /tmp and this has no size limits which again is going
>>> to make the system slower and can be used to attack it? in either case
>>> there seem to be real protections against this in django core as far
>>> as I can see.
>>
>> Use Apache/mod_wsgi and you can say:
>>
>>  LimitRequestBody 100
>>
>> and Apache/mod_wsgi will give back a HTTP_REQUEST_ENTITY_TOO_LARGE
>> error when it goes over that size before it even passes the request to
>> Django and even before any of the request content is read by Apache.
>>
>> So, add the protections where most appropriate if you want to outright
>> block requests with large content. If your issue is efficient handling
>> of large posts, where you do want to handle them, then that is an
>> issue for Django.
>>
>> Note that other Apache modules by which you can host Django may not
>> work properly in honouring LimitRequestBody directive of Apache. The
>> mod_python module for example doesn't really get it right, causing an
>> exception when request content tries to be read by Django application,
>> resulting in a malformed error response.
> 
> Yes I understand that both apache and some the mods have limits.
> However, this doesn't stop a persistent attacker abusing these
> relatively high limits.
> IMHO I feel that django should be able to put a cap on the largest
> size temporary file size possible. In addition, /tmp is a fine place
> to store temporary files if the size may not be known.
> 
> I propose the following in psudo code:
> 
> 1. start reading the file if we are receiving it (regardless of the
> default 2.5 mb limit)
> 2. once it goes over 2.5mb / the configured default  shift to the next
> available storage option.
> 
> In addition, as you are pointing out that it is really not possible
> for django to handle chunked requests and the content length field
> must be specified then you should have no problems with the following
> patch (in either case this is safe because by default it will revert
> back to the temporary file storage) :
> 
> 
> --- django/core/files/uploadhandler.py.orig   2010-08-29 13:50:17.0 
> +1000
> +++ django/core/files/uploadhandler.py2010-08-29 14:01:15.0 
> +1000
> @@ -153,7 +153,7 @@
>  """
>  # Check the content-length header to see if we should
>  # If the post is too large, we cannot use the Memory handler.
> -if content_length > settings.FILE_UPLOAD_MAX_MEMORY_SIZE:
> +   if content_length is None or content_length >
> settings.FILE_UPLOAD_MAX_MEMORY_SIZE:
>  self.activated = False
>  else:
>  self.activated = True
> @@ -170,6 +170,7 @@
>  """
>  if self.activated:
>  self.file.write(raw_data)
> +   self.file.truncate(settings.FILE_UPLOAD_MAX_MEMORY_SIZE)
>  else:
>  return raw_data
> 
> http://pastebin.com/5vgGMb5z
> 
OK, so you don't believe the advice you are getting, which is that of
the many issues a Django sit will face this is a relatively low
probability attack. That's fair enough - a vulnerability is a
vulnerability, after all, no matter how improbable, and not everyone
will set up their production systems to be correctly protected by a
front-end server.

If you really want to see this in Django you would be better advised to
post it in the issue tracker, where it will not get lost.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



  1   2   3   4   >