adamghill / django-unicorn

The magical reactive component framework for Django ✨
https://www.django-unicorn.com
MIT License
2.33k stars 118 forks source link

Improve tutorial installation #699

Open CedricRaison opened 2 months ago

CedricRaison commented 2 months ago

Hello,

The documentation for setting up a Django Unicorn project is not very clear. I was following the installation process: https://www.django-unicorn.com/docs/installation/

Here are the issues I encountered:

  1. The first small issue is that it asks to install django-unicorn without first instructing to install and set up a Django project. It should specify this beforehand.

  2. The second issue is that it's not very clear how to set up the template. Here is the documentation:

3. Add {% load unicorn %} to the top of the Django HTML template.

4. Add {% unicorn_scripts %} into the Django HTML template and make sure there is a {% csrf_token %} in the template as well.
<!-- index.html -->
{% load unicorn %}
<html>
  <head>
    {% unicorn_scripts %}
  </head>
  <body>
    {% csrf_token %}
  </body>
</html>

But where is this supposed to be placed? Should I create an empty Django project with django startapp application_name, create a templates folder inside it, and add an index.html inside? Should I create an "empty" view that will show this template? What about the startunicorn command? Should it be a different app? If yes, what is the purpose of creating a Django app just for an index.html file?

I'm just following the tutorial, and I think it should be clearer on how to install and set up a Django Unicorn project.

I'm sorry to create issue like this but I think it could really help newcomer like me to the project.

Thank you.

CedricRaison commented 2 months ago

That would be great if you know how to startup a django-unicorn project

CedricRaison commented 2 months ago

It would be a lot better to improve the official documentation so every one can benefit from it.

CedricRaison commented 2 months ago

Do it yourself if you know how to improve it. I cannot because I don't understand how to setup a django-unicorn project but if I could I would have made the PR myself.

tataraba commented 2 months ago

I was talking to @adamghill hill about this recently and I think you make a good point here about making the documentation a little clearer as to how to get started. I may work on this, but probably not till next week. I appreciate the examples you've given above, and if you have any other thoughts, feel free to drop them in here and I'll see if I can address those.

adamghill commented 2 months ago

@CedricRaison I really appreciate that you created this issue! I agree that the documentation should be more clear -- it currently makes a lot of assumptions. We'll be tackling this soon and we'll update this issue when there is something to check out. 👍

tataraba commented 1 month ago

@adamghill I'm thinking of adding a "Getting Started" section.

I was able to build docs locally to test some things, but one thing I was thinking of adding is collapsible/dropdown sections for basic items (installing python, creating django project, etc...)

I found out that to do that, I would need to add the a the sphinx extension sphinx-design

I tried to add that using poetry into the "docs" group, but got an error:

The current project's supported Python range (>=3.8,<4) is not compatible with some of the required packages Python requirement:
  - sphinx-design requires Python >=3.9, so it will not be satisfied for Python >=3.8,<3.9

I can keep going without those neat documentation things, but just wanted to bring this up. (This also would enable those tabbed groupings for things like different installation instructions, etc...)

adamghill commented 1 month ago

Oh, for tabbed groupings I was looking at https://github.com/pradyunsg/sphinx-inline-tabs. Let me see what I can do about sphinx-design, though.

adamghill commented 1 month ago

@tataraba

  1. I added this in pyproject.toml:
sphinx-design = { version = "*", optional = true }
  1. I added "sphinx-design" to the docs extras group in pyproject.toml
  2. Ran poetry lock && poetry install --extras docs --extras minify in the terminal and it seemed to work

Can you try that and see what happens for you?

tataraba commented 1 month ago

Okay, I was able to add sphinx-design with the instructions above...

Still got error during the build phase (can't recognize directive type: dropdown), but that may be user error there. I'll play around with it a bit more and let you know if I have any other issues.

adamghill commented 1 month ago

Not sure if you added it to the extensions, but maybe that's why? https://sphinx-design.readthedocs.io/en/latest/get_started.html#usage

tataraba commented 1 month ago

Yeah, I was missing that, but also had to add myst_enable_extensions = ["colon_fence"]

I added both to conf.py and now it's working locally for me. That should get me on my way. Hopefully should have something for you to look at tomorrow (I know it's late there 😁