Running sync_to_async to create object, but YET raise .ASynchronous exception

2020-05-06 Thread DAVID ALEJANDRO Pineda
Hello guys! I'm stucked on this problem, i have some script to save data to database using a django object. The script is with async,so i have to use the 'sync_to_async' function. Beyond that, running the script raise the ASynchronous exception, but it's look correct. Code: ``` async

Re: create object instance with ManyToManyField

2011-10-28 Thread Leonardo Giordani
The add() method of a ManyToMany field adds the indexes of the given objects to the field. If you add a list, each index in the list is added to the field. In the admin interface, when you edit a Company object, you see a convenient automagically-created menu which lists all Index object in your

Re: create object instance with ManyToManyField

2011-10-28 Thread Jaroslav Dobrek
Hello Leonardo, thanks your your answer. > n = Company(name=my_name, country=my_country, isin=my_isin) > n.save() > n.indices.add(my_indices) This causes that the company object has all indices in my_indices (such as Dow Jones S 100, Dax, ...) as *choices*. I.e. someone who manipulates these

Re: create object instance with ManyToManyField

2011-10-27 Thread Leonardo Giordani
Hi Jaroslav, you have to do the following n = Company(name=my_name, country=my_country, isin=my_isin) n.save() n.indices.add(my_indices) See here https://docs.djangoproject.com/en/dev/topics/db/queries/#saving-foreignkey-and-manytomanyfield-fields Bye 2011/10/27 Jaroslav Dobrek

create object instance with ManyToManyField

2011-10-27 Thread Jaroslav Dobrek
Hello, how can I create an object instance with a ManyToManyField. Everything works fine via the admin interface. But I don't understand how to do it in Python. Example: I have this model: class Company(models.Model): name = models.CharField(max_length=200, unique=True) country =

Re: Newbie Django 1.0 help with create object, uopdate object

2009-06-01 Thread adelaide_mike
Thanks Tim for your detailed reply. I have it now. HTML was incorrect, and yes, now I understand better what is happening I have rewritten the view as you suggest. I split it up only to try to make clearer to me what was happening. Thanks again. Mike On Jun 2, 1:48 am, Tim Sawyer

Re: Newbie Django 1.0 help with create object, uopdate object

2009-06-01 Thread Tim Sawyer
Hi, I think the recommended approach in django is for forms to submit to the current URL and for the view to decide whether the request is to display the form (a HTTP GET) or submit the form (HTTP POST). I'd suggest that you attempt to re-write this way. Your error could be caused by

Re: Newbie Django 1.0 help with create object, uopdate object

2009-06-01 Thread adelaide_mike
Thanks for your response Tim. However, you lost me a bit there, I am a real newbie. I have narrowed my question down to this: # in views.py: class PropertyForm(ModelForm): class Meta: model = Property def property_update(request, property_id='0', street_id='0'):

Re: Newbie Django 1.0 help with create object, uopdate object

2009-06-01 Thread Tim Sawyer
On Monday 01 June 2009 01:38:30 adelaide_mike wrote: > I found a really clear explanation of creating and updating database > objects in SAMS TeachYourself Django, but it appears to be for v > 0.96. > > I have looked at "Creating forms from models" in the documentation, > and about one-third the

Newbie Django 1.0 help with create object, uopdate object

2009-05-31 Thread adelaide_mike
I found a really clear explanation of creating and updating database objects in SAMS TeachYourself Django, but it appears to be for v 0.96. I have looked at "Creating forms from models" in the documentation, and about one-third the way down it shows the following: # Create a form instance from

Re: what's the correct way to create object with ForeignKey?

2006-11-08 Thread Aidas Bendoraitis
ubgroup.objects.get(subGroupName="p1sub1") e.save() m = User(name="xxx") m.save() e.user_set.add(m) Good luck! Aidas Bendoraitis [aka Archatas] On 11/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I know this maybe very simple, but I can't fi

what's the correct way to create object with ForeignKey?

2006-11-08 Thread [EMAIL PROTECTED]
I know this maybe very simple, but I can't find the answers on the net, I'm using following method to create object with ForeignKey, this however works, but according to django document you should avoid using "_id" column, what's the correct way to do this? any idea? (running d

Re: create object method

2006-01-16 Thread Max Battcher
The Boss wrote: that was needed. one problem with django i guess is figuring out what exactly are the correct names and hierarchy, Precisely, which is why the magic-removal branch has changed this particular annoyance (model classes now don't jump to a different namespace) and a few

Re: create object method

2006-01-16 Thread The Boss
thanks Joseph! that got me on the right track. it wasn't quite... from django.models.mypp.group import Group but... from django.models.mypp import groups that was needed. one problem with django i guess is figuring out what exactly are the correct names and hierarchy, but i just

Re: create object method

2006-01-14 Thread Joseph Kocherhans
On 1/14/06, The Boss <[EMAIL PROTECTED]> wrote: > > but when I try to put a check into add_related that says to create a > new group if the person doesn't yet have one > (by using > g=group.Group(name='x') > g.save() > > it tells me that global name groups is not defined, despite having > defined

create object method

2006-01-14 Thread The Boss
I am trying to do something really simple and I am sure there are 10 ways to do it but I can't seem to find one. I just want to include a method in one class to create a new object in another class. So I have a people class with a foreign key field to a group class. I made some methods to

Re: create object

2005-10-27 Thread Grigory Fateyev
Hello Grigory Fateyev! On Thu, 27 Oct 2005 19:43:45 +0400 you wrote: > > Hello! > > http://django.pastebin.com/407800 > > Somebody can explane why this app could not create object? Any advice > ... > Problem was fixed! -- Всего наилучшего! greg [at] anastasia [dot] ru Григорий.

create object

2005-10-27 Thread Grigory Fateyev
Hello! http://django.pastebin.com/407800 Somebody can explane why this app could not create object? Any advice ... -- Всего наилучшего! greg [at] anastasia [dot] ru Григорий.