Bernard Kwey
NoReverseMatch at /2/
Reverse for 'new_entry' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P<topic_id>[0-9]+)/$']
Bernard Kwey
how can i fix it
Anonymous
Bernard Kwey
yes
Bernard Kwey
in my views or urls or in my templates
Anonymous
Bernard Kwey
yes
Anonymous
Can u share the screenshots of your views, templates and urls
Bernard Kwey
my new_entry template
Bernard Kwey
{% extends "learning_logs/base.html" %}
{% block content %}
<p><a href="{% url 'learning_logs:topic' topic.id %}">{{ topic }}</a></p>
<p>Add a new entry:</p>
<form action="{% url 'learning_logs:new_entry' topic.id %}" method='post'>
{% csrf_token %}
{{ form.as_p }}
<button name='submit'>add entry</button>
</form>
{% endblock content %}
Bernard Kwey
my views
Bernard Kwey
def new_entry(request, topic_id):
"""Add a new entry for a particular topic."""
topic = Topic.objects.get(id=topic_id)
if request.method != 'POST':
# No data submitted; create a blank form.
form = EntryForm()
else:
# POST data submitted; process data.
form = EntryForm(data=request.POST)
if form.is_valid():
new_entry = form.save(commit=False)
new_entry.topic = topic
new_entry.save()
return HttpResponseRedirect(reverse('learning_logs:topic',
args=[topic.id]))
context = {'topic': topic, 'form': form}
return render(request, 'learning_logs/new_entry.html', context)
Bernard Kwey
my urls
Bernard Kwey
app_name = "learning_logs"
urlpatterns = [
# Home Page
path('', views.index, name='index'),
# Show all topics
path('topics/', views.topics, name='topics'),
# Detail page for a single topic
path('<int:topic_id>/', views.topic, name='topic'),
# Page for adding a new topic
path('new_topic/', views.new_topic, name='new_topic'),
#page for adding a new entry
path('<int:topic_id>/', views.new_entry, name='new_entry'),
]
Anonymous
Okay.. can u try changing the URL to
path('new/?P<pk>[0-9]+', views.new_entry, name='new_entry')
Bernard Kwey
okay
Bernard Kwey
NoReverseMatch at /1/
Reverse for 'new_entry' with arguments '('',)' not found. 1 pattern(s) tried: ['new/\\?P(?P<pk>[^/]+)\\[0\\-9\\]\\+$']
Request Method:
GET
Request URL:
http://127.0.0.1:8000/1/
Django Version:
2.2.1
Exception Type:
NoReverseMatch
Exception Value:
Reverse for 'new_entry' with arguments '('',)' not found. 1 pattern(s) tried: ['new/\\?P(?P<pk>[^/]+)\\[0\\-9\\]\\+$']
Bernard Kwey
error
Bernard Kwey
Error during template rendering
In template C:\Users\parke\Desktop\learning_log\learning_logs\templates\learning_logs\base.html, error at line 0
Reverse for 'new_entry' with arguments '('',)' not found. 1 pattern(s) tried: ['new/\\?P(?P<pk>[^/]+)\\[0\\-9\\]\\+$']
1
{% load static %}
2
3
4
<!DOCTYPE html>
5
<html>
6
<head>
7
<title>learning Log</title>
8
</head>
9
<body>
10
Bernard Kwey
Anonymous
Yeah
Bernard Kwey
so i should remove the "int:" since i don't won't to pass in any number
Bernard Kwey
or what
Bernard Kwey
for updating any value
Anonymous
for updating any value
Then u need to pass an integer value, otherwise we wouldn't be able to pinpoint which value to update
Bernard Kwey
that is why i pass in an id
Anonymous
I went through ur code and it feels like it is used to create a new entry.. not updating it right ? If that is the case, then no need for int..
Bernard Kwey
sorry i forget to tell you that
Bernard Kwey
so you can only make a new entry only when you click on a topic or when you create one...
Anonymous
I see
Naveen
kindly share your code in Pastebin along with error @goshbak
Bernard Kwey
thanks
Venkatesh
Hello all I need some video tutorial on rest API can anyone please help me.
Naveen
Naveen
https://ftuforum.com/build-your-own-backend-rest-api-using-django-rest-framework-1/
Naveen
@Venkateshb22
Naveen
How to install django in windows7
you need to install python first, then install pip and you can install any library then.Google - how to install python
This way you will easily be able to run django
Root
Gaston
Hi, i have a problem with formset, i use this plugin and the button add-row dont show.
https://github.com/elo80ka/django-dynamic-formset/blob/master/docs/usage.rst
Any hint where is the problem?
Gaston
https://pastebin.com/siq8GVXw
Venkatesh
Antony
Hello! Help me) I use pytest django, and i need load fixtures for each module. After the tests ended in the module, data must be deleted. How can i realize this??
Antony
so, i create in each app file
conftest.py
, and use this:
@pytest.fixture()
def django_db_setup(django_db_setup, django_db_blocker):
with django_db_blocker.unblock():
call_command('loaddata', './apps/accounts/fixtures/accounts.json')
call_command('loaddata', './apps/activation/fixtures/activation.json')
call_command('loaddata', './apps/questionnaire/fixtures/questionnaire.json')
Martin
I'm scratching my head trying to figure out how to migrate from Django 1.9.x to 1.10.x
from line 13 onwards the uhh.. some things in urls.py aren't imported, and that fails in Django 1.10, but I can't figure out how to rewrite this
view must be a callable or a list/tuple in the case of include().
as a note this was encased in patterns() before, which I removed and used [] instead
https://haste.rys.pw/uvagayukal.py
Anonymous
hi guys ı have problem , when ım on pythonanywhere setting py debug = False
Anonymous
ım lost all my pictures
Anonymous
anyoont know this ?
Nitesh
anyoont know this ?
Use nginx or Apache and configure them to serve your media files and static files
Anonymous
how ?
Anonymous
mate ?
Nitesh
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
Martin
Martin
cj
Martin
I couldn't find "assign_user_to_group" in the entire project, the thing that's used is the name
cj
Martin
and the name value is only present once in a template
Martin
$.post("{% url "master_assign_user_action" %}",
{
"assign": post_assign,
"perm": perm,
"email": user,
"group": group,
"csrfmiddlewaretoken": "{{ csrf_token }}"
}, function(data){
console.log("User assigned");
console.log(data);
}
);
}
Anders (izzno / gooood) 🇳🇴
I'm pretty sure I know the answer to this but does prepopulated_fields work if I exclude the field ? 🤣, or do i have to override the save method and slugify manually before save ?
Naveen
Anders (izzno / gooood) 🇳🇴
Gaston
I try JQuery plugins for djago and other soluctions and not work
Martin
@izznogooood what do you mean?
Anders (izzno / gooood) 🇳🇴
Anders (izzno / gooood) 🇳🇴
Django would just throw an empty string
Anders (izzno / gooood) 🇳🇴
Mirco
Martin
Martin
But I can't just install 2.3 and deal with 15 deprecations at once :D
Anders (izzno / gooood) 🇳🇴
When do you need to slugify ?
When I save, its just for pretty urls. So I was contemplating hiding them from the users in the admin panel. Now I use prepopulated_fields to autofill the field while they type the name.
Anders (izzno / gooood) 🇳🇴
Anders (izzno / gooood) 🇳🇴
Just branch out and start working.... If not youll be doing alot more work all together.
Mirco