How to return arrayfield in django model?How to convert list to stringDjango foreign key access in save() functiondjango - inlineformset_factory with more than one ForeignKeySaving form data rewrites the same rowShow information of subclass in list_display djangoDjango south migration error with unique field in postgresql databaseRadio buttons in django adminfilter json data from Django modelDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to expose some specific fields of model_b based on a field of model_a?How to set dynamic initial values to django modelform field
Are there liquid fueled rocket boosters having coaxial fuel/oxidizer tanks?
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
Sum Square Difference, which way is more Pythonic?
Some pads on a PCB are marked in clusters and I can't understand which one is which
How can I communicate my issues with a potential date's pushy behavior?
Why aren't rainbows blurred-out into nothing after they are produced?
How do I call a 6-digit Australian phone number with a US-based mobile phone?
Doesn't the speed of light limit imply the same electron can be annihilated twice?
Go to last file in vim
Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?
What is the most difficult concept to grasp in Calculus 1?
What would it take to get a message to another star?
A man in the desert is bitten by a skeletal animal, its skull gets stuck on his arm
How to gracefully leave a company you helped start?
What is the farthest a camera can see?
Is the Microsoft recommendation to use C# properties applicable to game development?
Are there any cons in using rounded corners for bar graphs?
What was the intention with the Commodore 128?
What would cause a nuclear power plant to break down after 2000 years, but not sooner?
Airline power sockets shut down when I plug my computer in. How can I avoid that?
What is a "soap"?
What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?
Why aren’t there water shutoff valves for each room?
Who is the controller of a Pacifism enchanting my creature?
How to return arrayfield in django model?
How to convert list to stringDjango foreign key access in save() functiondjango - inlineformset_factory with more than one ForeignKeySaving form data rewrites the same rowShow information of subclass in list_display djangoDjango south migration error with unique field in postgresql databaseRadio buttons in django adminfilter json data from Django modelDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to expose some specific fields of model_b based on a field of model_a?How to set dynamic initial values to django modelform field
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This is my models.py
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return self.product
But i'm getting error like :
TypeError at /admin/ordering/product/add/
str returned non-string (type list)
django
|
show 2 more comments
This is my models.py
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return self.product
But i'm getting error like :
TypeError at /admin/ordering/product/add/
str returned non-string (type list)
django
you need to convert it to string to display
– webbyfox
Mar 27 at 11:33
stackoverflow.com/questions/5618878/…
– Endre Both
Mar 27 at 11:35
method str should return string, not list.
– Anish
Mar 27 at 11:37
Actually im new to django i just searched how to use arary field in django model and i got this docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
– neha
Mar 27 at 11:37
Possible duplicate of How to convert list to string
– webbyfox
Mar 27 at 11:37
|
show 2 more comments
This is my models.py
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return self.product
But i'm getting error like :
TypeError at /admin/ordering/product/add/
str returned non-string (type list)
django
This is my models.py
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return self.product
But i'm getting error like :
TypeError at /admin/ordering/product/add/
str returned non-string (type list)
django
django
edited Mar 27 at 11:31
Anish
2,4094 gold badges26 silver badges52 bronze badges
2,4094 gold badges26 silver badges52 bronze badges
asked Mar 27 at 11:29
nehaneha
85 bronze badges
85 bronze badges
you need to convert it to string to display
– webbyfox
Mar 27 at 11:33
stackoverflow.com/questions/5618878/…
– Endre Both
Mar 27 at 11:35
method str should return string, not list.
– Anish
Mar 27 at 11:37
Actually im new to django i just searched how to use arary field in django model and i got this docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
– neha
Mar 27 at 11:37
Possible duplicate of How to convert list to string
– webbyfox
Mar 27 at 11:37
|
show 2 more comments
you need to convert it to string to display
– webbyfox
Mar 27 at 11:33
stackoverflow.com/questions/5618878/…
– Endre Both
Mar 27 at 11:35
method str should return string, not list.
– Anish
Mar 27 at 11:37
Actually im new to django i just searched how to use arary field in django model and i got this docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
– neha
Mar 27 at 11:37
Possible duplicate of How to convert list to string
– webbyfox
Mar 27 at 11:37
you need to convert it to string to display
– webbyfox
Mar 27 at 11:33
you need to convert it to string to display
– webbyfox
Mar 27 at 11:33
stackoverflow.com/questions/5618878/…
– Endre Both
Mar 27 at 11:35
stackoverflow.com/questions/5618878/…
– Endre Both
Mar 27 at 11:35
method str should return string, not list.
– Anish
Mar 27 at 11:37
method str should return string, not list.
– Anish
Mar 27 at 11:37
Actually im new to django i just searched how to use arary field in django model and i got this docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
– neha
Mar 27 at 11:37
Actually im new to django i just searched how to use arary field in django model and i got this docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
– neha
Mar 27 at 11:37
Possible duplicate of How to convert list to string
– webbyfox
Mar 27 at 11:37
Possible duplicate of How to convert list to string
– webbyfox
Mar 27 at 11:37
|
show 2 more comments
2 Answers
2
active
oldest
votes
In your __str__()
method of model Product
self.product returns list of names.
class Product(models.Model):
...
def __str__(self):
return self.product # This returns list of names
You can either convert self.product to string manually or replace with following one.
class Product(models.Model):
...
def __str__(self):
return ", ".join(self.product) # This would join list of names with ,
add a comment |
Just convert your product array to string. For that you can type cast product array to string
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return str(self.product)
str(anything)
will convert any python object into its string representation
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%2f55376127%2fhow-to-return-arrayfield-in-django-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your __str__()
method of model Product
self.product returns list of names.
class Product(models.Model):
...
def __str__(self):
return self.product # This returns list of names
You can either convert self.product to string manually or replace with following one.
class Product(models.Model):
...
def __str__(self):
return ", ".join(self.product) # This would join list of names with ,
add a comment |
In your __str__()
method of model Product
self.product returns list of names.
class Product(models.Model):
...
def __str__(self):
return self.product # This returns list of names
You can either convert self.product to string manually or replace with following one.
class Product(models.Model):
...
def __str__(self):
return ", ".join(self.product) # This would join list of names with ,
add a comment |
In your __str__()
method of model Product
self.product returns list of names.
class Product(models.Model):
...
def __str__(self):
return self.product # This returns list of names
You can either convert self.product to string manually or replace with following one.
class Product(models.Model):
...
def __str__(self):
return ", ".join(self.product) # This would join list of names with ,
In your __str__()
method of model Product
self.product returns list of names.
class Product(models.Model):
...
def __str__(self):
return self.product # This returns list of names
You can either convert self.product to string manually or replace with following one.
class Product(models.Model):
...
def __str__(self):
return ", ".join(self.product) # This would join list of names with ,
answered Mar 27 at 11:42
Devang PadhiyarDevang Padhiyar
1,2178 silver badges24 bronze badges
1,2178 silver badges24 bronze badges
add a comment |
add a comment |
Just convert your product array to string. For that you can type cast product array to string
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return str(self.product)
str(anything)
will convert any python object into its string representation
add a comment |
Just convert your product array to string. For that you can type cast product array to string
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return str(self.product)
str(anything)
will convert any python object into its string representation
add a comment |
Just convert your product array to string. For that you can type cast product array to string
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return str(self.product)
str(anything)
will convert any python object into its string representation
Just convert your product array to string. For that you can type cast product array to string
class Product(models.Model):
product = ArrayField(ArrayField(models.CharField(max_length=200), blank=True))
def __str__(self):
return str(self.product)
str(anything)
will convert any python object into its string representation
answered Mar 27 at 12:08
AnishAnish
2,4094 gold badges26 silver badges52 bronze badges
2,4094 gold badges26 silver badges52 bronze badges
add a comment |
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%2f55376127%2fhow-to-return-arrayfield-in-django-model%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
you need to convert it to string to display
– webbyfox
Mar 27 at 11:33
stackoverflow.com/questions/5618878/…
– Endre Both
Mar 27 at 11:35
method str should return string, not list.
– Anish
Mar 27 at 11:37
Actually im new to django i just searched how to use arary field in django model and i got this docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
– neha
Mar 27 at 11:37
Possible duplicate of How to convert list to string
– webbyfox
Mar 27 at 11:37