i've urls in urls.py
urlpatterns = [ # examples: url(r'^$', 'products.views.home', name='home'), url(r'^s/$', 'products.views.search', name='search'), url(r'^products/$', 'products.views.all', name='products'), url(r'^products/(?p<slug>[\w-]+)/$', 'products.views.single', name='single_product'), url(r'^cart/(?p<id>\d+)/$', 'carts.views.remove_from_cart', name='remove_from_cart'), url(r'^cart/(?p<slug>[\w-]+)/$', 'carts.views.add_to_cart', name='add_to_cart'), url(r'^cart/$', 'carts.views.view', name='cart'), url(r'^checkout/$', 'orders.views.checkout', name='checkout'), url(r'^orders/$', 'orders.views.orders', name='user_orders'), url(r'^ajax/dismiss_marketing_message/$', 'marketing.views.dismiss_marketing_message', name='dismiss_marketing_message'), url(r'^ajax/email_signup/$', 'marketing.views.email_signup', name='ajax_email_signup'), url(r'^ajax/add_user_address/$', 'accounts.views.add_user_address', name='ajax_add_user_address'), #footerpages url(r'^about/$', 'footerpages.views.about_us', name='about_us'), url(r'^faq/$', 'footerpages.views.faq', name='faq'), url(r'^privacy/$', 'footerpages.views.privacy', name='privacy'), url(r'^terms/$', 'footerpages.views.terms', name='terms'), #contact url(r'^contact/$', 'contact.views.contact', name='contact'), # url(r'^blog/', include('blog.urls')), #(?p<all_items>.*) #(?p<id>\d+) url(r'^admin/', include(admin.site.urls)), url(r'^accounts/logout/$', 'accounts.views.logout_view', name='auth_logout'), url(r'^accounts/login/$', 'accounts.views.login_view', name='auth_login'), url(r'^accounts/register/$', 'accounts.views.registration_view', name='auth_register'), # url(r'^accounts/profile/$', 'accounts.views.profile', name='profile'), url(r'^accounts/profile/edit/$', 'accounts.views.profile_edit', name='profile_edit'), url(r'^accounts/packages/$', 'accounts.views.packages', name='packages'), url(r'^accounts/packages/edit/(?p<variation_id>\d+)/$', 'accounts.views.packages_edit', name='packages_edit'), url(r'^accounts/packages/delete/(?p<variation_id>\d+)/$', 'accounts.views.packages_delete', name='packages_delete'), url(r'^accounts/packages/add/$', 'accounts.views.packages_add', name='packages_add'), url(r'^accounts/address/add/$', 'accounts.views.add_user_address', name='add_user_address'), url(r'^accounts/activate/(?p<activation_key>\w+)/$', 'accounts.views.activation_view', name='activation_view'), ]
then changed
url(r'^products/(?p<slug>[\w-]+)/$', 'products.views.single', name='single_product'),
to:
url(r'^(?p<slug>[\w-]+)/$', 'products.views.single', name='single_product'),
so 'single_product' products urls works fine , passes in slug. can load accounts/ pages. other urls such about, faq, cart, checkout, gives me page not found error. can't event access http://127.0.0.1:8000/admin/. gives me page not found (404).
now if change urls.py /xyz/admin/ http://127.0.0.1:8000/xyz/admin/ works. same goes xyz/cart or xyz/faq.
i keep
url(r'^(?p<slug>[\w-]+)/$', 'products.views.single', name='single_product'),
what can do?
just including carts.views.view if affects anything.
def view(request): try: the_id = request.session['cart_id'] cart = cart.objects.get(id=the_id) except: the_id = none if the_id: new_total = 0.00 item in cart.cartitem_set.all(): pass variation in item.variations.all(): line_total = (float(variation.price_per_guest) * item.quantity) + (float(variation.extra_km_charge) * item.distance) + (float(variation.extra_hours_charge) * item.hour) new_total += line_total # subtotal_guests = variation.price_per_guest * item.quantity # subtotal_km_charges = variation.extra_km_charge * item.distance # subtotal_hours_charges = variation.extra_hours_charge * item.hour request.session['items_total'] = cart.cartitem_set.count() cart.total = new_total cart.save() context = { "cart": cart, # "subtotal_guests": subtotal_guests, # "subtotal_km_charges": subtotal_km_charges, # "subtotal_hours_charges": subtotal_hours_charges, } else: empty_message = "your cart empty, please keep shopping." context = {"empty": true, "empty_message": empty_message } template = "cart/view.html" return render(request, template, context)
all works intended - about/
matches ^([\w-]+)/$
url products.views.single
view called url. same issue valid faq/
, cart/
, checkout/
, admin/
pages - catched regex..
move single_product
url bottom of urlpatterns
. should last record in list:
urlpatterns = patterns('', ... # urls except `single_product` url(r'^(?p<slug>[\w-]+)/$', 'products.views.single', name='single_product') )
Comments
Post a Comment