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;








1















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)











share|improve this question


























  • 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

















1















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)











share|improve this question


























  • 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













1












1








1








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)











share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












2 Answers
2






active

oldest

votes


















0














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 ,





share|improve this answer
































    0














    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






    share|improve this answer



























      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%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









      0














      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 ,





      share|improve this answer





























        0














        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 ,





        share|improve this answer



























          0












          0








          0







          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 ,





          share|improve this answer













          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 ,






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 11:42









          Devang PadhiyarDevang Padhiyar

          1,2178 silver badges24 bronze badges




          1,2178 silver badges24 bronze badges


























              0














              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






              share|improve this answer





























                0














                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






                share|improve this answer



























                  0












                  0








                  0







                  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






                  share|improve this answer













                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 27 at 12:08









                  AnishAnish

                  2,4094 gold badges26 silver badges52 bronze badges




                  2,4094 gold badges26 silver badges52 bronze badges






























                      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%2f55376127%2fhow-to-return-arrayfield-in-django-model%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

                      How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

                      Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?