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

  • SEARCH
  • Home
  • 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 3429012
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:01:48+00:00 2026-05-18T07:01:48+00:00

In Django, there’s the existence of a message framework which notifies the user after

  • 0

In Django, there’s the existence of a message framework which notifies the user after an action is performed. For instance, from the views.py there might something like:

if success:
    messages.success(request, 'Update Successful')
else:
    messages.warning(request, 'Something is missing')

I believe Rails have something similar with:

flash[:notice] = 'Something is missing'

Should the messages above be hard-coded in the controller?

  • 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-18T07:01:49+00:00Added an answer on May 18, 2026 at 7:01 am

    If I understand your question, you are asking whether or not you should hard-code a string value into your code. In compiled languages, you often use a reference to a string, instead of entering the actual string. ala:

    message.success(request, message_resource.success )
    

    This gives you the freedom to change the string value without re-compiling the code, and has a performance benefit in some instances.

    Because Python is dynamic this really isn’t required, but depending on the size of the project, may be beneficial.

    Imagine a situation where the software is used by people speaking different languages, you could detect the required language somewhere else in your code and initialize message_resource.success, as well as any other strings, to be in said language.

    here is a simple example:

    german.py

    # german language messages
    success = "Sie folgten!"
    failure = "Sie fallen aus!"
    

    english.py

    #english language messages
    success = "You succeeded!"
    failure = "You fail!"
    

    main.py

    # main
    
    # import english language
    message_resource = __import__('english');
    
    print message_resource.success
    print message_resource.failure
    
    # import german language
    message_resource = __import__('german');
    
    print message_resource.success
    print message_resource.failure
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In django framework,When there are changes in urls.py or model.py or views.py .We would
Is there analogue of Django Messages Framework (or RoR flash messages) in Java? http://docs.djangoproject.com/en/dev/ref/contrib/messages/
In django is there way to import all modules ex: from project.models import *
Django as a framework is a neat little package. There are very few files
Is there any c# web framework like Django or Ruby on Rails? I know
I am a Java developer. Is there some Django/Ruby-on-Rails kind of framework for Java?
If there is someone here from the Django world that can teach the best
Before Django 1.0 there was an easy way to get the admin url of
is there anything built-in in Django templates that will allow me to compare two
Is there a recommended way of using Django to clean an input string without

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.