I tried to include the urls 

originally it was 

    path('score/new/', PostCreateView.as_view(), name='post-create'),

but both didn't work 

On Friday, April 24, 2020 at 11:29:41 PM UTC-4, Ahmed Khairy 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 still 
>
>
> HTML : 
>  
>  <a class="nav-link waves-effect" href="{% url 'score:post-create' %}"
>  > Upload Designs </a>
>
>
>
> URLS 
> from django.urls import include, path
>
> from . import views
> from .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 import settings
> from django.conf.urls.static import static
> from django.contrib import admin
> from django.contrib.auth import views as auth_views
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> from django.urls import include, path
>
> from users import views as user_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'),
>
> views
> from django.contrib import messages
> 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 import HttpResponse
> from django.shortcuts import get_object_or_404, redirect, render
> from django.utils import timezone
> from django.views.generic import (
>     CreateView, DeleteView, DetailView, ListView, UpdateView)
>
> from .models import Post
>
>
>
> class PostListView(ListView):
>     model = Post
>     template_name = "score.html"
>     context_object_name = 'posts'
>
> class PostCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
>     model = Post
>     fields = ['caption', 'design']
>     template_name = "score/post_form.html"
>
>     def form_valid(self, form):
>         form.instance.author = self.request.user
>         return super().form_valid(form)
>
> models
>
> from django.conf import settings
> from django.contrib.auth.models import User
> from django.db import models
> from django.shortcuts import reverse
> from django.utils import timezone
>
>
> # Create your models here.
> class Post(models.Model):
>     author = models.ForeignKey(User, on_delete=models.CASCADE)
>     design = models.ImageField(
>         blank=False, null=True, upload_to='new designs')
>
>     def __str__(self):
>         return self.caption
>
>     def 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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c813a663-e0dc-447e-94a9-a5dda31b3ac6%40googlegroups.com.

Reply via email to