Hello fellow Django developers, I would like to request your assistance on a caveat I ran into when doing slugs in the django url's.
First off please let me lay out what I've been building: Here are the internals of my urls.py: (r'^artists/register/$', 'madtrak.userprofiles.views.ArtistRegistration' ), (r'^artists/login/$', 'madtrak.userprofiles.views.ArtistLoginRequest'), (r'^artists/logout/$', 'madtrak.userprofiles.views.ArtistLogoutRequest' ), (r'^artists/(?P<artistreq>[a-zA-Z0-9]+)/$', 'madtrak.userprofiles.views.ArtistProfile'), Here are some relevant views.py functions: # Artist Profile def ArtistProfile(request, artistreq): artist_object = Artist.objects.filter(artisturl = artistreq) return render_to_response('artistprofile.html', {'Artist': artist_object}, context_instance = RequestContext(request)) and # Artist Registration def ArtistRegistration(request): if request.user.is_authenticated(): return HttpResponseRedirect('/artists/profile') if request.method == 'POST': form = ArtistRegistrationForm(request.POST) if form.is_valid(): # If information entered is valid create the user # user = User.objects.create_user('john', 'len...@thebeatles.com', 'johnpassword') artistusername = form.cleaned_data['artistusername'] artistemail = form.cleaned_data['artistemail'] artistpassword = form.cleaned_data['artistpassword'] artistuser = User.objects.create_user(username=artistusername, email=artistemail, password=artistpassword) # Save new user to the database artistuser.save() artist = Artist(artistuser=artistuser, artistname=form.cleaned_data['artistname'], artistbirthday=form.cleaned_data['artistbirthday'], artisturl=form.cleaned_data['artisturl']) artist.save() return HttpResponseRedirect('/artists/profile/') else: return render_to_response('registerartist.html', {'form': form}, context_instance=RequestContext(request)) else: ''' user is not submitting the form, show the blank registration form ''' form = ArtistRegistrationForm() context = {'form': form} return render_to_response('registerartist.html', context, context_instance = RequestContext(request)) So, basically here is the caveat: If a user requests artists/register the site goes to hell. Why? well it's because as you might have guessed that request also fits the regex expression listed where I url config'd (r '^artists/(?P<artistreq>[a-zA-Z0-9]+)/$', 'madtrak.userprofiles.views.ArtistProfile'), and so the url config does not behave as I desired. Or if I requested likewise if you put artists/ [artistuser] it collides still with the rest of the url configs. So, my quick fix and was: (r'^artists/register/$', 'madtrak.userprofiles.views.ArtistRegistration' ), (r'^artists/login/$', 'madtrak.userprofiles.views.ArtistLoginRequest'), (r'^artists/logout/$', 'madtrak.userprofiles.views.ArtistLogoutRequest' ), (r'^artists/profile/(?P<artistreq>[a-zA-Z0-9]+)/$', 'madtrak.userprofiles.views.ArtistProfile'), which thereby says hey if I only see artists/profile/ and then the requested artists profile then I behave as desired and return that artists public profile. Which makes sure it is obviously not listening at just artists/ [anything else] Yet the thing is I REALLY want to be able to have it is I originally had it. I like how clean it is. I strongly desire the situation where I can host all the registration, login, logout, and any other systems that I desire following the artists/ but also want to be able to also cleanly host all artists usernames following the artists/ so that it properly querys the db and returns that artists profile. I was thinking maybe I could hack this out with python regex or something of the like but is there a way in django to hack this together? Thanks so much, JJ -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.