What is the solution to “django.urls.exceptions.NoReverseMatch” error when creating a Django model object?2019 Community Moderator ElectionDjango 2.0 - Not a valid view function or pattern name (Customizing Auth views)django models request get id error Room matching query does not existTypeError: a bytes-like object is required, not 'str' when writing to a file in Python3TkInter Frame doesn't load if another function is calledDjango: TypeError: '<' not supported between instances (model objects)Django ImageField in Model and FormsDjango throws TypeError when trying to use auth LoginViewDynamically add rows and columns in QTable in pyQT5Unable to create instance of Django modelDjango related models in one formNoReverseMatch at/myapp/products/

It's a yearly task, alright

What wound would be of little consequence to a biped but terrible for a quadruped?

What is the difference between "shut" and "close"?

what does the apostrophe mean in this notation?

Who is our nearest neighbor

Straight line with arrows and dots

Does the Bracer of Flying Daggers benefit from the Dueling fighting style?

Good allowance savings plan?

Single word request: Harming the benefactor

My adviser wants to be the first author

Why do Australian milk farmers need to protest supermarkets' milk price?

What does it mean when multiple 々 marks follow a 、?

How do anti-virus programs start at Windows boot?

How to make readers know that my work has used a hidden constraint?

Do I need to leave some extra space available on the disk which my database log files reside, for log backup operations to successfully occur?

Latest web browser compatible with Windows 98

Are there situations where a child is permitted to refer to their parent by their first name?

Want to switch to tankless, but can I use my existing wiring?

What has been your most complicated TikZ drawing?

The meaning of the "at the of"

Why doesn't the EU now just force the UK to choose between referendum and no-deal?

Why would a jet engine that runs at temps excess of 2000°C burn when it crashes?

validation vs test vs training accuracy, which one to compare for claiming overfit?

Rejected in 4th interview round citing insufficient years of experience



What is the solution to “django.urls.exceptions.NoReverseMatch” error when creating a Django model object?



2019 Community Moderator ElectionDjango 2.0 - Not a valid view function or pattern name (Customizing Auth views)django models request get id error Room matching query does not existTypeError: a bytes-like object is required, not 'str' when writing to a file in Python3TkInter Frame doesn't load if another function is calledDjango: TypeError: '<' not supported between instances (model objects)Django ImageField in Model and FormsDjango throws TypeError when trying to use auth LoginViewDynamically add rows and columns in QTable in pyQT5Unable to create instance of Django modelDjango related models in one formNoReverseMatch at/myapp/products/










0















I am trying to create an application conference for which code files are below.
I am running into an error as can be seen from attached file when I click create conference button in conference_list.html file.



Error shown in Console:



enter image description here



I have included static files in base.html and extended in all other app_name_base.html files.




Culprit line as pointed by chrome browser is in file views.py of conferences app as follows:



return render(request , 'conferences/conference_create.html')



Please help. Files are shown below:



conferences models.py



from django.db import models
from django.utils.text import slugify
from django.urls import reverse

import misaka

from datetime import date
import datetime
from django.contrib.auth import get_user_model
User = get_user_model()
from django import template
register = template.Library()

class Conference(models.Model):
name = models.CharField(max_length=255,unique=True)
poster = models.ImageField(upload_to='images/%Y/%m/%d',blank=True)
venue = models.CharField(max_length=255,editable=True,default='Online')
created_at = models.DateTimeField(auto_now_add=True,blank=False)
conference_on = models.DateTimeField(auto_now_add=True,blank=False)
registration_till = models.DateField(auto_now_add=False, blank=True)
audience = models.TextField(blank=True,default='Add your audience type here i.e. "Below 25","Entrepreneurs","Music"')
description = models.TextField(blank=True,default='Add your event description here i.e. "Coding Event for python developers"')
slug = models.SlugField(allow_unicode=True, unique=True)
audience_html = models.TextField(editable=False,default='',blank=True)
conference_user = models.ForeignKey(User, related_name='User', null=True,on_delete=models.CASCADE)
members = models.ManyToManyField(User,through="ConferenceMember")
# Add a company user here


def __str__(self):
return self.name

def save(self,*args,**kwargs):
self.slug = slugify(self.name)
self.audience_html = misaka.html(self.audience)
super().save(*args,**kwargs)

def get_absolute_url(self):
return reverse('conferences:single',kwargs="slug": self.slug)

class Meta:
ordering = ['name']
def daysleft(self):
if datetime.date.today() > self.conference_on.date():
return False
else:
return self.conference_on.date() - datetime.date.today()
def registration(self):
if datetime.date.today() > self.registration_till:
return False
else:
return self.registration_till - datetime.date.today()

def summary(self):
return self.description[:100]
def reg_date_pretty(self):
return self.registration_till.strftime('%b %e %Y')
def conf_date_pretty(self):
return self.conference_on.strftime('%b %e %Y')






class ConferenceMember(models.Model):
conference = models.ForeignKey(Conference,related_name="memberships",on_delete=models.CASCADE)
user = models.ForeignKey(User,related_name="user_groups",on_delete=models.CASCADE)

def __str__(self):
return self.user.username
class Meta:
unique_together = ('conference','user')



pass


conferences application "create" function in views.py



@login_required(login_url = "accounts/signup")
def create(request):
if request.method == 'POST':
if request.POST['name'] and request.POST['venue'] and request.POST['registration_till'] and request.FILES['poster'] and request.POST['audience']:
project = Conference()
project.name = request.POST['name']
project.venue = request.POST['venue']
project.registration_till = request.POST['registration_till']
project.poster = request.cleaned_data['poster']

project.audience = request.POST['audience']
project.created_at = timezone.datetime.now()
project.conference_user = request.user
project.save()
return redirect('conferences/event/in/' + str(project.slug))
else:
return render(request , 'conferences/conference_create.html','error':'All fields are required.')
else:
return render(request , 'conferences/conference_create.html')


conferences urls.py



from django.urls import path
from . import views
app_name="conferences"
urlpatterns=[
path('',views.ListConferences.as_view(),name='all'),
# path('event/in/<int:conference_id>',views.SingleConference,name='single'),
path('event/in/<slug:slug>',views.SingleConference.as_view(),name='single'),
path('create', views.create , name = 'create'),
path('join/<slug:slug>',views.JoinConference.as_view(),name="join"),
path('leave/<slug:slug>',views.LeaveConference.as_view(),name="leave"),
]


conferences conference_list.html



% extends "conferences/conference_base.html" %
% block pregroup %

<div class="row">
<div class="col-md-4">
<div class="content profile">
% if user.is_authenticated %

<h2>Welcome Back
<a href="% url 'posts:for_user' username=user.username %">@user.username</a>
</h2>

% endif %

</div>

</div>
</div>
% endblock %

% block group_content %
<a href="% url 'conferences:create' %" class="nav-item nav-link btn btn-info btn-lg plus">
Create Conference
</a>
% for conference in object_list %
<div class="row">
<div class="col-md-2">
<img src="conference.poster.url" alt="Image" width=200 height=150>
</div>
<div class="col-md-10">
<div class="list-group">



<a href="% url 'conferences:single' slug=conference.slug %" class="list-group-item">
<h3 class="title list-group-item-heading">conference.name</h3>
<div class="list-group-item-text container-fluid">
conference.audience_html
<div class="row">
<div class="col-md-4">
<span class="badge"> conference.members.count </span> attendy conference.members.count
<span class="badge">
% if conference.registration %
Hurray conference is in conference.daysleft days. Registration closes in conference.registration
% else %
Conference was on conference.conference_on. Visit Post Section on conference.name Page.
% endif %
</span>

</div>
</div>
</div>
</a>
<br>



</div>

</div>

</div>

% endfor %
% endblock %


conference_create.html



% extends 'base.html' %
% block content %
% if error %
<p class="alert alert-primary" role="alert">error</p>
<br>
<br>
% endif %
<h1>Create your hosted Conference</h1>
<form action="% url 'conferences:create' %" method = "POST" enctype = "multipart/form-data">

% csrf_token %
Name:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="text" name = "name" />
<br/>
Venue:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "venue" />
<br/>
Audience:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "audience" />
<br/>

<!-- Registration open till:<br/>
<input type="date" name = "reg_date" />
<br/>
Conference on Date:<br/>
<input type="date" name = "conf_date" />
<br/> -->
Poster:<br/>
<input type="file" name = "poster" />
<br/>
<input type="submit" value = "Create Conference" class = "btn btn-primary"/>
</form>


%endblock%


Project urls.py



from django.conf.urls.static import static
from django.contrib import admin
from django.conf import settings
from django.urls import path, include
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.HomePage.as_view(),name = "home"),
path('accounts/',include('accounts.urls',namespace="accounts")),
path('accounts/', include("django.contrib.auth.urls")),
path('thanks/',views.ThanksPage.as_view(),name="thanks"),
path('conferences/',include('conferences.urls',namespace="conferences")),
path('companies/',include('companies.urls',namespace="companies")),
path('posts/',include('posts.urls',namespace="posts")),
path('profiles/',include('profiles.urls',namespace="profile")),

]
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Edit and Solution:
I have also added modified conference_create.html file [Culprit line was line 9 as i needed to add action="% url 'conferences:create' %" in html form.










share|improve this question
























  • Possible duplicate of Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)

    – Edeki Okoh
    Mar 6 at 17:51






  • 1





    Above solution woks as I needed to add conferences(app_name) in call to url in the file conference_create.html . Thanks Edeki :)

    – Mohit Verma
    Mar 6 at 18:42















0















I am trying to create an application conference for which code files are below.
I am running into an error as can be seen from attached file when I click create conference button in conference_list.html file.



Error shown in Console:



enter image description here



I have included static files in base.html and extended in all other app_name_base.html files.




Culprit line as pointed by chrome browser is in file views.py of conferences app as follows:



return render(request , 'conferences/conference_create.html')



Please help. Files are shown below:



conferences models.py



from django.db import models
from django.utils.text import slugify
from django.urls import reverse

import misaka

from datetime import date
import datetime
from django.contrib.auth import get_user_model
User = get_user_model()
from django import template
register = template.Library()

class Conference(models.Model):
name = models.CharField(max_length=255,unique=True)
poster = models.ImageField(upload_to='images/%Y/%m/%d',blank=True)
venue = models.CharField(max_length=255,editable=True,default='Online')
created_at = models.DateTimeField(auto_now_add=True,blank=False)
conference_on = models.DateTimeField(auto_now_add=True,blank=False)
registration_till = models.DateField(auto_now_add=False, blank=True)
audience = models.TextField(blank=True,default='Add your audience type here i.e. "Below 25","Entrepreneurs","Music"')
description = models.TextField(blank=True,default='Add your event description here i.e. "Coding Event for python developers"')
slug = models.SlugField(allow_unicode=True, unique=True)
audience_html = models.TextField(editable=False,default='',blank=True)
conference_user = models.ForeignKey(User, related_name='User', null=True,on_delete=models.CASCADE)
members = models.ManyToManyField(User,through="ConferenceMember")
# Add a company user here


def __str__(self):
return self.name

def save(self,*args,**kwargs):
self.slug = slugify(self.name)
self.audience_html = misaka.html(self.audience)
super().save(*args,**kwargs)

def get_absolute_url(self):
return reverse('conferences:single',kwargs="slug": self.slug)

class Meta:
ordering = ['name']
def daysleft(self):
if datetime.date.today() > self.conference_on.date():
return False
else:
return self.conference_on.date() - datetime.date.today()
def registration(self):
if datetime.date.today() > self.registration_till:
return False
else:
return self.registration_till - datetime.date.today()

def summary(self):
return self.description[:100]
def reg_date_pretty(self):
return self.registration_till.strftime('%b %e %Y')
def conf_date_pretty(self):
return self.conference_on.strftime('%b %e %Y')






class ConferenceMember(models.Model):
conference = models.ForeignKey(Conference,related_name="memberships",on_delete=models.CASCADE)
user = models.ForeignKey(User,related_name="user_groups",on_delete=models.CASCADE)

def __str__(self):
return self.user.username
class Meta:
unique_together = ('conference','user')



pass


conferences application "create" function in views.py



@login_required(login_url = "accounts/signup")
def create(request):
if request.method == 'POST':
if request.POST['name'] and request.POST['venue'] and request.POST['registration_till'] and request.FILES['poster'] and request.POST['audience']:
project = Conference()
project.name = request.POST['name']
project.venue = request.POST['venue']
project.registration_till = request.POST['registration_till']
project.poster = request.cleaned_data['poster']

project.audience = request.POST['audience']
project.created_at = timezone.datetime.now()
project.conference_user = request.user
project.save()
return redirect('conferences/event/in/' + str(project.slug))
else:
return render(request , 'conferences/conference_create.html','error':'All fields are required.')
else:
return render(request , 'conferences/conference_create.html')


conferences urls.py



from django.urls import path
from . import views
app_name="conferences"
urlpatterns=[
path('',views.ListConferences.as_view(),name='all'),
# path('event/in/<int:conference_id>',views.SingleConference,name='single'),
path('event/in/<slug:slug>',views.SingleConference.as_view(),name='single'),
path('create', views.create , name = 'create'),
path('join/<slug:slug>',views.JoinConference.as_view(),name="join"),
path('leave/<slug:slug>',views.LeaveConference.as_view(),name="leave"),
]


conferences conference_list.html



% extends "conferences/conference_base.html" %
% block pregroup %

<div class="row">
<div class="col-md-4">
<div class="content profile">
% if user.is_authenticated %

<h2>Welcome Back
<a href="% url 'posts:for_user' username=user.username %">@user.username</a>
</h2>

% endif %

</div>

</div>
</div>
% endblock %

% block group_content %
<a href="% url 'conferences:create' %" class="nav-item nav-link btn btn-info btn-lg plus">
Create Conference
</a>
% for conference in object_list %
<div class="row">
<div class="col-md-2">
<img src="conference.poster.url" alt="Image" width=200 height=150>
</div>
<div class="col-md-10">
<div class="list-group">



<a href="% url 'conferences:single' slug=conference.slug %" class="list-group-item">
<h3 class="title list-group-item-heading">conference.name</h3>
<div class="list-group-item-text container-fluid">
conference.audience_html
<div class="row">
<div class="col-md-4">
<span class="badge"> conference.members.count </span> attendy conference.members.count
<span class="badge">
% if conference.registration %
Hurray conference is in conference.daysleft days. Registration closes in conference.registration
% else %
Conference was on conference.conference_on. Visit Post Section on conference.name Page.
% endif %
</span>

</div>
</div>
</div>
</a>
<br>



</div>

</div>

</div>

% endfor %
% endblock %


conference_create.html



% extends 'base.html' %
% block content %
% if error %
<p class="alert alert-primary" role="alert">error</p>
<br>
<br>
% endif %
<h1>Create your hosted Conference</h1>
<form action="% url 'conferences:create' %" method = "POST" enctype = "multipart/form-data">

% csrf_token %
Name:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="text" name = "name" />
<br/>
Venue:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "venue" />
<br/>
Audience:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "audience" />
<br/>

<!-- Registration open till:<br/>
<input type="date" name = "reg_date" />
<br/>
Conference on Date:<br/>
<input type="date" name = "conf_date" />
<br/> -->
Poster:<br/>
<input type="file" name = "poster" />
<br/>
<input type="submit" value = "Create Conference" class = "btn btn-primary"/>
</form>


%endblock%


Project urls.py



from django.conf.urls.static import static
from django.contrib import admin
from django.conf import settings
from django.urls import path, include
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.HomePage.as_view(),name = "home"),
path('accounts/',include('accounts.urls',namespace="accounts")),
path('accounts/', include("django.contrib.auth.urls")),
path('thanks/',views.ThanksPage.as_view(),name="thanks"),
path('conferences/',include('conferences.urls',namespace="conferences")),
path('companies/',include('companies.urls',namespace="companies")),
path('posts/',include('posts.urls',namespace="posts")),
path('profiles/',include('profiles.urls',namespace="profile")),

]
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Edit and Solution:
I have also added modified conference_create.html file [Culprit line was line 9 as i needed to add action="% url 'conferences:create' %" in html form.










share|improve this question
























  • Possible duplicate of Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)

    – Edeki Okoh
    Mar 6 at 17:51






  • 1





    Above solution woks as I needed to add conferences(app_name) in call to url in the file conference_create.html . Thanks Edeki :)

    – Mohit Verma
    Mar 6 at 18:42













0












0








0








I am trying to create an application conference for which code files are below.
I am running into an error as can be seen from attached file when I click create conference button in conference_list.html file.



Error shown in Console:



enter image description here



I have included static files in base.html and extended in all other app_name_base.html files.




Culprit line as pointed by chrome browser is in file views.py of conferences app as follows:



return render(request , 'conferences/conference_create.html')



Please help. Files are shown below:



conferences models.py



from django.db import models
from django.utils.text import slugify
from django.urls import reverse

import misaka

from datetime import date
import datetime
from django.contrib.auth import get_user_model
User = get_user_model()
from django import template
register = template.Library()

class Conference(models.Model):
name = models.CharField(max_length=255,unique=True)
poster = models.ImageField(upload_to='images/%Y/%m/%d',blank=True)
venue = models.CharField(max_length=255,editable=True,default='Online')
created_at = models.DateTimeField(auto_now_add=True,blank=False)
conference_on = models.DateTimeField(auto_now_add=True,blank=False)
registration_till = models.DateField(auto_now_add=False, blank=True)
audience = models.TextField(blank=True,default='Add your audience type here i.e. "Below 25","Entrepreneurs","Music"')
description = models.TextField(blank=True,default='Add your event description here i.e. "Coding Event for python developers"')
slug = models.SlugField(allow_unicode=True, unique=True)
audience_html = models.TextField(editable=False,default='',blank=True)
conference_user = models.ForeignKey(User, related_name='User', null=True,on_delete=models.CASCADE)
members = models.ManyToManyField(User,through="ConferenceMember")
# Add a company user here


def __str__(self):
return self.name

def save(self,*args,**kwargs):
self.slug = slugify(self.name)
self.audience_html = misaka.html(self.audience)
super().save(*args,**kwargs)

def get_absolute_url(self):
return reverse('conferences:single',kwargs="slug": self.slug)

class Meta:
ordering = ['name']
def daysleft(self):
if datetime.date.today() > self.conference_on.date():
return False
else:
return self.conference_on.date() - datetime.date.today()
def registration(self):
if datetime.date.today() > self.registration_till:
return False
else:
return self.registration_till - datetime.date.today()

def summary(self):
return self.description[:100]
def reg_date_pretty(self):
return self.registration_till.strftime('%b %e %Y')
def conf_date_pretty(self):
return self.conference_on.strftime('%b %e %Y')






class ConferenceMember(models.Model):
conference = models.ForeignKey(Conference,related_name="memberships",on_delete=models.CASCADE)
user = models.ForeignKey(User,related_name="user_groups",on_delete=models.CASCADE)

def __str__(self):
return self.user.username
class Meta:
unique_together = ('conference','user')



pass


conferences application "create" function in views.py



@login_required(login_url = "accounts/signup")
def create(request):
if request.method == 'POST':
if request.POST['name'] and request.POST['venue'] and request.POST['registration_till'] and request.FILES['poster'] and request.POST['audience']:
project = Conference()
project.name = request.POST['name']
project.venue = request.POST['venue']
project.registration_till = request.POST['registration_till']
project.poster = request.cleaned_data['poster']

project.audience = request.POST['audience']
project.created_at = timezone.datetime.now()
project.conference_user = request.user
project.save()
return redirect('conferences/event/in/' + str(project.slug))
else:
return render(request , 'conferences/conference_create.html','error':'All fields are required.')
else:
return render(request , 'conferences/conference_create.html')


conferences urls.py



from django.urls import path
from . import views
app_name="conferences"
urlpatterns=[
path('',views.ListConferences.as_view(),name='all'),
# path('event/in/<int:conference_id>',views.SingleConference,name='single'),
path('event/in/<slug:slug>',views.SingleConference.as_view(),name='single'),
path('create', views.create , name = 'create'),
path('join/<slug:slug>',views.JoinConference.as_view(),name="join"),
path('leave/<slug:slug>',views.LeaveConference.as_view(),name="leave"),
]


conferences conference_list.html



% extends "conferences/conference_base.html" %
% block pregroup %

<div class="row">
<div class="col-md-4">
<div class="content profile">
% if user.is_authenticated %

<h2>Welcome Back
<a href="% url 'posts:for_user' username=user.username %">@user.username</a>
</h2>

% endif %

</div>

</div>
</div>
% endblock %

% block group_content %
<a href="% url 'conferences:create' %" class="nav-item nav-link btn btn-info btn-lg plus">
Create Conference
</a>
% for conference in object_list %
<div class="row">
<div class="col-md-2">
<img src="conference.poster.url" alt="Image" width=200 height=150>
</div>
<div class="col-md-10">
<div class="list-group">



<a href="% url 'conferences:single' slug=conference.slug %" class="list-group-item">
<h3 class="title list-group-item-heading">conference.name</h3>
<div class="list-group-item-text container-fluid">
conference.audience_html
<div class="row">
<div class="col-md-4">
<span class="badge"> conference.members.count </span> attendy conference.members.count
<span class="badge">
% if conference.registration %
Hurray conference is in conference.daysleft days. Registration closes in conference.registration
% else %
Conference was on conference.conference_on. Visit Post Section on conference.name Page.
% endif %
</span>

</div>
</div>
</div>
</a>
<br>



</div>

</div>

</div>

% endfor %
% endblock %


conference_create.html



% extends 'base.html' %
% block content %
% if error %
<p class="alert alert-primary" role="alert">error</p>
<br>
<br>
% endif %
<h1>Create your hosted Conference</h1>
<form action="% url 'conferences:create' %" method = "POST" enctype = "multipart/form-data">

% csrf_token %
Name:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="text" name = "name" />
<br/>
Venue:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "venue" />
<br/>
Audience:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "audience" />
<br/>

<!-- Registration open till:<br/>
<input type="date" name = "reg_date" />
<br/>
Conference on Date:<br/>
<input type="date" name = "conf_date" />
<br/> -->
Poster:<br/>
<input type="file" name = "poster" />
<br/>
<input type="submit" value = "Create Conference" class = "btn btn-primary"/>
</form>


%endblock%


Project urls.py



from django.conf.urls.static import static
from django.contrib import admin
from django.conf import settings
from django.urls import path, include
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.HomePage.as_view(),name = "home"),
path('accounts/',include('accounts.urls',namespace="accounts")),
path('accounts/', include("django.contrib.auth.urls")),
path('thanks/',views.ThanksPage.as_view(),name="thanks"),
path('conferences/',include('conferences.urls',namespace="conferences")),
path('companies/',include('companies.urls',namespace="companies")),
path('posts/',include('posts.urls',namespace="posts")),
path('profiles/',include('profiles.urls',namespace="profile")),

]
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Edit and Solution:
I have also added modified conference_create.html file [Culprit line was line 9 as i needed to add action="% url 'conferences:create' %" in html form.










share|improve this question
















I am trying to create an application conference for which code files are below.
I am running into an error as can be seen from attached file when I click create conference button in conference_list.html file.



Error shown in Console:



enter image description here



I have included static files in base.html and extended in all other app_name_base.html files.




Culprit line as pointed by chrome browser is in file views.py of conferences app as follows:



return render(request , 'conferences/conference_create.html')



Please help. Files are shown below:



conferences models.py



from django.db import models
from django.utils.text import slugify
from django.urls import reverse

import misaka

from datetime import date
import datetime
from django.contrib.auth import get_user_model
User = get_user_model()
from django import template
register = template.Library()

class Conference(models.Model):
name = models.CharField(max_length=255,unique=True)
poster = models.ImageField(upload_to='images/%Y/%m/%d',blank=True)
venue = models.CharField(max_length=255,editable=True,default='Online')
created_at = models.DateTimeField(auto_now_add=True,blank=False)
conference_on = models.DateTimeField(auto_now_add=True,blank=False)
registration_till = models.DateField(auto_now_add=False, blank=True)
audience = models.TextField(blank=True,default='Add your audience type here i.e. "Below 25","Entrepreneurs","Music"')
description = models.TextField(blank=True,default='Add your event description here i.e. "Coding Event for python developers"')
slug = models.SlugField(allow_unicode=True, unique=True)
audience_html = models.TextField(editable=False,default='',blank=True)
conference_user = models.ForeignKey(User, related_name='User', null=True,on_delete=models.CASCADE)
members = models.ManyToManyField(User,through="ConferenceMember")
# Add a company user here


def __str__(self):
return self.name

def save(self,*args,**kwargs):
self.slug = slugify(self.name)
self.audience_html = misaka.html(self.audience)
super().save(*args,**kwargs)

def get_absolute_url(self):
return reverse('conferences:single',kwargs="slug": self.slug)

class Meta:
ordering = ['name']
def daysleft(self):
if datetime.date.today() > self.conference_on.date():
return False
else:
return self.conference_on.date() - datetime.date.today()
def registration(self):
if datetime.date.today() > self.registration_till:
return False
else:
return self.registration_till - datetime.date.today()

def summary(self):
return self.description[:100]
def reg_date_pretty(self):
return self.registration_till.strftime('%b %e %Y')
def conf_date_pretty(self):
return self.conference_on.strftime('%b %e %Y')






class ConferenceMember(models.Model):
conference = models.ForeignKey(Conference,related_name="memberships",on_delete=models.CASCADE)
user = models.ForeignKey(User,related_name="user_groups",on_delete=models.CASCADE)

def __str__(self):
return self.user.username
class Meta:
unique_together = ('conference','user')



pass


conferences application "create" function in views.py



@login_required(login_url = "accounts/signup")
def create(request):
if request.method == 'POST':
if request.POST['name'] and request.POST['venue'] and request.POST['registration_till'] and request.FILES['poster'] and request.POST['audience']:
project = Conference()
project.name = request.POST['name']
project.venue = request.POST['venue']
project.registration_till = request.POST['registration_till']
project.poster = request.cleaned_data['poster']

project.audience = request.POST['audience']
project.created_at = timezone.datetime.now()
project.conference_user = request.user
project.save()
return redirect('conferences/event/in/' + str(project.slug))
else:
return render(request , 'conferences/conference_create.html','error':'All fields are required.')
else:
return render(request , 'conferences/conference_create.html')


conferences urls.py



from django.urls import path
from . import views
app_name="conferences"
urlpatterns=[
path('',views.ListConferences.as_view(),name='all'),
# path('event/in/<int:conference_id>',views.SingleConference,name='single'),
path('event/in/<slug:slug>',views.SingleConference.as_view(),name='single'),
path('create', views.create , name = 'create'),
path('join/<slug:slug>',views.JoinConference.as_view(),name="join"),
path('leave/<slug:slug>',views.LeaveConference.as_view(),name="leave"),
]


conferences conference_list.html



% extends "conferences/conference_base.html" %
% block pregroup %

<div class="row">
<div class="col-md-4">
<div class="content profile">
% if user.is_authenticated %

<h2>Welcome Back
<a href="% url 'posts:for_user' username=user.username %">@user.username</a>
</h2>

% endif %

</div>

</div>
</div>
% endblock %

% block group_content %
<a href="% url 'conferences:create' %" class="nav-item nav-link btn btn-info btn-lg plus">
Create Conference
</a>
% for conference in object_list %
<div class="row">
<div class="col-md-2">
<img src="conference.poster.url" alt="Image" width=200 height=150>
</div>
<div class="col-md-10">
<div class="list-group">



<a href="% url 'conferences:single' slug=conference.slug %" class="list-group-item">
<h3 class="title list-group-item-heading">conference.name</h3>
<div class="list-group-item-text container-fluid">
conference.audience_html
<div class="row">
<div class="col-md-4">
<span class="badge"> conference.members.count </span> attendy conference.members.count
<span class="badge">
% if conference.registration %
Hurray conference is in conference.daysleft days. Registration closes in conference.registration
% else %
Conference was on conference.conference_on. Visit Post Section on conference.name Page.
% endif %
</span>

</div>
</div>
</div>
</a>
<br>



</div>

</div>

</div>

% endfor %
% endblock %


conference_create.html



% extends 'base.html' %
% block content %
% if error %
<p class="alert alert-primary" role="alert">error</p>
<br>
<br>
% endif %
<h1>Create your hosted Conference</h1>
<form action="% url 'conferences:create' %" method = "POST" enctype = "multipart/form-data">

% csrf_token %
Name:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="text" name = "name" />
<br/>
Venue:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "venue" />
<br/>
Audience:<br/>
<input style="background-color:white;
border: solid 1px #6E6E6E;
height: 30px;
font-size:18px;
vertical-align:9px;color:#bbb" type="textbox" name = "audience" />
<br/>

<!-- Registration open till:<br/>
<input type="date" name = "reg_date" />
<br/>
Conference on Date:<br/>
<input type="date" name = "conf_date" />
<br/> -->
Poster:<br/>
<input type="file" name = "poster" />
<br/>
<input type="submit" value = "Create Conference" class = "btn btn-primary"/>
</form>


%endblock%


Project urls.py



from django.conf.urls.static import static
from django.contrib import admin
from django.conf import settings
from django.urls import path, include
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.HomePage.as_view(),name = "home"),
path('accounts/',include('accounts.urls',namespace="accounts")),
path('accounts/', include("django.contrib.auth.urls")),
path('thanks/',views.ThanksPage.as_view(),name="thanks"),
path('conferences/',include('conferences.urls',namespace="conferences")),
path('companies/',include('companies.urls',namespace="companies")),
path('posts/',include('posts.urls',namespace="posts")),
path('profiles/',include('profiles.urls',namespace="profile")),

]
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Edit and Solution:
I have also added modified conference_create.html file [Culprit line was line 9 as i needed to add action="% url 'conferences:create' %" in html form.







python-3.x twitter-bootstrap-3 django-2.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 17:59







Mohit Verma

















asked Mar 6 at 17:38









Mohit VermaMohit Verma

12




12












  • Possible duplicate of Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)

    – Edeki Okoh
    Mar 6 at 17:51






  • 1





    Above solution woks as I needed to add conferences(app_name) in call to url in the file conference_create.html . Thanks Edeki :)

    – Mohit Verma
    Mar 6 at 18:42

















  • Possible duplicate of Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)

    – Edeki Okoh
    Mar 6 at 17:51






  • 1





    Above solution woks as I needed to add conferences(app_name) in call to url in the file conference_create.html . Thanks Edeki :)

    – Mohit Verma
    Mar 6 at 18:42
















Possible duplicate of Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)

– Edeki Okoh
Mar 6 at 17:51





Possible duplicate of Django 2.0 - Not a valid view function or pattern name (Customizing Auth views)

– Edeki Okoh
Mar 6 at 17:51




1




1





Above solution woks as I needed to add conferences(app_name) in call to url in the file conference_create.html . Thanks Edeki :)

– Mohit Verma
Mar 6 at 18:42





Above solution woks as I needed to add conferences(app_name) in call to url in the file conference_create.html . Thanks Edeki :)

– Mohit Verma
Mar 6 at 18:42












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029135%2fwhat-is-the-solution-to-django-urls-exceptions-noreversematch-error-when-creat%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029135%2fwhat-is-the-solution-to-django-urls-exceptions-noreversematch-error-when-creat%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко