Greetings,

trying to create new app with simple Form to create and update Company 
info. My view looks like:

def company_new(request):
    if request.method == "POST":
        form = CompanyForm(request.POST)
        if form.is_valid():
            company = form.save(commit=False)
            company.save()
            return redirect('views.company_detail', pk=company.pk)
    else:
        form = CompanyForm()
    return render(request, 'crm/company_edit.html', {'form': form})


with urls.py:


app_name = 'crm'
urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^index_previous', views.index_previous, name='index_previous'),
    url(r'^report_money', views.report_money, name='report_money'),
    url(r'^report_works', views.report_works, name='report_works'),
    url(r'^company/(?P<pk>[0-9]+)/$', views.company_detail, 
name='company_detail'),
    url(r'^work/(?P<pk>[0-9]+)/$', views.work_detail, name='work_detail'),
    url(r'^company/new/$', views.company_new, name='company_new'),
    url(r'^company/edit/(?P<pk>[0-9]+)/$', views.company_edit, 
name='company_edit'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)



But when i save my new company, i get info: 

Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/company/new/views.company_detail


So Django takes whole URL + my redirect. Is it possible to force to use my 
urls.py? I found something like "return HttpResponseRedirect('/')", but 
it's strange solution. Another way is to point to exact path, but i don't 
like too, i'd like to use urls.py to redirect.

Thanks for tips, i hope it's some simple trick or import i'm missing.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/24f7f6b7-2b9a-452f-9d15-325e1e467793%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to