did you try to change the name 'post-create' to something else ?
On Sat, Apr 25, 2020 at 6:34 AM Ahmed Khairy <ahmed.heshameldin@gmail.com> wrote:
yes--INSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','django.contrib.sites','allauth','allauth.account','users.apps.UsersConfig','core','crispy_forms','django_filters','score']
On Saturday, April 25, 2020 at 12:31:30 AM UTC-4, Motaz Hejaze wrote:did you add your new app to installed apps in settings.pyOn Sat, Apr 25, 2020 at 6:29 AM Motaz Hejaze <trap...@gmail.com> wrote:you don't need the include part because you already copied the class to the new appOn Sat, Apr 25, 2020 at 6:16 AM Ahmed Khairy <ahmed.he...@gmail.com> wrote:I tried to include the urls--originally it waspath('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 appI 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' %}" > Upload Designs </a>URLSfrom django.urls import include, pathfrom . 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 import settingsfrom django.conf.urls.static import staticfrom django.contrib import adminfrom django.contrib.auth import views as auth_viewsfrom django.contrib.staticfiles.urls import staticfiles_urlpatternsfrom django.urls import include, pathfrom users import views as user_viewsurlpatterns = [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 import messagesfrom django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixinfrom django.contrib.auth.models import Userfrom django.contrib.messages.views import SuccessMessageMixinfrom django.http import HttpResponsefrom django.shortcuts import get_object_or_404, redirect, renderfrom django.utils import timezonefrom 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.userreturn super().form_valid(form)modelsfrom django.conf import settingsfrom django.contrib.auth.models import Userfrom django.db import modelsfrom django.shortcuts import reversefrom 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.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/c813a663-e0dc-447e-94a9-a5dda31b3ac6%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/0bd12de7-9b6d-4a56-9ea1-d8ba11c6f192%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/CAHV4E-dqRZe07F26B1HZ4jfcbvTsbqoPxCh7YWK5bqhK9ULJng%40mail.gmail.com.
No comments:
Post a Comment