Re URLs

Have look at 
http://itekblog.com/django-url-dispatcher-routing-beginners-tutorial/  ... 
and  bear in mind that the 'r' and the '^' are not directly related and 
serve two purposes.  

The very basic "overview" of Django is that urls point to views; views 
typically make use of models (and other bits-and-pieces such as forms or 
business logic code) to help handle data going in and/or out; and models 
are mapped to tables in your database (and themselves have code to help 
ensure data integrity).  Very logical and not *too* hard!

Without those layers, your web app ends up being a huge mish-mash of code 
and data and HTML ... like "old skool" PHP.  Easy to start off, but a 
nightmare to maintain as it gets more complex.

Derek

On Saturday, 20 July 2013 17:17:06 UTC+2, Randy Baxley wrote:
>
> The Django tutorial is not quite making it for me.  This is a very 
> complicated language and all the pieces seem to not match up for me.  This 
> I think is my fault and most of it seems to be in the use of the r hat for 
> root and exactly how that points to views, models and dbs.  I may get there 
> but it is not easy without someone to be a sort of guide.  Each time though 
> I go into settings or one of the other files they get a perception of being 
> more familiar and thus shorter.  While doing some of those I say a key set 
> to fals for allow profanity but not sure what all that filter has passed 
> through it.
>
>
> On Sat, Jul 20, 2013 at 8:20 AM, Tim Chase 
> <django...@tim.thechases.com<javascript:>
> > wrote:
>
>> On 2013-07-18 20:53, Sivaram R wrote:
>> >   While saving these forms instance,is it possible to create a
>> > random string for username field.How to do this,any sample would be
>> > great choice.
>>
>> You can.  Assigning random usernames isn't usually considered a very
>> nice thing to do to users, but assuming you have a valid use-case
>> for it, it's just simple Python:
>>
>>   import random
>>   import string
>>   def random_username(characters=string.ascii_lowercase, length=10):
>>     return ''.join(
>>       random.choice(characters)
>>       for _ in range(length)
>>       )
>>
>> You might also want to post-process to check for profanity in it, as
>> you you don't (usually) want to assign profanity as a username:
>>
>>   BAD_WORDS = [ ... ] # all in uppercase
>>   while True:
>>     username = random_username()
>>     normalized_username = random_username.upper()
>>     for word in BAD_WORDS:
>>       if word in normalized_username:
>>         break
>>     else: # note this is at the indentation level of the "for", not "if"
>>       break
>>   print "Username:", username
>>
>> It's not a perfect check, but it will eliminate the obviously
>> problematic ones based on your black-list
>>
>> -tkc
>>
>>
>> --
>> 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...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

-- 
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.


Reply via email to