A URL.py problem
Reg
Willy
Sent from my iPad
Sent from my iPad
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 ' %}" > 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/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.
No comments:
Post a Comment