{24-10-23 12:46}localhost:~/ad_app root# Traceback (most recent call last):            File "/root/ad_app/manage.py", line 22, in <module>                                               main()                                        File "/root/ad_app/manage.py", line 18, in main                                                   execute_from_command_line(sys.argv)           File "/root/ad_app/myappenv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line              utility.execute()                             File "/root/ad_app/myappenv/lib/python3.12/site-packages/django/core/management/__init__.py", line 382, in execute                                settings.INSTALLED_APPS                       File "/root/ad_app/myappenv/lib/python3.12/site-packages/django/conf/__init__.py", line 81, in __getattr__                                        self._setup(name)                             File "/root/ad_app/myappenv/lib/python3.12/site-packages/django/conf/__init__.py", line 68, in _setup                                             self._wrapped = Settings(settings_module)                       ^^^^^^^^^^^^^^^^^^^^^^^^^     File "/root/ad_app/myappenv/lib/python3.12/site-packages/django/conf/__init__.py", line 166, in __init__                                          mod = importlib.import_module(self.SETTINGS_MODULE)                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                           File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module                       return _bootstrap._gcd_import(name[level:], package, level)                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import                                 File "<frozen importlib._bootstrap>", line 1360, in _find_and_load                              File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked                     File "<frozen importlib._bootstrap>", line 935, in _load_unlocked                               File "<frozen importlib._bootstrap_external>", line 991, in exec_module                         File "<frozen importlib._bootstrap_external>", line 1129, in get_code                           File "<frozen importlib._bootstrap_external>", line 1059, in source_to_code                     File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed                    File "/root/ad_app/ad_app/settings.py", line 114                                                  os.path.join(BASE_DIR, 'staticfiles'),      IndentationError: unexpected indentimport os

# Define the base directory of your Django project
BASE_DIR = '/root/ad_app'  # Change this to your actual project path

# Step 1: Update settings.py
settings_path = os.path.join(BASE_DIR, 'ad_app', 'settings.py')

with open(settings_path, 'r') as file:
    settings_content = file.readlines()

# Update STATICFILES_DIRS and TEMPLATES DIRS
for i, line in enumerate(settings_content):
    if 'STATICFILES_DIRS' in line:
        # Ensure STATICFILES_DIRS does not include STATIC_ROOT
        settings_content[i] = "STATICFILES_DIRS = [\n"
        settings_content[i] += f"    os.path.join(BASE_DIR, 'other_static_files'),\n"  # Adjust if you have another static directory
        settings_content[i] += f"    os.path.join(BASE_DIR, 'pop', '2097_pop'),\n"
        settings_content[i] += "]\n"
    elif 'STATIC_ROOT' in line:
        settings_content[i] = f"STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')\n"  # Set STATIC_ROOT correctly
    elif 'DIRS' in line and 'TEMPLATES' in settings_content[i - 1]:
        settings_content[i] = "    os.path.join(BASE_DIR, 'pop', '2097_pop'),\n"

# Write updated settings back to settings.py
with open(settings_path, 'w') as file:
    file.writelines(settings_content)

# Step 2: Create views.py
views_path = os.path.join(BASE_DIR, 'ad_app', 'views.py')
views_content = """\
from django.shortcuts import render
from django.http import Http404
import logging

logger = logging.getLogger(__name__)

def landing_view(request):
    try:
        return render(request, 'index.html')
    except Exception as e:
        logger.error(f"Error rendering template: {e}")
        raise Http404("Template not found or an error occurred.")
"""

with open(views_path, 'w') as file:
    file.write(views_content)

# Step 3: Update urls.py
urls_path = os.path.join(BASE_DIR, 'ad_app', 'urls.py')
urls_content = """\
from django.urls import path
from .views import landing_view

urlpatterns = [
    path('', landing_view, name='landing'),
]
"""

with open(urls_path, 'w') as file:
    file.write(urls_content)

# Step 4: Create index.html in the template directory
template_dir = os.path.join(BASE_DIR, 'pop', '2097_pop')
os.makedirs(template_dir, exist_ok=True)  # Create the directory if it doesn't exist

# Create index.html file
index_html_path = os.path.join(template_dir, 'index.html')
index_html_content = """\
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Landing Page</title>
</head>
<body>
    <h1>Welcome to the Landing Page</h1>
</body>
</html>
"""

with open(index_html_path, 'w') as file:
    file.write(index_html_content)

print("Django project structure has been updated successfully.")