2024-12-06-Friday


created: 2024-12-06 06:21 tags: - daily-notes


Friday, December 06, 2024

<< Timestamps/2024/12-December/2024-12-05-Thursday|Yesterday | Timestamps/2024/12-December/2024-12-07-Saturday|Tomorrow >>


🎯 Goal


🌟 Results

  • Learned how to Django Bulk Upload my ideas into the BigBrain App. Maybe this is the right app to upload my dev notes to? I wonder if it can support markdown.
  • installed the AWS CLI, used it to pre-sign the URL of and S3 object, then used my custom command to upload my ideas into the app.

🌱 Next Time


📝 Notes

Wanted to continue working through Django Bulk Uploading my BigBrain App data. Learning how to do this will allow me to populate different databases from apps within the main DIMMiN App easier in the future, so it's a good component to learn.

I re-uploaded the data I wanted to load into S3 and generated a new pre-signed URL. Then I copied the data using curl into a temporary directory in my Heroku CLI with

curl -o bulk_upload_data.txt presigned-url

When I looked at the actual data that was being transferred I saw an XML file that mentioned that the request was invalid.

I decided to install the AWS CLI via the windows installer page. I configured my AWS credentials with

aws configure

Then I could run the following command:

aws s3 presign s3://your-bucket-name/path/to/your-file.txt --expires-in 3600

Then I could transfer the file successfully with

curl -o "/tmp/bulk_upload_data.txt" "pre-signed-url"

which actually transferred in the data. Finally, I just needed to run my new command of

python manage.py bulk_upload_ideas

which worked! Unfortunately because I used a blank string as the optional working title none of the ideas were actually accessible... whoops. I ran it again to check that it wouldn't produce duplicates and thankfully it worked (i.e didn't just add all of the pre-existing ideas again).

Now I wonder if there's a way to update all of these rows from blank values to null values in the Heroku CLI / using the Django manage.py file. ChatGPT helped me with the following shell script:

python manage.py shell
from apps.bigbrain.models import Idea
Idea.objects.filter(optional_working_title='').update(optional_working_title=None)

which successfully updated my ideas using Django QuerySets!

I also found additional ideas in my notes so I'll upload those as well using the same procedure.

Finally as a quick adjustment to the Django Admin view of the ideas, I want them to be in reverse order which I adjusted by overriding the get_ordering() method of the admin.ModelAdmin Class:

@admin.register(Idea)
class IdeaAdmin(admin.ModelAdmin):
    list_display = ('optional_working_title', 'details')
    search_fields = ('details', 'optional_working_title')

    def get_ordering(self, request):
        return ['-created_at']

I also decided to do the same for the Project Django Model, ordering them by priority. Unfortunately priority is sorting by alphabetical order. I wonder if I should adjust this field to represent integers instead...? Either way that's pretty low on my list of priorities.


Notes created today

List FROM "" WHERE file.cday = date("2024-12-06") SORT file.ctime asc

Notes last touched today

List FROM "" WHERE file.mday = date("2024-12-06") SORT file.mtime asc

(Template referenced from Dann Berg, can be found here)


Previous Note 2024-12-05-Thursday Next Note 2024-12-09-Monday