Atrox / sweetify-django

SweetAlert integration for Django
BSD 3-Clause "New" or "Revised" License
55 stars 21 forks source link

Not working in Django #16

Closed guilherme-funchal closed 4 years ago

guilherme-funchal commented 4 years ago

Hi, I followed all the steps to install on Django and I was not successful.

Inside my views.py I inserted :

import sweetify

sweetify.fire('Good job!', 'You clicked the button!', 'success')

No message appears.

Atrox commented 4 years ago

Please take a look at issue #11. Is sweetalert installed correctly?

guilherme-funchal commented 4 years ago

Hello, thank for you reply.

It includes installation in the generation of the docker container and apparently everything is OK.

Atrox commented 4 years ago

Did you try this https://github.com/Atrox/sweetify-django/issues/11#issuecomment-562600746?

guilherme-funchal commented 4 years ago

I need to install the sweetify2 or just sweetify (pip install sweetify) ?

guilherme-funchal commented 4 years ago

In my code I inserted: sweetify.sweetalert(request, 'Title', button=True)

Error : The view aries_community.views.handle_credential_offer didn't return an HttpResponse object. It returned None instead.

Atrox commented 4 years ago

As stated in the README "Note: This package does not provide the client-side files of SweetAlert. You have to provide them yourself." you have to install the client-side part yourself. So you need to install both sweetify and sweetalert2.

Regarding your error: Did you read the README at all? You still have to redirect at the end.

guilherme-funchal commented 4 years ago

Take a look

            sweetify.success(request, 'test')
            return redirect('/connections')

Nothing happens...

Atrox commented 4 years ago

Did you try this https://github.com/Atrox/sweetify-django/issues/11#issuecomment-562600746?

Did you try this?

guilherme-funchal commented 4 years ago

The Django is running inside a container, how do I do this?

Atrox commented 4 years ago

This has nothing to do with your container. Open your browser, navigate to your site and execute the line?

guilherme-funchal commented 4 years ago

VM129:1 Uncaught ReferenceError: Swal is not defined at :1:1

guilherme-funchal commented 4 years ago

Sorry, but not is clear to me where I must install the lib sweetalert2.

Should I generate the Django container with the library or load it on the base page of the site?

I try to execute in console of Chrome and I get the error:

Uncaught ReferenceError: Swal is not defined

Atrox commented 4 years ago

Yeah, so you are missing the sweetalert2 library. Include it in your base template to load it.

guilherme-funchal commented 4 years ago

How I do this ?

Atrox commented 4 years ago

Put <script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script> into your base template

guilherme-funchal commented 4 years ago

Its works, thanks a lot for your help.

Atrox commented 4 years ago

Glad to hear :)

guilherme-funchal commented 4 years ago

Why doesn't the image appear?

Atrox commented 4 years ago

I can't help you if you give me no information whatsoever.

guilherme-funchal commented 4 years ago

Thanks a lot again...Its works...just pass icon='error' for example in thes command.