Re: Sane defaults for Startapp and Startproject

2011-10-19 Thread Aymeric Augustin
On 19 oct. 2011, at 00:21, Rich Jones wrote:
> Here's some of what I propose. I'm not suggesting this be a canonical
> list of features by any means, I'm just suggesting that django have
> more convenient default settings. We should look at the most common
> conventions and best practices and shape the defaults towards them.

Hello,

Collecting static files and putting media uploads in the "project directory" 
(whatever that means) isn't really a best practice. In production, the code 
area should be read-only for the web server user: code goes in /usr/... and 
data in /var/www/...

In order to make deployment easier, I also recommend putting site-wide 
templates and templatetags in an application, and keeping TEMPLATE_DIRS empty, 
but that's a personal preference.

There are many ways to specialize settings by environment, and 
local_settings.py is only convenient for the smallest projects — as soon as two 
people work on the project, it's better to have "dev.py" / "prod.py" and to 
symlink or import * from the appropriate module.

Sorry for sounding negative, but I'm also against import pollution.

In short, I think that Django is a general purpose framework, and putting 
default values geared towards one-man projects isn't good for us in the long 
term. I prefer if newcomers have to read the appropriate page of the doc — 
discovering in the process that we have an excellent documentation — rather 
than blindly use the template loader or the static files without understanding 
it, and then complain that it breaks when they deploy to production.

Following Carl's cleanup of the PYTHONPATH mess, we considered writing a 
documentation page about project layout. It would touch many of the points 
discussed in your proposal. I think that's the best solution to the question 
discussed here: "how should I organize my (first) Django project?"

Best regards,

-- 
Aymeric Augustin.

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



Re: Sane defaults for Startapp and Startproject

2011-10-19 Thread Gabriel Hurley
Thanks for the suggestions, Rich... I'll try not to repeat what others have 
said, but have a couple notes to add:

should create ./static, ./uploads and ./newproj and ./newproj/ 
> templates 
>

I could get behind static, and *maybe* even templates, but absolutely not 
uploads. I would argue against Django automatically creating any directories 
inside your project that you wouldn't ever want to check into your VCS, and 
I definitely don't want my user uploads ever getting checked in to my repos. 
As others have noted, there are many other solutions for how those should be 
handled.
 

> and at the end, the commonly used from local settings import * block. 
>

Others have already spoken out against this, but as extra corroboration see 
our lovely BDFL Jacob's "Best and Worst of 
Django" 
presentation (particularly slides 46-51) where he argues against this 
explicitly (and rightly, IMHO).
 

As for the rest: I don't believe in adding magic in order to save a couple 
lines of typing (explicit > implicit), but I am in favor of things we can do 
to encourage best practices where the community agrees. So to that task I 
wish you excellent luck!

All the best,

- Gabriel

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



Re: Sane defaults for Startapp and Startproject

2011-10-19 Thread Andre Terra
Hi all,

On Wed, Oct 19, 2011 at 5:50 AM, Gabriel Hurley  wrote:

> Thanks for the suggestions, Rich... I'll try not to repeat what others have
> said, but have a couple notes to add:
>
> ()
>
> As for the rest: I don't believe in adding magic in order to save a couple
> lines of typing (explicit > implicit), but I am in favor of things we can do
> to encourage best practices where the community agrees. So to that task I
> wish you excellent luck!
>
> All the best,
>
> - Gabriel
>

I think you hit the nail on the head. This sounds to me like exactly what we
need to discuss, regardless of how we address it. I'm not in favor of adding
too much magic to startapp/startproject, except for maybe the templates dir,
its relative import and explicitly listing every default settings
(AUTHENTICATION_BACKENDS included). Again, explicit > implicit.

I do however believe that we need to create a section in the docs with some
suggestions as to how to layout your project. Perhaps your blog post could
be turned into a documentation patch? Too often when I was starting with
Django I felt the need for such a guide, and even though we may not agree on
one single solution, we should at least point to some "canonical"
alternatives which we believe constitute best practices.

"Give a man a fish and you feed him for a day. Teach a man how to fish and
you feed him for a lifetime."

This is a valid concern and request, and any experienced user will know
enough Python and Django to roll out their own customized setup.


Cheers,
AT

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



Re: Towards a more friendly NoReverseMatch

2011-10-19 Thread Wilfred Hughes
I've opened a ticket for improving the NoReverseMatch error:
https://code.djangoproject.com/ticket/17076

However, I'd still like to improve the documentation regarding which
patterns can be reversed. I don't fully understand the limitations
myself yet.

1. Can we provide an example of a pattern containing "|" that doesn't
work? I've successfully reversed the pattern r'^fruit/(bananas|apples)
$' above.

2. Can we give a more precise description of the limits of reversible
patterns? Is it just that the arguments / keyword arguments must match
up (looking at 
https://github.com/django/django/blob/master/django/core/urlresolvers.py#L364
this seems to be only obvious limitation)?

On Oct 12, 4:13 pm, Wilfred Hughes  wrote:
> > >    >>> reverse('i_dont_exist')
> > >    NoReverseMatch: Reverse for 'i_dont_exist' with arguments '()' and
> > > keyword arguments '{}' not found.
>
> > > In this case, it would be nicer to have something like:
>
> > >    NoURLPattern: No patterns specified for 'i_dont_exist'.
>
> > Just on this point, I must disagree. For instance, consider if you
> > have a URL named 'i_dont_exist', and the URL pattern has two
> > positional arguments.
>
> Ah, sorry. I've been unclear. My point here is that when there /isn't/
> a URL with that name. It would be good to distinguish between having
> no regexes and not being able to reverse the regex.
>
> So, if I have an URL:
>
>     url(r'^fruit/(bananas|apples)$', some_view, name='fruit'),
>
> And I make a spelling mistake:
>
>     >>> reverse('rfuit', args=['bananas'])
>
> I would like some hint that the problem isn't in my regex. The two
> options I'm proposing are:
>
>     NoURLPattern: No patterns specified for 'rfuit'.
>
> Or:
>
>     NoReverseMatch: Reverse for 'rfuit' with arguments '()' and
> keyword arguments '{}' not found (patterns tried: []).

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



Re: Sane defaults for Startapp and Startproject

2011-10-19 Thread Gabriel Hurley
I think there is sufficient interest in the idea of a "how to organize your 
Django project" page in the documentation that it would be worth beginning 
work on a patch for one, much in the way that the "How to contribute to 
Django"/"Spirit of contributing" page got started.

That means:

  1. Opening a ticket for it if one doesn't already exist.
  2. Creating a wiki page to start crafting the text where everyone can 
contribute.
  3. Writing an initial draft to get the ball rolling.
  4. Working with the mailing list to garner attention and consensus.
  5. Writing a patch in proper reST once general consensus has been reached.

I think there are going to be quite a few different opinions on this topic, 
so structuring it in such a way as to provide "Common patterns" with pros 
and cons of each would be a wise way to go about it.

All the best,

- Gabriel

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