Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data not displayed in Index.html #32

Closed
app-generator opened this issue Jul 27, 2023 · 19 comments
Closed

Data not displayed in Index.html #32

app-generator opened this issue Jul 27, 2023 · 19 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@app-generator
Copy link
Owner

Issue raised in support (Discord)

Changes are saved in test1 branch

A new model data Site is displayed in index page.

Views.py

  units = Site.objects.all().values()

  context = {
    'segment': 'index',
    'units'  : units    
  }
  return render(request, "pages/index.html", context)

Template, pages/index.html

    {% for unit in units %}
    >> {{ unit.site_id }}, {{ unit.site_name }}, {{ unit.sitecol }}, {{ unit.lat }}, {{ unit.long }}
    <br/>
    {% endfor %}

@mominur-helios please take a look

@app-generator app-generator added the help wanted Extra attention is needed label Jul 27, 2023
@mominur-helios
Copy link
Collaborator

mominur-helios commented Jul 27, 2023

In home apps urls.py files just comment out the views from admin_datta and import views from home.

Just like this

Screenshot from 2023-07-27 17-01-03

@jorgeassuncao
Copy link

jorgeassuncao commented Jul 27, 2023

I've made the above changes but the problem persists.

Do you need anything from me to help debig this? the complete views.py, index.html,...?

P.S.: I've just made the changes proposed on the fist post, will try now the second.

@jorgeassuncao
Copy link

jorgeassuncao commented Jul 27, 2023

@mominur-helios my file is diferent from yours, are you shure this is Datta Able Django?

Readme.MD:

> Built with [App Generator](https://appseed.us/generator/), timestamp `2023-07-22 22:58`

- `Up-to-date dependencies`
- Database: `mysql`
- UI-Ready app, Django Native ORM
- `Session-Based authentication`, Forms validation
- `Dark Mode` (enhancement)
- Persistent via browser `local storage`

Changelog.md

## CodeBase version: 2stable.0.1 / 2022-01-15
### Improvements

- Dependencies update (all packages) 
  - Django==4.0.1
- Settings update for Django 4.x
  - `New Parameter`: CSRF_TRUSTED_ORIGINS
    - [Origin header checking isn`t performed in older versions](https://docs.djangoproject.com/en/4.0/ref/settings/#csrf-trusted-origins)

My /apps/home/urls.py dont have admin_datta...

# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""

from django.urls import path, re_path
from apps.home import views

###
from . import views
###

urlpatterns = [

    # The home page
    path('', views.index, name='home'),

    # Matches any html file
    re_path(r'^.*\.*', views.pages, name='pages'),

]

@app-generator
Copy link
Owner Author

Hello @jorgeassuncao

The codebase will be updated soon. You've spotted a regression added by the latest commits.

Please wait.

@app-generator
Copy link
Owner Author

Fixed in version v1.0.23.

To test, please do the following & let us know the results.

  • download the latest version
  • create two Products using Django CLI or Admin Section
  • Edit home/views.py to load products into the main template
def index(request):

  context = {
    'segment'  : 'index',
    'products' : Product.objects.all()  # <-- Uncomment this line
  }
  return render(request, "pages/index.html", context)

The HOMEpage needs to be like this:

image

@jorgeassuncao
Copy link

jorgeassuncao commented Jul 27, 2023

Had this errors rinning pip3 install -r requirements.txt. Are they normal?

  DEPRECATION: django-admin-datta is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for django-admin-datta ... done
  DEPRECATION: django-api-generator is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for django-api-generator ... done
  DEPRECATION: django-dynamic-datatb is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559```

@app-generator
Copy link
Owner Author

This is new. Let us investigate.

@mominur-helios please take a look at this warning.

TY

@jorgeassuncao
Copy link

I've inserted two products.
image

They appear on Dynamic Tables.
image

But notthing on main page
image

@jorgeassuncao
Copy link

This is new. Let us investigate.

@mominur-helios please take a look at this warning.

TY

image

@app-generator
Copy link
Owner Author

Is the line UNcommented in the controller?

Products are not injected by default.

def index(request):

  context = {
    'segment'  : 'index',
    'products' : Product.objects.all()  # <-- Uncomment this line
  }
  return render(request, "pages/index.html", context)

@jorgeassuncao
Copy link

Yes it is.
image

@app-generator
Copy link
Owner Author

app-generator commented Jul 27, 2023

Can you share your repo with us?

Just add app-generator as a contributor.

@jorgeassuncao
Copy link

@jorgeassuncao
Copy link

jorgeassuncao commented Jul 27, 2023

just wait a few minutes, i'm syncyng the repo.

P.S.: It's now synced

@app-generator
Copy link
Owner Author

The project is updated, please pull.

https://github.com/jorgeassuncao/d23e8dd6-1347-499f-85bb-88bb4507108c

You were still using the previous version. Now is updated to the latest release of Datta Able.

We recommend starting fresh with the latest version of Datta Able and adding your own code on top:

image

@jorgeassuncao
Copy link

ahhhh... Perfect!
image

I'm still new to this all Django stuff, so maybe i've made a mistake along the way. Sorry for the trouble...

Just a quick question, if i use more than one "query" on a page (results from diferent tables) whats the corret way to do it? Just add them like these?

def index(request):

  context = {
    'segment'  : 'index',
    'products' : Product.objects.all(),
    'services' : Service.objects.all()
  }
  return render(request, "pages/index.html", context)

And how to make a "query" available on all pages?

@app-generator
Copy link
Owner Author

app-generator commented Jul 27, 2023

@mominur-helios can you advise here?

@mominur-helios
Copy link
Collaborator

Hello @jorgeassuncao ,

if you use more than one "query" on a page then yes your approach is correct.

and if you want to make a "query" available on all pages then there is concept in django templatetags. You need to use django custom templatetags to achieve the expected behaviour.

@app-generator
Copy link
Owner Author

Patch validated. Closing.
@jorgeassuncao let us know anytime if you need further assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants