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
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
add a comment |
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
add a comment |
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
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
python django django-custom-field
edited Mar 8 at 11:17
Ajanyan Pradeep
434111
434111
asked Mar 7 at 18:38
PritamPritam
103
103
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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