app-generator / django-datta-able

Datta Able - Open-Source Django Dashboard | AppSeed
https://appseed.us/product/datta-able/django/
Other
535 stars 236 forks source link

Create a custom app on django-datta-able failed #14

Closed samg666 closed 2 years ago

samg666 commented 2 years ago

Hello,

I am pretty new to Django and trying to using django-dotta-able, and I have tried to create a simple helloworld app named demo1, but always got errors. I do this by below steps. I am not sure what is wrong on my steps.

It would be really helpful if there's step-by-step guidance docs on how to create a simple custom apps/pages on django-dotta-able.

  1. Create a new app demo1 on django-datta-able foler by python manage.py startapp demo1
  2. Install app demo1 on core.settings
  3. Create an view on demo1.views
    def index(request):
    return HttpResponse("Hello World")
  4. Create demo1.urls file and added below code
    
    from django.urls import path, re_path
    from . import views

urlpatterns = [

path('', views.index, name='index'),

]


5. Include demo1.urls to core.urls by adding `path("demo1/", include("demo1.urls")),`

Then I access by `http://127.0.0.1:8000/demo1` and got `Error 404`, on the console I saw `[04/Feb/2022 03:20:28] "GET /demo1 HTTP/1.1" 200 3011` without error. 

OS: MacOS 12.1
Python: 3.9.0
app-generator commented 2 years ago

Hello @ggs331,

To make it work, please update the following:

1- Update core/urls.py to include demo1 above apps.home.urls

urlpatterns = [
    path('admin/', admin.site.urls),               # Django admin route
    path("", include("apps.authentication.urls")), # Auth routes - login / register
    path("demo1/", include("demo1.urls")),         # <----- The NEW APP
    path("", include("apps.home.urls"))            # UI Kits Html files
]

2 - Update demo1/urls.py as bellow:

...
urlpatterns = [
    path('index', views.index, name='index'),  
]

3 - The new rule is available at:

Let us know if you succeed to bootstrap your local version

samg666 commented 2 years ago

Thank you very much, it works now.