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

tagging feature #174

Closed
bbelderbos opened this issue Jan 22, 2024 · 11 comments
Closed

tagging feature #174

bbelderbos opened this issue Jan 22, 2024 · 11 comments
Assignees

Comments

@bbelderbos
Copy link
Collaborator

I have it like this:

class Tag(models.Model):
    name = models.CharField(max_length=128)

    def __str__(self):
        return self.name

On Tune model:

    tags = models.ManyToManyField(Tag, related_name='tags')
@bbelderbos
Copy link
Collaborator Author

Then in admin:

class YourAdmin(admin.ModelAdmin):
    ...
    autocomplete_fields = ('tags')

But I want to investigate how to get this niceness on the front-end ...

@bbelderbos
Copy link
Collaborator Author

desired front-end = like django admin m2m:

Screenshot 2024-01-22 at 15 30 36

@bbelderbos
Copy link
Collaborator Author

@jwjacobson seems not natively doable with htmx so I am happy to play with this gpt suggestion to offload this from you:

image

@bbelderbos
Copy link
Collaborator Author

@jwjacobson can you spec out the feature a bit?

  • should there be a set of fixed tags? In that case superuser can manage that in admin
  • should users add tags? if so, in the same create tune form or in a separate view?
  • the create tune form already yields tags, but it did not seem to work, let me check this now ...

So the key question is if you want to autocomplete on the tags which involves more JS, not sure if that's really a prio for MVP?

@bbelderbos
Copy link
Collaborator Author

Update create tune view only renders tags added by admin first (the save/linking did not work but I logged and fixed that here: #184)

@bbelderbos
Copy link
Collaborator Author

So the question remains do you want to have user add tags at the front-end and if so will you make a new crud for it? In that case you might also want to add a user foreign key column to the tag table to keep track of who owns which tag ...

@jwjacobson
Copy link
Owner

I think autocomplete on tags can be a nice to have, and not doing it for now could involve a much simpler implementation

The idea for tags is that you can have various bits of information about a tune that don't fit into any of the provided fields and would make tune management too cumbersome if they each had their own field. In its simplest form a tag is just a string of text. Possible tags I'm imagining are "ballad" (if the tune is a ballad), "latin" (if the tune is played in latin style), "rhythm" or "rhythm_changes" (if the tunes uses rhythm changes), etc. Basically little notes on the style or structure of a tune which will all be searchable.

The user should be able to add any tags they want, as this would be a space for significant repertoire customization. They might want to add tags for tunes they play with specific people or groups, or really anything.

With autocomplete, my thinking was just that a lot of the structural/stylistic tags will end up being common to many users so it makes sense for them to be able to access that pool of common tags. On the other hand it's much more complicated to implement.

Do you think it might make sense for now to just have tags as a charfield? This would capture all of the functionality I describe minus autocomplete which isn't a necessity anyway

@bbelderbos
Copy link
Collaborator Author

Thanks for clarifying, no need for tag ownership then.
An autocomplete to retrieve + add tags would be really convenient then, let me check again ... yesterday I found a bunch of jquery but not sure if it would be good to bring that into this project ...

@bbelderbos
Copy link
Collaborator Author

Going to try this out tomorrow:

https://django-autocomplete-light.readthedocs.io/en/master/index.html

Feature included:

Creating choices that don’t exist in the autocomplete

@bbelderbos
Copy link
Collaborator Author

Did this:

image

Seems exactly what we need!

Screenshot 2024-01-25 at 13 14 08 Screenshot 2024-01-25 at 13 13 26

@jwjacobson
Copy link
Owner

Just using little checkboxes for now, works fine. Of course the user can't add their own tags yet...

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

2 participants