How to create simple custom field in django?2019 Community Moderator ElectionHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory in Python?How do I sort a dictionary by value?Does Django scale?How do I list all files of a directory?Radio buttons in django adminHow to expose some specific fields of model_b based on a field of model_a?How to define Mode with generic ForeignKey in Django

Emojional cryptic crossword

Is "inadequate referencing" a euphemism for plagiarism?

Is a square zero matrix positive semidefinite?

Pre-Employment Background Check With Consent For Future Checks

Don't understand why (5 | -2) > 0 is False where (5 or -2) > 0 is True

Why is indicated airspeed rather than ground speed used during the takeoff roll?

TDE Master Key Rotation

Why didn’t Eve recognize the little cockroach as a living organism?

Did Nintendo change its mind about 68000 SNES?

Print last inputted byte

Isn't the word "experience" wrongly used in this context?

What are rules for concealing thieves tools (or items in general)?

How to read string as hex number in bash?

How to test the sharpness of a knife?

Why didn't Héctor fade away after this character died in the movie Coco?

If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?

What kind of footwear is suitable for walking in micro gravity environment?

Difficulty understanding group delay concept

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Help with identifying unique aircraft over NE Pennsylvania

Is VPN a layer 3 concept?

Friend wants my recommendation but I don't want to

is this saw blade faulty?

10 year ban after applying for a UK student visa



How to create simple custom field in django?



2019 Community Moderator ElectionHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory in Python?How do I sort a dictionary by value?Does Django scale?How do I list all files of a directory?Radio buttons in django adminHow to expose some specific fields of model_b based on a field of model_a?How to define Mode with generic ForeignKey in Django










0















I want to create two additional properties of TextField such as property1 and property2 so that I can access them in template like



% for field in form %
field.property1
field.property2
% endfor %


my current model looks like



class ResponseModel(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
ans1 = models.TextField()
ans2 = models.TextField()
submit_count = models.IntegerField(default=0)

def __str__(self):
return str(self.author) + str(self.submit_count)









share|improve this question




























    0















    I want to create two additional properties of TextField such as property1 and property2 so that I can access them in template like



    % for field in form %
    field.property1
    field.property2
    % endfor %


    my current model looks like



    class ResponseModel(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    ans1 = models.TextField()
    ans2 = models.TextField()
    submit_count = models.IntegerField(default=0)

    def __str__(self):
    return str(self.author) + str(self.submit_count)









    share|improve this question


























      0












      0








      0








      I want to create two additional properties of TextField such as property1 and property2 so that I can access them in template like



      % for field in form %
      field.property1
      field.property2
      % endfor %


      my current model looks like



      class ResponseModel(models.Model):
      author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
      ans1 = models.TextField()
      ans2 = models.TextField()
      submit_count = models.IntegerField(default=0)

      def __str__(self):
      return str(self.author) + str(self.submit_count)









      share|improve this question
















      I want to create two additional properties of TextField such as property1 and property2 so that I can access them in template like



      % for field in form %
      field.property1
      field.property2
      % endfor %


      my current model looks like



      class ResponseModel(models.Model):
      author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
      ans1 = models.TextField()
      ans2 = models.TextField()
      submit_count = models.IntegerField(default=0)

      def __str__(self):
      return str(self.author) + str(self.submit_count)






      python django django-custom-field






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 11:17









      Ajanyan Pradeep

      434111




      434111










      asked Mar 7 at 18:38









      PritamPritam

      103




      103






















          1 Answer
          1






          active

          oldest

          votes


















          0














          in order to access the model properties in the template you should pass them through the view.py:



          **views.py**

          from .models import *

          def index(request):
          context=
          'form': ResponseModel


          return render(request, 'path/to/template', context)


          And in index.html (Template):



          % for field in form %
          field.property1
          field.property2
          % endfor %


          That should work just fine, let me know if you got it.






          share|improve this answer























          • I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

            – Pritam
            Mar 8 at 10:37











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55050667%2fhow-to-create-simple-custom-field-in-django%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          in order to access the model properties in the template you should pass them through the view.py:



          **views.py**

          from .models import *

          def index(request):
          context=
          'form': ResponseModel


          return render(request, 'path/to/template', context)


          And in index.html (Template):



          % for field in form %
          field.property1
          field.property2
          % endfor %


          That should work just fine, let me know if you got it.






          share|improve this answer























          • I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

            – Pritam
            Mar 8 at 10:37
















          0














          in order to access the model properties in the template you should pass them through the view.py:



          **views.py**

          from .models import *

          def index(request):
          context=
          'form': ResponseModel


          return render(request, 'path/to/template', context)


          And in index.html (Template):



          % for field in form %
          field.property1
          field.property2
          % endfor %


          That should work just fine, let me know if you got it.






          share|improve this answer























          • I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

            – Pritam
            Mar 8 at 10:37














          0












          0








          0







          in order to access the model properties in the template you should pass them through the view.py:



          **views.py**

          from .models import *

          def index(request):
          context=
          'form': ResponseModel


          return render(request, 'path/to/template', context)


          And in index.html (Template):



          % for field in form %
          field.property1
          field.property2
          % endfor %


          That should work just fine, let me know if you got it.






          share|improve this answer













          in order to access the model properties in the template you should pass them through the view.py:



          **views.py**

          from .models import *

          def index(request):
          context=
          'form': ResponseModel


          return render(request, 'path/to/template', context)


          And in index.html (Template):



          % for field in form %
          field.property1
          field.property2
          % endfor %


          That should work just fine, let me know if you got it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 10:17









          Dre RossDre Ross

          12116




          12116












          • I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

            – Pritam
            Mar 8 at 10:37


















          • I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

            – Pritam
            Mar 8 at 10:37

















          I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

          – Pritam
          Mar 8 at 10:37






          I couldn't make myself clear I'm sorry. I want to create two additional properties of TextField so that I can access them. I shall edit my question.

          – Pritam
          Mar 8 at 10:37




















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55050667%2fhow-to-create-simple-custom-field-in-django%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Can't find variable: document ReactNative Js2019 Community Moderator ElectionReactNative: how to center text?Can't find variable: navigate - ReactNative navigationReact Native error: “Can't find variable: TouchableHighlight”How to use Expo.DocumentPicker.getDocumentAsync properly. [Expo] [ReactNative]Can't find variable: regeneratorRuntime (ReactNative)Reactnative Expo It is advisable for a StartUp?Can't find variable : Self / Can't install firebaseNPM Install Error in installing ReactNative CLIContacts Displaying in App using ReactnativeFacebook login error: can't find variable: Alert

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices