slyapustin / django-classified

Django Classified
https://github.com/slyapustin/django-classified-demo
MIT License
171 stars 77 forks source link

Initial installation #45

Closed typonaut closed 4 years ago

typonaut commented 4 years ago

I have a few queries on initial installation. The first one is that I get this error on "runserver"

?: (urls.E004) Your URL pattern (<module 'django_classified.urls' from '/Users/…/Documents/django/domosia2/mysite/django_classified/urls.py'>, 'django_classified', 'django_classified') is invalid. Ensure that urlpatterns is a list of path() and/or re_path() instances. HINT: Try using path() instead of a tuple.

I'd inserted this into /urls.py: include('django_classified.urls', namespace='django_classified')

But changed to this, which seemed to solve the issue: path('django_classified/', include('django_classified.urls', namespace='django_classified'))

After this I can "runserver" and see the initial view of classifieds at "/django_classified". However I see no listing of section names.

If I then click on "Add new" I seem to get the same error as noted in #29:

Page not found: (404)
Request Method: | GET
http://127.0.0.1:8000/accounts/login/?next=/django_classified/new/

However, I have checked the INSTALLED_APPS and "django.contrib.sites" is listed.

Here's a list of pip installed packages:

asgiref==3.2.3
Babel==2.8.0
certifi==2019.9.11
Django==2.2.9
django-bootstrap-form==3.4
django-classified==0.8.12
django-filter==2.2.0
Pillow==7.0.0
pytz==2019.3
sorl-thumbnail==12.5.0
sqlparse==0.3.0
Unidecode==1.1.1

Any help appreciated.

slyapustin commented 4 years ago

@typonaut You need to create your sections/groups structure via /admin/ page. You need to create Django Admin user first python ./manage.py createsuperuser.

typonaut commented 4 years ago

I created the superuser, but I still get an error through the web browser:

`

Request Method: GET


Request URL http://127.0.0.1:8000/admin/login/?next=/admin/ Django Version 2.2.9 Exception type DoesNotExist Exception value Site matching query does not exist. Exception location /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/db/models/query.py in get, line 406 Python executable /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 Python version 3.8.0 Python path ['/Users/clive/Documents/django/domosia2/mysite', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages']

`

slyapustin commented 4 years ago

@typonaut I see you need to have at least one entry in your Django Sites model. Please check that thread on SO: https://stackoverflow.com/questions/11814059/site-matching-query-does-not-exist

typonaut commented 4 years ago

Ok, got it, sorry for the aggravation.

Just added: SITE_ID = 1

to settings.py

Is this something that 'django.contrib.sites' is looking for?

Creating a user was not an issue - there was already a user defined. There was a site defined in the db table "django_site", but this wasn't referenced in settings.py.

Perhaps this point could be added to the readme for us neophytes?

slyapustin commented 4 years ago

@typonaut Good catch, thanks! I may need to point about that more explicitly in the demo application.

typonaut commented 4 years ago

Sorry to come back on this. I am only able to log-in as the admin user. I cannot create any new users (as if a new user visited and wanted to list new items).

If I click on "Add new" without being logged-in I get a 404 error which complains that the URL requested does not match any URL patterns:

Request URL: http://127.0.0.1:8000/accounts/login/?next=/new/

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: polls/ admin/ ^$ [name='index'] ^new/$ [name='item-new'] ^edit/(?P<pk>\d+)/$ [name='item-edit'] ^(?P<pk>\d+)-(?P<slug>[-\w]+)/$ [name='item'] ^group/(?P<pk>\d+)-(?P<slug>[-\w]+)/$ [name='group'] ^search/ [name='search'] ^robots\.txt$ [name='robots'] ^sitemap\.xml$ [name='sitemap'] ^rss\.xml$ [name='rss'] ^user/$ [name='user-items'] ^user/profile/$ [name='profile'] ^user/my/delete/(?P<pk>\d+)/$ [name='my-delete'] ^user/logout/$ [name='logout'] ^user/set-area/$ [name='set-area'] The current path, accounts/login/, didn't match any of these.

I get a similar problem if I click the "Login" link from Django Classified:

http://127.0.0.1:8000/accounts/login/?next=/django_classified/user/profile/

Produces a 404 with the following path searches:

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: polls/ admin/ django_classified/ The current path, accounts/login/, didn't match any of these.

Another anomaly is that if the URL path for django_classified is not '' (i.e. the root of the server), then I also get a 404 when trying to log out as admin. I guess this is because there is no URL path pointing to /, which is where the logout request is directed.

I can only log-in via /admin without getting an error.

typonaut commented 4 years ago

All is sorted out now.

damascene commented 1 year ago

All is sorted out now.

How did you solve it?

typonaut commented 1 year ago

Sorry, don’t recall. Probably just a [l]user error on my part.