Thursday, August 30, 2012

Making a MockPortal project and app, with login and Templates

Scenario:
making a MockPortal app.

- MockPortal project = startproject
- MockPortal app = startapp







django-admin.py startproject mockportal http://www.djangobook.com/en/2.0/chapter02/
/mockportal
manage.py
/mockportal/settings.py
=edit the settings.py 'UTC'
=http://192.168.195.136:8020/asdf Start your first app by running python manage.py startapp [appname].
python manage.py startapp mockportal_app
/mockportal
manage.py
/mockportal/settings.py
/mockportal_app/views.py




Scenario: Create a basic login page
https://docs.djangoproject.com/en/dev/topics/auth/ User authentication in Django | Django documentation | Django

Note that if you don't specify the login_url parameter, you'll need to map the appropriate Django view to settings.LOGIN_URL. For example, using the defaults, add the following line to your URLconf:
(r'^accounts/login/$', 'django.contrib.auth.views.login'),

python manage.py syncdb To get the auth table 'django_session'





Scenario: Put a template for the basic login page. PATH: where on the filesystem?
http://www.djangobook.com/en/2.0/chapter04/
With TEMPLATE_DIRS set, the next step is to change the view code to use Django’s template-loading functionality rather than hard-coding the template paths. Returning to our current_datetime view, let’s change it like so:
Sample base templates and login templates:
http://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/
https://bitbucket.org/devdoodles/registration_templates/src








If you don't want to use the built-in views
not having to write forms for this functionality
NEWDOCS https://docs.djangoproject.com/en/dev/topics/auth/#module-django.contrib.auth.forms
OLDDOCS https://docs.djangoproject.com/en/1.0/topics/auth/#module-django.contrib.auth.forms

Built-in forms
If you don't want to use the built-in views, but want the convenience of not having to write forms for this functionality, the authentication system provides several built-in forms located in django.contrib.auth.forms:

class AdminPasswordChangeForm
A form used in the admin interface to change a user's password.

class AuthenticationForm
A form for logging a user in.

#################################################


























No comments:

Post a Comment