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

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript