I was trying to include the urls
but still both not working
On Friday, April 24, 2020 at 11:33:48 PM UTC-4, Motaz Hejaze wrote:
-- originally it was
path('score/new/', PostCreateView.as_view(), name='post-create'),
On Friday, April 24, 2020 at 11:33:48 PM UTC-4, Motaz Hejaze wrote:
path('score/new/', include(('pexplain this line ?ost-create.urls ', 'post-create' ), PostCreateView.as_view(),name ='post-create'),On Sat, Apr 25, 2020 at 5:30 AM Ahmed Khairy <ahmed.he...@gmail.com> wrote:I have created a new app in a project and moved one of the classes from one app to the new app--I checked every step but I keep getting No Reverse match I wrote the name of the app before the namespace but stillHTML :<a class="nav-link waves-effect " href="{% url 'score:post-create ' %}" > UploadDesigns </a> URLSfrom django.urls importinclude, path from . import viewsfrom .views import (PostCreateView, PostDeleteView, PostDetailView, PostListView, PostUpdateView, UserPostListView) app_name = 'score'urlpatterns = [path('user/<str:username>', UserPostListView.as_view(), name ='user-posts'),path('score/',PostListView.as_view(), name=' score '),path('score/<int:pk>/',PostDetailView.as_view(), name = 'post-detail'),path('score/new/', include(('post-create.urls', 'post- create '), PostCreateView.as_view (), name='post-create'),path('score/<int:pk>/update/ ', PostUpdateView.as_view (), name='post-update'),path('score/<int:pk>/delete/ ', PostDeleteView.as_view (), name='post-delete')]settings:from django.conf importsettings from django.conf.urls.static import staticfrom django.contrib importadmin from django.contrib.auth import views as auth_viewsfrom django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls importinclude, path from users import views asuser_views urlpatterns = [path('admin/', admin.site.urls), path('accounts/', include(' allauth.urls')),path('', include('core.urls ', namespace='core')),path('register/', user_views.register, name='register ' ),path('profile/', user_views.profile, name='profile') , viewsfrom django.contrib importmessages from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.contrib.auth.models import User from django.contrib.messages.views import SuccessMessageMixin from django.http importHttpResponse from django.shortcuts importget_object_or_404, redirect, render from django.utils importtimezone from django.views.generic import (CreateView, DeleteView,DetailView, ListView, UpdateView) from .models import Postclass PostListView(ListView):model = Posttemplate_name = "score.html "context_object_name = 'posts 'class PostCreateView(LoginRequiredMixin , SuccessMessageMixin, CreateView):model = Postfields = ['caption', 'design ']template_name = "score/post_form.html "def form_valid(self, form): form.instance.author =self.request.user return super().form_valid (form)modelsfrom django.conf importsettings from django.contrib.auth.models import User from django.db import modelsfrom django.shortcuts importreverse from django.utils importtimezone # Create your models here.class Post(models.Model):author = models.ForeignKey(User, on_delete=models.CASCAD E )design = models.ImageField( blank=False, null=True, upload_to='new designs') def __str__(self):return self.captiondef get_absolute_url(self): return reverse("score:post-detail ", kwargs={"pk": self .pk})
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 django...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a5bf9872- .8877-42dd-b76b-cfd1cd316ef5% 40googlegroups.com
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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/298223b8-f349-4ce6-9183-3b077c6d573a%40googlegroups.com.
No comments:
Post a Comment