On Wed, Jul 22, 2009 at 10:39 PM, Joshua Russo <josh.r.ru...@gmail.com>wrote:

> On Wed, Jul 22, 2009 at 10:58 AM, Divesh Gidwani <dagidw...@gmail.com>wrote:
>
>>
>> Also, what kind of views do I need? I'm really confused about that
>> part.
>
>
> If you want to mimic the current application you will need to create custom
> views and forms. It's really easy once you get the idea, but it's taken me a
> couple of go-a-rounds to get the concepts solidified in my own head. The
> following is an extremely simplified version of a form I have on the home
> page of the app I'm working on.
>
> I'll start from urls.py:
>
> from adminTributaria.matriz import views
> ...
> urlpatterns = patterns('',
>     ...
>     (r'^$', views.bemvindo)
> )
>
> Next views.py in my app called matriz:
>
> from django import template
> from django.shortcuts import render_to_response
>
> from adminTributaria.matriz.forms import BemvindoForm
>
> def bemvindo(request):
>     if request.method == 'POST':
>         curForm = BemvindoForm(request.POST)
>         if curForm.is_valid():
>             # Your form passed validation, do what you want with the data
> here
>             # The cleaned_data dictionary will have proper Python objects
>             curMatrizID = curForm.cleaned_data['matrizID']
>             ...
>     else:
>         curForm = BemvindoForm()
>
>     context = {
>         'title': _('Home'),
>         'form': curForm
>     }
>
>     return render_to_response('matriz/index.html', context,
>             context_instance=template.RequestContext(request))
>
> Now the forms.py in matriz:
>
> from django import forms
>
> class BemvindoForm(MyForm):
>     matrizID     = forms.IntegerField()
>     ...
>
>
> The only thing that I haven't shown here is the template. For my templates,
> I generally take a copy of base.html in
> django\contrib\admin\templates\admin\. I'll modify that how I like and then
> inherit from it. The template inheritance is really slick.
>
> I would recommend reading these sections of the docs:
> http://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-urls (If
> you are weak in the area of regular expressions, take time to understand
> them here, it makes all the difference)
> http://docs.djangoproject.com/en/dev/topics/http/views/#topics-http-views
> http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index
> http://docs.djangoproject.com/en/dev/topics/templates/#topics-templates
>

Sorry, cut and paste error

class BemvindoForm(MyForm):
should be
class BemvindoForm(forms.Form):

I subclassed forms.Form in my app

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to