# \# Writing your first Django app, part 4

**URL:** <https://forum.djangoproject.com/t/writing-your-first-django-app-part-4/34577>\
**Category:** Getting Started\
**Created:** [September 7, 2024, 6:53am UTC](https://forum.djangoproject.com/t/writing-your-first-django-app-part-4/34577 "2024-09-07T06:53:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baxtishodd](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/baxtishodd/32/23755_2.png) [@Baxtishodd](https://forum.djangoproject.com/u/Baxtishodd)\
**Post date:** [September 7, 2024, 6:53am UTC](https://forum.djangoproject.com/t/writing-your-first-django-app-part-4/34577/1 "2024-09-07T06:53:23Z")

</div>

I create vote app from django

# Writing your first Django app, part 4

```auto
from django.urls import path

from . import views

app_name = "polls"
urlpatterns = [
    path("", views.IndexView.as_view(), name="index"),
    path("<int:pk>/", views.DetailView.as_view(), name="detail"),
    path("<int:pk>/results/", views.ResultsView.as_view(), name="results"),
    path("<int:question_id>/vote/", views.vote, name="vote"),
]

```

after that code errors with

File “”, line 1387, in \_gcd\_import  
File “”, line 1360, in \_find\_and\_load  
File “”, line 1331, in \_find\_and\_load\_unlocked  
File “”, line 935, in \_load\_unlocked  
File “”, line 995, in exec\_module  
File “”, line 488, in \_call\_with\_frames\_removed  
File “C:\Users\Baxti\Desktop\django-app\polls\urls.py”, line 3, in   
from . import views  
File “C:\Users\Baxti\Desktop\django-app\polls\views.py”, line 5  
from django.views import generic,  
^  
SyntaxError: trailing comma not allowed without surrounding parentheses

another Error why  
File “”, line 1387, in \_gcd\_import  
File “”, line 1360, in \_find\_and\_load  
File “”, line 1331, in \_find\_and\_load\_unlocked  
File “”, line 935, in \_load\_unlocked  
File “”, line 995, in exec\_module  
File “”, line 488, in \_call\_with\_frames\_removed  
File “C:\Users\Baxti\Desktop\django-app\polls\urls.py”, line 9, in   
path(“”, views.IndexView.as\_view(), name=“index”),  
^^^^^^^^^^^^^^^^^^^^^^^  
AttributeError: ‘function’ object has no attribute ‘as\_view’

---

<div class="post-metadata">

**Author:** ![HBarotov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hbarotov/32/26901_2.png) [@HBarotov](https://forum.djangoproject.com/u/HBarotov)\
**Post date:** [September 7, 2024, 7:32am UTC](https://forum.djangoproject.com/t/writing-your-first-django-app-part-4/34577/2 "2024-09-07T07:32:58Z")

</div>

Hi, (Assalomu aleykum)

It seems the error is in your `views.py`, specifically in line 5. While importing, make sure there is no comma at the end of the line. You need to remove that comma from line 5:

```auto
from django.views import generic

```

The second error means, in short, this:  
You cannot use `as_view` attribute for a function-based view, i.e. they are only for class-based views. Looking at your traceback, you can try removing `.as_view()` from your `IndexView`:

```auto
path(“”, views.IndexView, name=“index”),

```

_ **Opinion Part** _  
The official polls tutorial is famously not for those new to Django. You may find _Django for Beginners_ or _[LearnDjango.com](http://LearnDjango.com)_ very useful. Then, the polls tutorial will be very beneficial.

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [September 8, 2024, 4:56am UTC](https://forum.djangoproject.com/t/writing-your-first-django-app-part-4/34577/3 "2024-09-08T04:56:39Z")

</div>

need your views.py code.

---

<div class="post-metadata">

**Author:** ![Baxtishodd](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/baxtishodd/32/23755_2.png) [@Baxtishodd](https://forum.djangoproject.com/u/Baxtishodd)\
**Post date:** [September 8, 2024, 8:04am UTC](https://forum.djangoproject.com/t/writing-your-first-django-app-part-4/34577/4 "2024-09-08T08:04:04Z")

</div>

thanks I found issue
