-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi Gerald,

Couple of points:
- - please try to stick to the mailing list when posting follow-up
  questions or materials rather than replying off-list; this makes it
  possible for other people to jump in and offer their advice (and
  also doesn't send the message that you expect the one person who
  tried to help you to personally coach you through your issue), and
- - rather than attaching your code in a tarball, posting the relevant
  parts of your code in-line typically makes it easier for people to
  help you – I can just look at the email and directly see the code,
  rather than having to fetch the attachment, unpack it, and go
  through all that hassle. (And don't even get me started on the trend
  of posting screenshots of stack traces or even code; some of us are
  reading our mail in text-mode terminals. Get off my lawn, kids! :P )

With that out of the way, let's get back to your questions.

On Thu, Aug 09, 2018 at 09:15:36PM +0800, Gerald Brown wrote:
> Thanks for your info.
> 
> I am attaching my views.py, url.py and index.html.  The index.html creates a
> menu on the main admin page.  I have included some comments there about the
> strange happenings that are going on.  I am not able to include any trace
> info because I have gone back to my original program from before these
> generic date views.
> 
> The URLS1.py file is from my top level and URL.py is from my visit app. In
> the views.py file most of the code is formatting the reportlab pdf file with
> the data from the queryset assigned to various locations in the pdf.

urls.py::

    from django.contrib import admin
    from django.urls import include, path

    #from visit import views # as visit_views
    from visit.views import PaymentTodayArchiveView 

    urlpatterns = [
            path('today/', PaymentTodayArchiveView.as_view, name="today"),
            ]

urls1.py::

    from django.contrib.admin.sites import AdminSite
    from django.contrib import admin
    from django.urls import path
    from django.conf.urls import include, url
    #from django.views.generic.dates import DateDetailView

    from patient import views as patient_views
    from visit import views as visit_views

    admin.site.site_header = 'MEDREC Administration'

    class DashboardSite(AdminSite):
            def get_urls(self):
                    urls = super(DashboardSite, self).get_urls()
                    custom_urls = [
                            path('^$', self.admin_view(HomeView.as_view()), 
name='admin'),
                            ]
                    del urls[2]
                    return custom_urls + urls

    urlpatterns = [
            path('admin/patient/', patient_views.prescription_view),
            
            path('admin/visit/', visit_views.daily_payment_view),
            
            path('admin/', admin.site.urls),
            ]

views.py::

    @staff_member_required
    # ~ class PaymentTodayArchiveView(TodayArchiveView):
            # ~ queryset = Visit.objects.all()
            # ~ date_field = "visit_date"

So, starting from the beginning – the correct way to reference a
generic class-based view in an URL config is to use
MyViewClass.as_view() – note the parentheses. You can see that in
action in the custom AdminSite that you wrote. The parentheses are
missing in your urls.py.

Second, I don't see urls.py being referenced anywhere in urls1.py,
which you say is the root URL config.

Third, your usage of the ``staff_member_required`` decorator is not
correct – I recommend reading the section of the docs which covers
decorating class-based views [1] to learn how to do that. Not to
mention that you left the decorator in place, while you commented out
the view itself, which means the decorator would get applied to the
next definition following it.

I'm not quite sure how I can help you here, since you don't actually
have any code in place that would use the GCBV...

> It seems like all tutorials I try to follow they are only half complete and
> they leave out a lot of stuff..like how to access these views.  Maybe that
> is something I should know, but don't.
> 
> As it is getting late here I will be taking another look at this tomorrow.

Michal

[1]: 
https://docs.djangoproject.com/en/2.1/topics/class-based-views/intro/#decorating-class-based-views
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJbbXEsAAoJEHA7T/IPM/kl410QAM6IM+hMFu7+0n41MysAJebW
qk7LE/YaO5lWeBFtbBnzKuQTQ3cIV102Q2e/YBYLOwh0lmlefD01iqR+pOJLdWAu
/Fbr6uqG5Nlem7hFoc0g6QvQLADej4AqsdGlQ80de12gb66PHvHaAkqV726cPodI
13V8qXsfZsj4ix0XsAZmPEmYKW6PoL4TV2J9FFQYLr8ZqlzD3Y+QkEojtnspfVod
ayK7nH3DcABEU1R0SGx+e/7ifwCFXkk3KjIC4ESRGH7pEaozJZu9onb7YP32Yejd
B9sUA1+7A5Cj1IQvlKc8cDayZ3qLRTV7tOG3oUvy/adiRFoBU1MgTodNJccT5Rrx
+WdEgYeGsmd5rrBZAio0S6fhGuCClRMQiknmFjX4YJ2pN4aBCZo7R8RlmkCkODmw
JgKecTujBLC8ax2EDYH887W/qALIsyk5+J1tOZlDblg3+cYMm8LCGQLUCpz5hARb
z35ZXRjb8f7WY6KN8JXDPvL9oNvypOV+AxmJP6NsYAPufA0RtTvkrTrPdXr0a5VK
YCB1E4VK5vBLvjf+qrrOu7mCYBG1qGiPXLXGOFd6uQCZDAJvqOAfEroC7PTxRlW0
min7N+lU5An2vWh8snDQ1P4oOZYvm8YGLeC9bdFNaWl79cpvG4PLwQfWb/R8LJum
MdtV/G8XgnwJWWaVG/ya
=rSMt
-----END PGP SIGNATURE-----

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20180810110413.GL1181%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to