Malcolm Tredinnick wrote:
> On Fri, 2008-10-03 at 13:29 -0400, Steve Holden wrote:
>   
>> Alexis Bellido wrote:
>>     
>>> Cool, thanks for the confirmation. I'm still devouring all the
>>> documentation, a couple of books and practicing a lot on Django :)
>>>   
>>>       
>> One of the things I find tricksiest about learning new Django code is
>> that the connections between the URLs and the views can often turn out
>> to be a maze of twisty little passages, all alike. It's difficult (for
>> me, anyway - maybe there's some obvious technique I have overlooked) to
>> trace which pieces of code and which URLs are associated.
>>     
>
> Hmm... this is getting off-topic a bit for this thread, but can you
> elaborate a bit more on what you mean here? I can't say this was
> something that every seemed tricky to me with Django, but I know
> different people learn and think differently, so it would be interesting
> to hear where there hidden shoals might be.
>
> It feels like it should be as simple as being a reg-exp pattern that
> captures some parameters and calls a view passing in those parameters
> and possible some extra ones. You can also give each pattern a name.
>
> I'm not mocking here. I'd like to hear how this can be hard so that I
> can at least experiment with some alternative explanations in the future
> when talking to people.
I'll do my best to explain, but it's a little difficult to "go back and
do it again" once the issues are past. It may be that I am complaining
about the specific apps I have dealt with rather than Django generally.
Or it may just be that there's something fundamental I've overlooked. I
accept that you aren't mocking, but I know you will appreciate that it's
difficult to confess ignorance at this apparently fundamental level when
you've been working with the web for some while.

I have just spent some time looking at how I can add user profiles to a
test site, and decided this would best be done by adding the
django-registration and django-profiles apps to it. Getting the code in
was relatively easy -- about the only thing I had to do was fix up a
newforms import. However, since I couldn't find much generic advice on
gluing these bits and pieces together I am quite prepared to accept that
it may just be because I've botched the job.

I think from memory the most difficult issue was with the named URLs, as
there is no definitive mapping between the textual names, the URL
components and the names. (I realize that the names have been made close
to the names of the views they map to, but knowing where to find them
does require some familiarity with the code).

Further, common URL prefixes don't necessarily map to views in the same
module (though this could be my misconfiguration). I have attached (to
avoid wrapping issues) a text file showing the various URLconfs that are
(or should be) configured into my application. It's ended up as a bit of
a dog's breakfast, having been patched together in a less-than-optimal way.

What I was hoping for was to be able to generate some clear state
transition diagram showing the sequences of URLs that particular actions
like registering a new user, adding a profile and editing it, and so on
would go through, along with the templates I would have to prepare and
the available contexts for each template. So I suppose it's not really
the individual mappings I find troublesome as much as the overall task
flow. *Is* this just me?

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

BASE SITE

    (r'^$', homepage),
    (r'^(students/.*)/$', stdpage),
    (r'^(py)/$', stdpage),
    (r'^(py/.*)/$', stdpage),
    (r'^(partners)/', stdpage),
    (r'^(partners/.*)/$', stdpage),
    (r'^(review/.*)$', stdpage),
    (r'^(opensource)/$', stdpage),
    (r'^(projects)/$', stdpage),
    (r'^(thankyou)/$', stdpage),
    (r'^(family)/$', stdpage),
    (r'^(training)/$', stdpage),
    (r'^(about)/$', stdpage),
    (r'^(search)/$', stdpage),
    (r'^registration/', include("registration.urls")),
    (r'^grp/', include('grp.urls')),
    (r'^(contact)', include('contact.urls')),
    url(r'^accounts/register/$',
        registration.views.register,
        {"profile_callback": hwprofile.models.create_profile},
        name='registration_register'),
    # Non-overridden register package
    (r'^accounts/', include('registration.urls')),
    (r'^accounts/profile/', 'hwprofile.views.postlogin'),
    (r'^accounts/password/reset/complete/$', 
django.contrib.auth.views.password_reset_complete, {}, 
'password_reset_complete'),
    (r'^accounts/password/reset/confirm/(?P<token>.+)/(?P<uidb36>\d)/$', 
django.contrib.auth.views.password_reset_confirm, {}, 'password_reset_confirm'),
    (r'^accounts/firstlogin/$', django.contrib.auth.views.logout_then_login),
    # profiles package
    (r'^profiles/', include('profiles.urls')),

    # Uncomment the next line to enable admin documentation:
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    #(r'(accounts/profile)$', profile),
    #(r'^accounts/', include('registration.urls')),
    # Uncomment this for admin:
    (r'^admin/(.*)', admin.site.root),

DJANGO PROFILES (prefix: /profiles/)

                       url(r'^create/$',
                           views.create_profile,
                           name='profiles_create_profile'),
                       url(r'^edit/$',
                           views.edit_profile,
                           name='profiles_edit_profile'),
                       url(r'^(?P<username>\w+)/$',
                           views.profile_detail,
                           name='profiles_profile_detail'),
                       url(r'^$',
                           views.profile_list,
                           name='profiles_profile_list'),

DJANGO REGISTRATION (prefix: /accounts/)

                       url(r'^activate/(?P<activation_key>\w+)/$',
                           activate,
                           name='registration_activate'),
                       url(r'^login/$',
                           auth_views.login,
                           {'template_name': 'login.html'},
                           name='auth_login'),
                       url(r'^logout/$',
                           auth_views.logout,
                           {'template_name': 'logout.html'},
                           name='auth_logout'),
                       url(r'^password/change/$',
                           auth_views.password_change,
                           name='auth_password_change'),
                       url(r'^password/change/done/$',
                           auth_views.password_change_done,
                           name='auth_password_change_done'),
                       url(r'^password/reset/$',
                           auth_views.password_reset,
                           name='auth_password_reset'),
                       url(r'^password/reset/done/$',
                           auth_views.password_reset_done,
                           name='auth_password_reset_done'),
                       url(r'^register/$',
                           register,
                           name='registration_register'),
                       url(r'^register/complete/$',
                           direct_to_template,
                           {'template': 
'registration/registration_complete.html'},
                           name='registration_complete'),

DJANGO.CONTRIB.AUTH (oops: not mapped into my URLconf at all)

    (r'^login/$', 'django.contrib.auth.views.login'),
    (r'^logout/$', 'django.contrib.auth.views.logout'),
    (r'^password_change/$', 'django.contrib.auth.views.password_change'),
    (r'^password_change/done/$', 
'django.contrib.auth.views.password_change_done'),
    (r'^password_reset/$', 'django.contrib.auth.views.password_reset'),
    (r'^password_reset/done/$', 
'django.contrib.auth.views.password_reset_done'),
    (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 
'django.contrib.auth.views.password_reset_confirm'),
    (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),

Reply via email to