# How To Programmatically Set A Course Advanced Fields

**URL:** <https://discuss.openedx.org/t/how-to-programmatically-set-a-course-advanced-fields/8901>\
**Category:** Development\
**Tags:** how-to\
**Created:** [December 11, 2022, 5:53am UTC](https://discuss.openedx.org/t/how-to-programmatically-set-a-course-advanced-fields/8901 "2022-12-11T05:53:27Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![arbrandes](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/arbrandes/32/158_2.png) [@arbrandes](https://discuss.openedx.org/u/arbrandes)\
**Post date:** [December 13, 2022, 8:26pm UTC](https://discuss.openedx.org/t/how-to-programmatically-set-a-course-advanced-fields/8901/21 "2022-12-13T20:26:17Z")

</div>

P.S.

I can’t stress this enough: an issue report without instructions to reproduce the problem from scratch is a _very difficult_ one to fix. Even experienced developers (perhaps specially them!), when browsing bug reports to try and fix, will instinctively skip these.

Reproducing the bug gets you half way to fixing it. I see folks are trying to do that here, which is encouraging. 👍

---

<div class="post-metadata">

**Author:** ![Zachary\_Trabookis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/zachary_trabookis/32/753_2.png) [@Zachary\_Trabookis](https://discuss.openedx.org/u/Zachary_Trabookis)\
**Post date:** [December 14, 2022, 8:44pm UTC](https://discuss.openedx.org/t/how-to-programmatically-set-a-course-advanced-fields/8901/22 "2022-12-14T20:44:39Z")

</div>

@arbrandes @sambapete @ghassan

We put in a PR with the `master` branch here to use a Django CMS management command to bulk update course advanced settings using the existing `update_course_advanced_settings` found at cms/djangoapps/contentstore/views/course.py.

> <https://github.com/openedx/edx-platform/pull/31449>
>
> \## Description
> 
> Needed a way to set course advanced fields through the Django …management command line. Instead of call the REST PATCH endpoint here cms/djangoapps/contentstore/rest\_api/v0/views/advanced\_settings.py we utilized the \`update\_course\_advanced\_settings\` method here cms/djangoapps/contentstore/views/course.py to pass JSON override values for one or more courses.
> 
> A \`--force-update-catalog-visibility-about\` command option was added to include advanced setting. When upgrading from an older release to \`Maple\` we had this \`catalog\_visibility\` set to \`none\` which produced the \`There was an error loading this course\` message when viewing the course MFE Learning frontend. It was necessary to make sure these courses didn't have the \`none\` value and received \`about\` or \`both\` settings to have the page load properly. This command sets the value to \`about\` to prevent the course from uploading to the \`course-discovery\` service and out to the marketing frontend.
> \`\`\`
> {
> "catalog\_visibility": {
> "value": "about"
> }
> }
> \`\`\`
> 
> \## Supporting information
> 
> We’re running into this issue mentioned above for students to be able to view the MFE learning page when Course Visibility in Catalog is set to none. The students receive the \`There was an error loading this course.\` message and nothing loads on the Course Home page. Also the LMS log files indicate no error messages so we were lucky to find this discussion article.
> 
> Reference: https://discuss.openedx.org/t/how-to-programmatically-set-a-course-advanced-fields/8901
> 
> \## Testing instructions
> 
> When upgrading from prior release to \`Maple\` we had several courses with \`course\_visibility\` set to \`none\` value. With this setting we traversed to the MFE Learning frontend and saw error message with \`There was an error loading this course.\` and a HTTP 404 response from an EdX API endpoint in the JavaScript console was indicated.
> 
> !\[image\](https://user-images.githubusercontent.com/5641338/207708976-8cb10613-aa01-4770-82fe-9131f097c7fd.png)
> 
> HTTP 404 Response was at this address.
> https://{{ LMS\_HOST }}/api/course\_home/course\_metadata/course-v1:CUCWD+FAA-ACS-AM-ID-FLF+DOCUMENTATION?browser\_timezone=America%2FNew\_York

We added in a `--limit-bulk-update-operation {0-N}` command option to prevent the command from consuming all server memory and crashing the server. So far this looks promising.

cc @traek728 @becdavid

[Previous page](https://discuss.openedx.org/t/how-to-programmatically-set-a-course-advanced-fields/8901.md?page=1)
