| 217 | |
| 218 | == Separated flatpages and redirects into standalone, optional apps == |
| 219 | |
| 220 | As of ____, flatpages and redirects, previously installed by default, are now optional add-ons. Now they must be installed manually. |
| 221 | |
| 222 | === What changed === |
| 223 | |
| 224 | * The flatpages and redirects database files are no longer installed by default. |
| 225 | * Renamed all references to "flatfiles" -- a previous name for flatpages -- to "flatpages", to be unambiguous. |
| 226 | * Renamed the flatpages and redirects database tables. |
| 227 | * Moved all flatpages and redirects logic from throughout the Django code to {{{django.contrib}}}. |
| 228 | * To use flatpages and redirects, you now need to specify them in {{{INSTALLED_APPS}}} -- use {{{"django.contrib.flatpages"}}} and {{{"django.contrib.redirects"}}}. |
| 229 | |
| 230 | === How to update your code === |
| 231 | |
| 232 | If you're using a Django installation from before this changeset, do the following to restore flatpages and redirects functionality: |
| 233 | |
| 234 | ==== If you don't want to use flatfiles ==== |
| 235 | |
| 236 | * Execute the following SQL: |
| 237 | {{{ |
| 238 | DROP TABLE flatfiles; |
| 239 | DROP TABLE flatfiles_sites; |
| 240 | DELETE FROM auth_permissions WHERE package = 'core' AND codename IN ('add_flatfile', 'change_flatfile', 'delete_flatfile'); |
| 241 | DELETE FROM content_types WHERE package = 'core' AND python_module_name = 'flatfiles'; |
| 242 | }}} |
| 243 | |
| 244 | ==== If you don't want to use redirects ==== |
| 245 | |
| 246 | * Execute the following SQL: |
| 247 | {{{ |
| 248 | DROP TABLE redirects; |
| 249 | DELETE FROM auth_permissions WHERE package = 'core' AND codename IN ('add_redirect', 'change_redirect', 'delete_redirect'); |
| 250 | DELETE FROM content_types WHERE package = 'core' AND python_module_name = 'redirects'; |
| 251 | }}} |
| 252 | |
| 253 | ==== If you do want to use flatfiles and redirects ==== |
| 254 | |
| 255 | * Execute the following SQL: |
| 256 | {{{ |
| 257 | ALTER TABLE redirects RENAME TO django_redirects; |
| 258 | ALTER TABLE flatfiles RENAME TO django_flatpages; |
| 259 | ALTER TABLE flatfiles_sites RENAME TO django_flatpages_sites; |
| 260 | ALTER TABLE django_flatpages_sites RENAME flatfile_id TO flatpage_id; |
| 261 | INSERT INTO packages (label, name) VALUES ('flatpages', 'flatpages'); |
| 262 | UPDATE content_types SET package = 'flatpages', python_module_name = 'flatpages' WHERE package = 'core' AND python_module_name = 'flatfiles'; |
| 263 | UPDATE auth_permissions SET package = 'flatpages' WHERE package = 'core' AND codename IN ('add_flatfile', 'change_flatfile', 'delete_flatfile'); |
| 264 | INSERT INTO packages (label, name) VALUES ('redirects', 'redirects'); |
| 265 | UPDATE content_types SET package = 'redirects', python_module_name = 'redirects' WHERE package = 'core' AND python_module_name = 'redirects'; |
| 266 | UPDATE auth_permissions SET package = 'redirects' WHERE package = 'core' AND codename IN ('add_redirect', 'change_redirect', 'delete_redirect'); |
| 267 | }}} |
| 268 | * If you're using PostgreSQL, execute this SQL: |
| 269 | {{{ |
| 270 | ALTER TABLE redirects_id_seq RENAME TO django_redirects_id_seq; |
| 271 | ALTER TABLE django_redirects ALTER COLUMN id DROP DEFAULT; |
| 272 | ALTER TABLE django_redirects ALTER COLUMN id SET DEFAULT nextval('public.django_redirects_id_seq'::text); |
| 273 | ALTER TABLE flatfiles_id_seq RENAME TO django_flatpages_id_seq; |
| 274 | ALTER TABLE django_flatpages ALTER COLUMN id DROP DEFAULT; |
| 275 | ALTER TABLE django_flatpages ALTER COLUMN id SET DEFAULT nextval('public.django_flatpages_id_seq'::text); |
| 276 | }}} |
| 277 | * If you have a {{{flatfiles/default.html}}} template, rename it to {{{flatpages/default.html}}}. |
| 278 | * In every one of your flatpage templates, change the variable {{{flatfile}}} to {{{flatpage}}}. |
| 279 | * If you use the URLconf {{{django.conf.urls.flatfiles}}}, now point to {{{django.contrib.flatpages.urls}}}. |
| 280 | * If you have a {{{USE_FLAT_PAGES}}} setting, remove it. |