Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6733797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:48:45+00:00 2026-05-26T10:48:45+00:00

I’m writing a Django application which will require a Script object which has access

  • 0

I’m writing a Django application which will require a Script object which has access both to a file containing the script and the fulltext of the script. The script file is an xls file, and I have no problems in extracting the data from it or writing data to it programmatically (xlrd and friends are great!), and I’m storing it in a models.FileField. I would like to store the fulltext in a models.TextField, but my problem is that I don’t know how to put the workflow together correctly so that the fulltext and the stored file mirror each other.

Workflows I want:

Script object created -> file uploaded to file field -> text extracted from file saved to fulltext field

and

Script fulltext edited -> text written back to file in file field -> script saved

and

Script file replaced with new file -> text extracted from file saved to fulltext field

I have been playing around with the signals framework (presave and postsave), but I don’t know how to make it, er, save the changes that I am hoping for, since that would require calling save->generating an infinite loop. Also, presave seems to be invoked before the file is uploaded (using a form), which makes my server puke at me.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:48:46+00:00Added an answer on May 26, 2026 at 10:48 am

    It turns out that I was overengineering this problem. The signal I was actually looking for was post_init, and the function that I wrote is literally just

    @receiver(post_save, sender=Script)
    def retrieve_fulltext(sender, **kwargs):
        script = kwargs['instance']
        s = open(script.script.path)
        text = s.read()
    
        if script.fulltext == text:
            return else: script.fulltext = text
            script.save()
    

    Which still, yes, requires a bit more to make it work with changes in fulltext triggering a write to the file. Sorry, SO, for asking a silly question. I hope this answer is at least useful to someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.