problem on django contrib

8 views
Skip to first unread message

Saeed Pooladzadeh

unread,
Nov 25, 2018, 2:37:16 AM11/25/18
to Django users
Hello
 

I'm trying to use Django on the visual studio but for admin page when I uncomment the

 from django.contrib import admin 

I get this message :

unexpected token and it can't accept this line of code,

please inform me why. 
Should I install a specific package or something?

thanx
Saeed

Joel Mathew

unread,
Nov 25, 2018, 2:54:47 AM11/25/18
to django...@googlegroups.com
Show the screenshot and complete code
Sincerely yours,

 Joel G Mathew



--
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...@googlegroups.com.
To post to this group, send email to django...@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/24fc6b59-3342-4a9b-b3f5-075e64518c5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saeed Pooladzadeh

unread,
Nov 25, 2018, 3:03:30 AM11/25/18
to Django users

here comes the code for urls.py but i cant uncomment it because python doesnt accept it

"""
Definition of urls for DjangoWebProject19.
"""

from django.conf.urls import include, url

# Uncomment the next two lines to enable the admin:
 #from django.contrib import admin
 #admin.autodiscover()

urlpatterns = [
    # Examples:
    # url(r'^$', DjangoWebProject19.views.home, name='home'),
    # url(r'^DjangoWebProject19/', include('DjangoWebProject19.DjangoWebProject19.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
     #url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
     #url(r'^admin/', include(admin.site.urls)),
]

در شنبه 24 نوامبر 2018، ساعت 18:54:47 (UTC-8)، Joel نوشته:

Joel Mathew

unread,
Nov 25, 2018, 3:32:52 AM11/25/18
to django...@googlegroups.com
Use path for simple urls:

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


urlpatterns = [
path('admin/', admin.site.urls),
path('appointments/', include('appointments.urls')),
path('clinic/', include('clinic.urls')),
path('', include('clinic.urls'))
]
Sincerely yours,

 Joel G Mathew


Saeed Pooladzadeh

unread,
Nov 25, 2018, 3:46:30 AM11/25/18
to Django users
Can you please explain what should I do exactly?

should I place these code in admin page? and delete the previous code?

در شنبه 24 نوامبر 2018، ساعت 19:32:52 (UTC-8)، Joel نوشته:

Joel Mathew

unread,
Nov 25, 2018, 3:50:12 AM11/25/18
to django...@googlegroups.com
You didnt show the admin page. You showed urls.py. path is an easier way to use urls, without need for regex.
Your problem is not clear to me. If it's something on the admin page. What exactly are you trying to do? Post everything relevant.

Sincerely yours,

 Joel G Mathew


Saeed Pooladzadeh

unread,
Nov 25, 2018, 3:56:03 AM11/25/18
to Django users
where should i place your code?
the admin page or urls page?


در شنبه 24 نوامبر 2018، ساعت 19:50:12 (UTC-8)، Joel نوشته:

Saeed Pooladzadeh

unread,
Nov 25, 2018, 3:58:59 AM11/25/18
to Django users
here comes my admin page code:

from django.contrib import admin
from .models import Post

admin.site.register(Post).


در شنبه 24 نوامبر 2018، ساعت 19:50:12 (UTC-8)، Joel نوشته:
You didnt show the admin page. You showed urls.py. path is an easier way to use urls, without need for regex.

Saeed Pooladzadeh

unread,
Nov 25, 2018, 4:49:33 AM11/25/18
to django...@googlegroups.com
here comes my project:


can you please give a try to it and let me know what is wrong and I can't see the admin page?

Reply all
Reply to author
Forward
0 new messages