Search Results

Search found 3 results on 1 pages for 'sevenearths'.

Page 1/1 | 1 

  • django {% tag %} problem

    - by Sevenearths
    I don't know if its me but {% tag ??? %} has bee behaving a bit sporadically round me (django ver 1.2.3). I have the following main.html file: <html> {% include 'main/main_css.html' %} <body> test! <a href="{% url login.views.logout_view %}">logout</a> test! <a href="{% url client.views.client_search_last_name_view %}">logout</a> </body> </html> with the urls.py being: from django.conf.urls.defaults import * import settings from login.views import * from mainapp.views import * from client.views import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^weclaim/', include('weclaim.foo.urls')), (r'^login/$', 'login.views.login_view'), (r'^logout/$', 'login.views.logout_view'), (r'^$', 'mainapp.views.main_view'), (r'^client/search/last_name/(A-Za-z)/$', 'client.views.client_search_last_name_view'), #(r'^client/search/post_code/(A-Za-z)/$', 'client.views.client_search_last_name_view'), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), (r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}), ) and the views.py for login being: from django.shortcuts import render_to_response, redirect from django.template import RequestContext from django.contrib import auth import mainapp.views def login_view(request): if request.method == 'POST': uname = request.POST.get('username', '') psword = request.POST.get('password', '') user = auth.authenticate(username=uname, password=psword) # if the user logs in and is active if user is not None and user.is_active: auth.login(request, user) return redirect(mainapp.views.main_view) else: return render_to_response('loginpage.html', {'login_failed': '1',}, context_instance=RequestContext(request)) else: return render_to_response('loginpage.html', {'dave': '1',}, context_instance=RequestContext(request)) def logout_view(request): auth.logout(request) return render_to_response('loginpage.html', {'logged_out': '1',}, context_instance=RequestContext(request)) and the views.py for clients being: from django.shortcuts import render_to_response, redirect from django.template import RequestContext import login.views def client_search_last_name_view(request): if request.user.is_authenticated(): return render_to_response('client/client_search_last_name.html', {}, context_instance=RequestContext(request)) else: return redirect(login.views.login_view) Yet when I login it django raises an 'NoReverseMatch' for {% url client.views.client_search_last_name_view %} but not for {% url login.views.logout_view %} Now why would this be?

    Read the article

  • installing snippets

    - by Sevenearths
    How do I install snippets in django? (specifically this) I have the file /{project}/snippets/EnforceLoginMiddleware.py and I have tried any number of permutations inside MIDDLEWARE_CLASSES to load it as well as googling django snippets install to no avail :( Any help would be grateful :) PS(Why can't I find any documentation or examples on the installation of snippets. Maybe I'm just a bad googler)

    Read the article

  • Returning user data for forms that have errors in when using ModelForms

    - by Sevenearths
    forms.py from django.forms import ModelForm from client.models import ClientDetails, ClientAddress, ClientPhone from snippets.UKPhoneNumberForm import UKPhoneNumberField class ClientDetailsForm(ModelForm): class Meta: model = ClientDetails class ClientAddressForm(ModelForm): class Meta: model = ClientAddress class ClientPhoneForm(ModelForm): number = UKPhoneNumberField() class Meta: model = ClientPhone views.py from django.shortcuts import render_to_response, redirect from django.template import RequestContext from client.forms import ClientDetailsForm, ClientAddressForm, ClientPhoneForm def new_client_view(request): formDetails = ClientDetailsForm(initial={'marital_status':'u'}) formAddress = ClientAddressForm() formHomePhone = ClientPhoneForm(initial={'phone_type':'home'}) formWorkPhone = ClientPhoneForm(initial={'phone_type':'work'}) formMobilePhone = ClientPhoneForm(initial={'phone_type':'mobi'}) return render_to_response('client/new_client.html', {'formDetails': formDetails, 'formAddress': formAddress, 'formHomePhone': formHomePhone, 'formWorkPhone': formWorkPhone, 'formMobilePhone': formMobilePhone}, context_instance=RequestContext(request)) (the new_client.html is nothing special) How should I write views.py so that if the user's data raises an error, instead of showing them the form again with the errors in but none of their original data, it shows them the form again with the errors AND their original data?

    Read the article

1