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

DifficultyTag's aren't sorted #344

Open
metenn opened this issue Mar 17, 2024 · 1 comment
Open

DifficultyTag's aren't sorted #344

metenn opened this issue Mar 17, 2024 · 1 comment

Comments

@metenn
Copy link
Contributor

metenn commented Mar 17, 2024

Seems like somebody forgot ordering = ['pk'] in Meta

class DifficultyTag(models.Model):
name = models.CharField(
max_length=20,
unique=True,
verbose_name=_("name"),
null=False,
blank=False,
validators=[
validators.MinLengthValidator(3),
validators.MaxLengthValidator(20),
validators.validate_slug,
],
)
problems = models.ManyToManyField(Problem, through='DifficultyTagThrough')
class Meta(object):
verbose_name = _("difficulty tag")
verbose_name_plural = _("difficulty tags")
def __str__(self):
return str(self.name)

same goes for DifficultyTagLocalization, which is why this code returns unsorted rows (per SQL specs rows are not automatically sorted by any field)
for tag in DifficultyTagLocalization.objects.filter(language=get_language())

so another fix would probably be adding an .order_by() here?

perhaps the ordering should be more explicit in the first place rather than relying on the autogenerated pk field?

@metenn
Copy link
Contributor Author

metenn commented Mar 17, 2024

As a bonus:
Seems like the styling on these buttons is a bit broken, not to mention the inconsistent heights.

firefox_fxvXzzAbva.mp4

@dawidratynski dawidratynski self-assigned this May 21, 2024
@dawidratynski dawidratynski removed their assignment Jun 12, 2024
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