This is a SCRIPT-8 cassette.
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // | |
| // ContentView.swift | |
| // AppRouterPlayground | |
| // | |
| // Created by Ben Cardy on 22/02/2023. | |
| // | |
| import SwiftUI | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // | |
| // EqualWidthIcons.swift | |
| // From https://bencardy.co.uk/2023/02/02/swiftui-equal-width-icons/ | |
| // | |
| // Created by Ben Cardy on 02/02/2023. | |
| // | |
| import SwiftUI | |
| struct WhatsNewSection: View { | 
- self.requestis the way to get the request object
- self.argsand- self.kwargsare the URL parameters from- urls.py(they are also passed to almost every method, but they're not always, and some methods take an- argsand- kwargsthat aren't the ones from the URL, so... just use- self.everywhere!)
- dispatchis called before- getor- postso is a useful place to setup stuff you need everywhere
- the view object itself is available in the template as view, so templates can access view methods and properties
- Detail and List views don't just get the template variables objectandobject_list, they also get<model-name>and<model-name>_list
- Permission decorators etc are better handled by django-braces
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from django.utils.http import urlencode | |
| def reverse_querystring(view, urlconf=None, args=None, kwargs=None, current_app=None, query_kwargs=None): | |
| '''Custom reverse to handle query strings. | |
| Usage: | |
| reverse('app.views.my_view', kwargs={'pk': 123}, query_kwargs={'search': 'Bob'}) | |
| ''' | |
| base_url = reverse(view, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app) | |
| if query_kwargs: | |
| return '{}?{}'.format(base_url, urlencode(query_kwargs)) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Colours: | |
| BLACK = '\033[30m' | |
| BLUE = '\033[34m' | |
| GREEN = '\033[32m' | |
| CYAN = '\033[36m' | |
| RED = '\033[31m' | |
| PURPLE = '\033[35m' | |
| YELLOW = '\033[33m' | |
| LIGHT_GREY = '\033[37m' | |
| DARK_GREY = '\033[1;30m' |