Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango error - didn't return an HttpResponse object
    text
    copied!<p>in my main application folder, the URLs.py has the following code.</p> <pre><code>urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), # (r'^catalog/$', home), (r'^static/(?P&lt;path&gt;.*)$', 'django.views.static.serve', { 'document_root' : 'C:/SHIYAM/Personal/SuccessOwl/SOWL0.1/SOWL/SOWL/static'}), # (r'^admin/', include('django.contrib.admin.urls')), (r'^catalog/', include('CATALOG.urls')), (r'^accounts/', include('registration.urls')), (r'^$', main_page), ) </code></pre> <p>I have a seperate app (Folder) called "CATALOG" and it's URLs.py has the following code:</p> <pre><code>urlpatterns = patterns('SOWL.catalog.views', (r'^$', 'index', { 'template_name':'catalog/index.html'}, 'catalog_home'), (r'^category/(?P&lt;category_slug&gt;[-\w]+)/$', 'show_category', {'template_name':'catalog/category.html'},'catalog_category'), (r'^product/(?P&lt;product_slug&gt;[-\w]+)/$', 'show_product', {'template_name':'catalog/product.html'},'catalog_product'), (r'^enter_product/$',enter_product), ) </code></pre> <p>Under catalog folder, I have forms.py</p> <pre><code>from django import forms from CATALOG.models import Product class ProductAdminForm(forms.ModelForm): class Meta: model = Product def clean_price(self): if self.cleaned_data['price'] &lt;= 0: raise forms.ValidationError('Price must be greater than zero.') return self.cleaned_data['price'] class Product_Form(forms.Form): name = forms.CharField(label='name', max_length=30) slug = forms.SlugField(label='Unique Name for the URL', max_length=30) brand = forms.CharField(label='Unique Name for the URL', max_length=30) price = forms.DecimalField(label='Price',max_digits=9,decimal_places=2) old_price = forms.DecimalField(max_digits=9,decimal_places=2,initial=0.00) quantity = forms.IntegerField() description = forms.CharField() meta_keywords = forms.CharField(max_length=255) meta_description = forms.CharField(max_length=255) categories = forms.CharField(max_length=255) user = forms.IntegerField() prepopulated_fields = {'slug' : ('name',)} </code></pre> <p>and views.py</p> <pre><code>from CATALOG.forms import * def enter_product(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = User.objects.create_user( username=form.clean_data['username'], password=form.clean_data['password1'], email=form.clean_data['email'] ) return HttpResponseRedirect('/') else: form = RegistrationForm() variables = RequestContext(request, { 'form': form }) return render_to_response( 'catalog/enter_product.html', variables ) </code></pre> <p>and under "\templates\catalog" folder, I have "enter_product.html", which has the following code:</p> <pre><code>{% extends "base.html" %} {% block title %}blah{% endblock %} {% block head %}blah{% endblock %} {% block content %} &lt;form method="post" action="."&gt; {{ form.as_p }} &lt;input type="submit" value="Enter" /&gt; &lt;/form&gt; {% endblock %} </code></pre> <p>but when I go to localhost:8000/catalog/enter_product/ it says:</p> <p>The view CATALOG.views.enter_product didn't return an HttpResponse object.</p> <p>why is that? Thanks for your help.</p> <ul> <li>Toronto</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload