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

Forward to /admin/login/?next=/admin/ and 500 when trying out admin panel #23

Open
koaning opened this issue Sep 26, 2024 · 5 comments
Open

Comments

@koaning
Copy link
Contributor

koaning commented Sep 26, 2024

I tried running the default example and went to the /admin url. This caused a 500 after it tried forwarding me. Here is the logline.

INFO:     127.0.0.1:36924 - "GET /admin/login/?next=/admin/ HTTP/1.1" 500 Internal Server Error

Did I mess something up? I would have expected the admin panel to be available from the get-go but I may have skipped a step.

@koaning koaning changed the title Forward to /admin/login/?next=/admin/ and 500 when trying out admin panel Forward to /admin/login/?next=/admin/ and 500 when trying out admin panel Sep 26, 2024
@j0hnc
Copy link

j0hnc commented Sep 26, 2024

I noticed this too. A short term fix, if you are just trying things out, is to set debug to true when starting your app, this seems to fix it:

app = Django(
    ...
    DEBUG=True,
)

@radiac
Copy link
Owner

radiac commented Sep 27, 2024

Thanks for spotting this - it was a bug in how uvicorn is instantiated in dev mode. This should be fixed in 28681ec and the imminent 0.9.1 release

@radiac radiac closed this as completed Sep 27, 2024
@alfonsrv
Copy link

Still seems to be an issue. The admin only works if DEBUG=True with nanodjango==0.9.2. Running the built-in server for testing nanodjango manage capability.py runserver 0.0.0.0:8000

app = Django(
    DEBUG=True,
    ADMIN_URL='admin/',
)

class Capability(models.Model):
    info = models.TextField(
        verbose_name='Info'
    )

class CapabilityAdmin(admin.ModelAdmin):
    pass

admin.site.register(Capability, CapabilityAdmin)

@radiac radiac reopened this Nov 25, 2024
@alfonsrv
Copy link

alfonsrv commented Nov 25, 2024

The issue is in relation to staticfiles. It works fine with DEBUG=False when using nanodjango serve ... instead of nanodjango run ... fyi – just wish there was a single command to run nanodjango and it just auto-magically takes care of hassle-free setup.

I honestly find the amount of different commands quite irritating.

edit: Might also be worth noting for admin auth to work in "production", CSRF_TRUSTED_ORIGINS has to be set – otherwise CSRF validation fails when attempting to log in.
Not necessarily related, but CSRF seems to be a bit of an issue generally #50

@radiac
Copy link
Owner

radiac commented Nov 26, 2024

Thanks for this info, I'll look into this again shortly.

Regarding the different commands, there's run for running locally with debug in dev mode - that's the one I expect people will use most. The other command is serve, for running the same script in production for public access. Evidently the docs could do with some clarification- thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants