-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Properly slugify the alias on Project Relationships. #3440
Conversation
**This includes a migration that will break some URL's**. In the past we haven't slugified aliases, so this will break URL's for projects in that state.
Pared down the initial migration to not change capitalization, and it looks like it does what I want. People will break their own URL's going forward if they try and change their alias. |
migrations.AlterField( | ||
model_name='project', | ||
name='programming_language', | ||
field=models.CharField(blank=True, choices=[('words', 'Only Words'), ('py', 'Python'), ('js', 'JavaScript'), ('php', 'PHP'), ('ruby', 'Ruby'), ('perl', 'Perl'), ('java', 'Java'), ('go', 'Go'), ('julia', 'Julia'), ('c', 'C'), ('csharp', 'C#'), ('cpp', 'C++'), ('objc', 'Objective-C'), ('other', 'Other')], default='words', help_text='The primary programming language the project is written in.', max_length=20, verbose_name='Programming Language'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above here is just noise from things we've missed I think? I can probably kill it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are updating the DB here and chaging the CharField for SlugField but we are not touching the logic for new created alias.
Does the SlugField run automatically the slugify on it? (I don't remember clearly) Even if it runs it, it seems that we need our custom one, right?
readthedocs/projects/models.py
Outdated
@@ -52,7 +52,7 @@ class ProjectRelationship(models.Model): | |||
related_name='subprojects') | |||
child = models.ForeignKey('Project', verbose_name=_('Child'), | |||
related_name='superprojects') | |||
alias = models.CharField(_('Alias'), max_length=255, null=True, blank=True) | |||
alias = models.SlugField(_('Alias'), max_length=255, null=True, blank=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think db_index=False
should be added. Since it's True
by default for SlugField
It runs automatically in Django. Django's allow's |
This includes a migration that will break some URL's.
In the past we haven't slugified aliases,
so this will break URL's for projects in that state.
This shows effected projects: