Check if latest exists before updating
@@ -324,9 +324,9 @@ class Project(models.Model):
for owner in self.users.all():
assign('view_project', owner, self)
try:
- latest = self.versions.get(slug=LATEST)
+ latest = self.versions.filter(slug=LATEST).first()
default_branch = self.get_default_branch()
- if latest.identifier != default_branch:
+ if latest and latest.identifier != default_branch:
latest.identifier = default_branch
latest.save()
except Exception:
