Appreciate the response.

I was working directly off a brand-new generated Django project, which I 
had named 
restservice 

...and following the installation instructions on:  
https://www.django-rest-framework.org/#installation

So I (trivially) modified the skeleton to the state (below), and when I ran 
it, encountered (completely unexpected) exceptions.

"""
restservice URL Configuration

The `urlpatterns` list routes URLs to views. For more information please 
see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""


#
# Original (default) now disabled per DRF Installation Guide: 
https://www.django-rest-framework.org/#example
# We intend to create a read-write API for accessing information on the 
users of our project.
#
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    url(r'^api-auth/', include('rest_framework.urls'))   # Per: 
https://www.django-rest-framework.org/#installation:
                                                         # ...add REST 
framework's login and logout views.
]


It hasn't stopped me -- I went on to adopt the Quickstart examples and 
moved on.  And, by the way, DRF looks *nice*!  As in  *REALLY* nice!

But I was thinking it wasn't good for the project to have errors from the 
very first example.

Is there someone responsible for the DRF documentation examples that I 
should notify of this issue?

Best regards,

-- Daniel


On Friday, August 7, 2020 at 8:44:55 PM UTC-7, Wandss wrote:
>
> Hi Daniel.
>
> Since you didn't posted any code, I can only make some assumptions here.
> Since Django 2, the url function has been sort of replaced by path 
> function, so instead writing your urls like:
>
> urlpatterns = [ url(some_regexp, your_views)]
>
> You will probably use:
>
> urlpattern = [path("some-path/", your views]
>
> Above examples are not actually code. I'm just giving you an idea.
> The url function had been moved to another package in Django 2, and I'm 
> not sure if it even exists in DJango3 
> https://docs.djangoproject.com/en/2.0/releases/2.0/#whats-new-2-0
> https://docs.djangoproject.com/en/3.0/ref/urls/
>
> I'd suggest taking a look at the Django Documentation as well, since 
> Django itself had some important changes since version 1.11
> About the admin not working, I can only guess that since you're having 
> issues with your urls mapping, it's probably getting lost and not been able 
> to reach the admin page.
>
> Hope I could help.
> If not, please post some part of your code, and I might help you better on 
> this.
>
> Cheers, and happy coding!
>
>
>
>
> Em sex., 7 de ago. de 2020 às 23:43, Daniel Cunningham <
> daniel.phil...@gmail.com <javascript:>> escreveu:
>
>> Hi All:
>>
>> I need a reality check on a misunderstanding I'm having with the 
>> installation instructions 
>> <https://www.django-rest-framework.org/#installation> for  DRF.  I've 
>> used DRF successfully before (about a year ago) so I'm surprised I'm having 
>> this difficulty.
>>
>> The instructions in the first "Installation" section 
>> <https://www.django-rest-framework.org/#installation> call for a 
>> modification to urlpatterns (whereby we append a new pattern for DRF).  
>> I noticed, when testing, that *this results in an immediate exception:*
>>
>> NameError: name 'url' is not defined
>>
>> I was curious to see if others are running into this error?  And if so, 
>> perhaps a quick correction would be useful to new DRF users, because an 
>> immediate error from the "here's how to install this" page seems like it 
>> would cause a bad first impression.  
>>
>> As a secondary issue, I was also quite puzzled by the syntax itself,  as 
>> it does not match the urlpatterns syntax in the "Example" section 
>> immediately following this first section.  I'm guessing  this is because I 
>> am a relative "newbie" to Django and DRF, but a bit of explanation would go 
>> a long way here, because it's quite unlike the patterns used by the rest of 
>> the example code.  *Perhaps a comment with a link to the convention or 
>> an example would be useful?*
>>
>> I know DRF is a great product, because it has worked quite well for me 
>> before, so as a work-around, I bypassed those last steps in the first part 
>> of the installation instructions, and went on to the "Example" section 
>> <https://www.django-rest-framework.org/#example>.  I implemented those 
>> instructions, and things went much smoother.
>>
>> One final (minor) issue: I noticed, when testing, that the instructions 
>> for modifying urls.py seem to imply a swap out of the entire urlpatterns 
>> section, 
>> but if you do that, *you lose the ability to get to the original Django 
>> admin page link *at: 127.0.0.1:8000/admin/  (in fact it will throw 
>> another exception).  So perhaps the code in this section should be modified 
>> to fix that problem.
>>
>> All that aside, I love the product.  I've got a great DRF example going, 
>> and I can continue my work.  I just wanted you all to know about these 
>> potential problematic issues, and see if there's a.way to make the 
>> introductory experience even better.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django REST framework" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-rest-framework+unsubscr...@googlegroups.com <javascript:>
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-rest-framework/6307fb92-3cce-4c5f-b630-6d076fb081dao%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-rest-framework/6307fb92-3cce-4c5f-b630-6d076fb081dao%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/3535b2aa-5df4-47bd-8a81-74336e9f4c86o%40googlegroups.com.

Reply via email to