Re: Django 1.8 data migrations not able to locate related collections
related models.py lines https://github.com/virtualcommons/vcweb/blob/10f44c3038f70a2e91f3a80704a4ab30c748f3e9/vcweb/core/models.py#L2060 https://github.com/virtualcommons/vcweb/blob/10f44c3038f70a2e91f3a80704a4ab30c748f3e9/vcweb/core/models.py#L2087 Hi A Lee, > > Can't say for sure but probably it is because your related_name is not > unique in core/migrations/0001_initial.py ( > https://github.com/virtualcommons/vcweb/blob/develop/vcweb/core/migrations/0001_initial.py#L647, > > > https://github.com/virtualcommons/vcweb/blob/develop/vcweb/core/migrations/0001_initial.py#L208 > ) > And based on django documentation the related_name must always be unique ( > https://docs.djangoproject.com/en/1.8/topics/db/models/#be-careful-with-related-name > ) > > It is just an assumption. > > Yours sincerely, > Pavel > > Hello, >> >> After upgrading to 1.8 from 1.7.7 our tests are now unable to create test >> data via data migrations and complain about related collections not >> existing as attributes for some but not all models (exception stack trace >> at https://travis-ci.org/virtualcommons/vcweb). It appears to succeed at >> creating a model object for the first related collection but then dies when >> attempting to create objects in the second related collection ( >> https://github.com/virtualcommons/vcweb/blob/develop/vcweb/experiment/forestry/migrations/0001_initial_forestry.py#L62 >> ). >> >> Any ideas on what might be causing this? Access to related collections >> through the django shell and via the web interface still seem to be working >> fine on 1.8, it's just the data migrations that are failing. >> >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fe8d989c-5673-4f9e-9c9f-86a68f44573e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django 1.8 data migrations not able to locate related collections
Hi A Lee, Can't say for sure but probably it is because your related_name is not unique in core/migrations/0001_initial.py (https://github.com/virtualcommons/vcweb/blob/develop/vcweb/core/migrations/0001_initial.py#L647, https://github.com/virtualcommons/vcweb/blob/develop/vcweb/core/migrations/0001_initial.py#L208) And based on django documentation the related_name must always be unique (https://docs.djangoproject.com/en/1.8/topics/db/models/#be-careful-with-related-name) It is just an assumption. Yours sincerely, Pavel Hello, > > After upgrading to 1.8 from 1.7.7 our tests are now unable to create test > data via data migrations and complain about related collections not > existing as attributes for some but not all models (exception stack trace > at https://travis-ci.org/virtualcommons/vcweb). It appears to succeed at > creating a model object for the first related collection but then dies when > attempting to create objects in the second related collection ( > https://github.com/virtualcommons/vcweb/blob/develop/vcweb/experiment/forestry/migrations/0001_initial_forestry.py#L62 > ). > > Any ideas on what might be causing this? Access to related collections > through the django shell and via the web interface still seem to be working > fine on 1.8, it's just the data migrations that are failing. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7be04264-e0cb-436a-af72-b11b89da0af0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Userena 'OrderedDict' object has no attribute 'keyOrder'
Yeah, sorry:) 2015-04-16 16:04 GMT+03:00 Vijay Khemlani <vkhem...@gmail.com>: > Why are you talking to me? I'm not OP xD > > On Thu, Apr 16, 2015 at 9:57 AM, Pavel Kuchin <pavel.s.kuc...@gmail.com> > wrote: >> >> Hi Vijay, >> >> Looks like Django does not use SortedDict anymore >> >> (https://github.com/django/django/commit/07876cf02b6db453ca0397c29c225668872fa96d#django/forms/forms.py) >> The self.fields.keyOrder does not work anymore, django-userena has an >> obsolete documentation. >> Try to remove def __init__(self, *args, **kw): from your class, >> ordering should be based on fields definition order. >> >> Best regards, >> Pavel >> >> 2015-04-16 15:31 GMT+03:00 Vijay Khemlani <vkhem...@gmail.com>: >> > In the title: "'OrderedDict' object has no attribute 'keyOrder'" >> > >> > On Thu, Apr 16, 2015 at 6:13 AM, Pavel Kuchin <pavel.s.kuc...@gmail.com> >> > wrote: >> >> >> >> Hi Willy, >> >> >> >> Can you send an error, because I see only the SignupFormExtra class. >> >> >> >> Yours sincerely, >> >> Pavel >> >> >> >> четверг, 16 апреля 2015 г., 1:41:47 UTC+3 пользователь willyhakim >> >> написал: >> >>> >> >>> Hi everyone, >> >>> I am using django-userena and extend the form class to add some of my >> >>> own >> >>> fields. I followed >> >>> the demo and still get the above error. Anyone know what I am doing >> >>> wrong? >> >>> >> >>> class SignupFormExtra(SignupForm): >> >>> """ >> >>> A form to demonstrate how to add extra fields to the signup form, >> >>> in >> >>> this >> >>> case adding the first and last name. >> >>> >> >>> """ >> >>> first_name = forms.CharField(label=_(u'First name'), >> >>> max_length=30, >> >>> required=True) >> >>> >> >>> last_name = forms.CharField(label=_(u'Last name'), >> >>> max_length=30, >> >>> required=False) >> >>> industry = forms.CharField(label=_(u'Industry'), >> >>> max_length=50, >> >>> required=False) >> >>> title = forms.CharField(label=_(u'title'), >> >>> max_length=50, >> >>> required=False) >> >>> >> >>> def __init__(self, *args, **kw): >> >>> """ >> >>> >> >>> A bit of hackery to get the first name and last name at the >> >>> top >> >>> of the >> >>> form instead at the end. >> >>> >> >>> """ >> >>> super(SignupFormExtra, self).__init__(*args, **kw) >> >>> # Put the first and last name at the top >> >>> new_order = self.fields.keyOrder[-2] >> >>> new_order.insert(0, 'first_name') >> >>> new_order.insert(1, 'last_name') >> >>> new_order.insert(2, 'industry') >> >>> new_order.insert(3, 'title') >> >>> self.fields.keyOrder = new_order >> >>> >> >>> def save(self): >> >>> """ >> >>> Override the save method to save the first and last name to >> >>> the >> >>> user >> >>> field. >> >>> """ >> >>> # First save the parent form and get the user. >> >>> new_user = super(SignupFormExtra, self).save() >> >>> >> >>> new_user.first_name = self.cleaned_data['first_name'] >> >>> new_user.last_name = self.cleaned_data['last_name'] >> >>> new_user.industry = self.cleaned_data['industry'] >> >>> new_user.title = self.cleaned_data['title'] >> >>> new_user.save() >> >>> >> >>> # Userena expects to get the new user from this form, so
Re: Django Userena 'OrderedDict' object has no attribute 'keyOrder'
Hi Vijay, Looks like Django does not use SortedDict anymore (https://github.com/django/django/commit/07876cf02b6db453ca0397c29c225668872fa96d#django/forms/forms.py) The self.fields.keyOrder does not work anymore, django-userena has an obsolete documentation. Try to remove def __init__(self, *args, **kw): from your class, ordering should be based on fields definition order. Best regards, Pavel 2015-04-16 15:31 GMT+03:00 Vijay Khemlani <vkhem...@gmail.com>: > In the title: "'OrderedDict' object has no attribute 'keyOrder'" > > On Thu, Apr 16, 2015 at 6:13 AM, Pavel Kuchin <pavel.s.kuc...@gmail.com> > wrote: >> >> Hi Willy, >> >> Can you send an error, because I see only the SignupFormExtra class. >> >> Yours sincerely, >> Pavel >> >> четверг, 16 апреля 2015 г., 1:41:47 UTC+3 пользователь willyhakim написал: >>> >>> Hi everyone, >>> I am using django-userena and extend the form class to add some of my own >>> fields. I followed >>> the demo and still get the above error. Anyone know what I am doing >>> wrong? >>> >>> class SignupFormExtra(SignupForm): >>> """ >>> A form to demonstrate how to add extra fields to the signup form, in >>> this >>> case adding the first and last name. >>> >>> """ >>> first_name = forms.CharField(label=_(u'First name'), >>> max_length=30, >>> required=True) >>> >>> last_name = forms.CharField(label=_(u'Last name'), >>> max_length=30, >>> required=False) >>> industry = forms.CharField(label=_(u'Industry'), >>> max_length=50, >>> required=False) >>> title = forms.CharField(label=_(u'title'), >>> max_length=50, >>> required=False) >>> >>> def __init__(self, *args, **kw): >>> """ >>> >>> A bit of hackery to get the first name and last name at the top >>> of the >>> form instead at the end. >>> >>> """ >>> super(SignupFormExtra, self).__init__(*args, **kw) >>> # Put the first and last name at the top >>> new_order = self.fields.keyOrder[-2] >>> new_order.insert(0, 'first_name') >>> new_order.insert(1, 'last_name') >>> new_order.insert(2, 'industry') >>> new_order.insert(3, 'title') >>> self.fields.keyOrder = new_order >>> >>> def save(self): >>> """ >>> Override the save method to save the first and last name to the >>> user >>> field. >>> """ >>> # First save the parent form and get the user. >>> new_user = super(SignupFormExtra, self).save() >>> >>> new_user.first_name = self.cleaned_data['first_name'] >>> new_user.last_name = self.cleaned_data['last_name'] >>> new_user.industry = self.cleaned_data['industry'] >>> new_user.title = self.cleaned_data['title'] >>> new_user.save() >>> >>> # Userena expects to get the new user from this form, so return >>> the new >>> # user. >>> return new_user >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/a4c2a9d4-b9f2-43bc-b7bc-537e9e17c88b%40googlegroups.com. >> >> For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/5HxEahhNuSo/unsubscribe. > To unsubscribe from this group and all its topics, send an email to >
Re: Django Userena 'OrderedDict' object has no attribute 'keyOrder'
Hi Willy, Can you send an error, because I see only the SignupFormExtra class. Yours sincerely, Pavel четверг, 16 апреля 2015 г., 1:41:47 UTC+3 пользователь willyhakim написал: > > Hi everyone, > I am using django-userena and extend the form class to add some of my own > fields. I followed > the demo and still get the above error. Anyone know what I am doing wrong? > > class SignupFormExtra(SignupForm): > """ > A form to demonstrate how to add extra fields to the signup form, in > this > case adding the first and last name. > > """ > first_name = forms.CharField(label=_(u'First name'), > max_length=30, > required=True) > > last_name = forms.CharField(label=_(u'Last name'), > max_length=30, > required=False) > industry = forms.CharField(label=_(u'Industry'), > max_length=50, > required=False) > title = forms.CharField(label=_(u'title'), > max_length=50, > required=False) > > def __init__(self, *args, **kw): > """ > > A bit of hackery to get the first name and last name at the top of > the > form instead at the end. > > """ > super(SignupFormExtra, self).__init__(*args, **kw) > # Put the first and last name at the top > new_order = self.fields.keyOrder[-2] > new_order.insert(0, 'first_name') > new_order.insert(1, 'last_name') > new_order.insert(2, 'industry') > new_order.insert(3, 'title') > self.fields.keyOrder = new_order > > def save(self): > """ > Override the save method to save the first and last name to the > user > field. > """ > # First save the parent form and get the user. > new_user = super(SignupFormExtra, self).save() > > new_user.first_name = self.cleaned_data['first_name'] > new_user.last_name = self.cleaned_data['last_name'] > new_user.industry = self.cleaned_data['industry'] > new_user.title = self.cleaned_data['title'] > new_user.save() > > # Userena expects to get the new user from this form, so return > the new > # user. > return new_user > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a4c2a9d4-b9f2-43bc-b7bc-537e9e17c88b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: saving data using cleaned data method
Hi Sekkizhar, I think django.forms.ModelForm is exactly what you are looking for. (https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#modelform) Yours sincerely, Pavel. Good Morning, > I am trying to save data in the table using cleaned data by get and post > method in the view. > How will I trace step by step the movement of data which is to be saved > in the database? > > My problem is there is know error while running the program. But i did not > see any data saved in the table in postgres. Where is the data? where can i > find the data? [ i Used IPDP() ] > > *View* > > def post(self,request,**kwargs): > if request.method == 'POST': > > > form=dms_school_gis_info_form(request.POST) > > if form.is_valid(): > form.process() > > cd = dms_school_gis_info( > tempid_id = form.cleaned_data['tempid'], > latitude=form.cleaned_data['latitude'], > longitude=form.cleaned_data['longitude'], > ) > cd.save() > > *Form* > > class dms_school_gis_info_form(forms.Form): > tempid = forms.CharField() > latitude=forms.CharField() > longitude=forms.CharField() > > def process(self): > cd = self.cleaned_data > > > > Please help me > > Sekkizhar > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/01955af7-a900-4f8d-863a-c82fe62316e0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django handle new ManyToManyField items with get_or_create()
Hi Filippo, You can check is form valid or not, then if valid save related model and then add M2M objects, like this: if form.is_valid(): model_instance = form.save() for tag in model_instance.tags.all(): t, created = Tag.objects.get_or_create(author=request.user, title=tag.title) model_instance.tags.add(t) return HttpResponseRedirect("/") Best regards, Pavel Help me, django-users, you're my only hope :D > > Hi all, my name is Filippo, I'm from Italy and I'm totally stuck on this > problem... > > I have a model with a ManyToManyField and in my view I want to be able to > add new options to the generated selectbox. > > How can I handle those new items with get_or_create function? > > I want to check for form validity before saving it, but it will never be > valid because I have to create all the new ManyToMany items. In the > meantime, I don't want to add new items if the form is not valid... > > So I'm stuck with this not-working-code: > > def add_entry(request): > if request.method == 'POST': > form = EntryForm(data=request.POST) > model_instance = form.save(commit=False) > for tag in model_instance.tags.all(): > t, created = Tag.objects.get_or_create(author=request.user, > title=tag.title) > model_instance.tags.add(t) > if form.is_valid(): > model_instance.save() > return HttpResponseRedirect("/") > else: > form = EntryForm() > return render_to_response( > 'add_entry.html', > {'form' : form }, > context_instance=RequestContext(request)) > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/29fcff84-a42d-4786-a35c-14cd209e10da%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django ProgrammingError: no relation exists when using ManyToManyfield
Hi Chase, Can you please attach your settings.py (or at least DATABASES and INSTALLED_APPS options) and LocationModel class? Best regards, Pavel 2015-04-13 17:37 GMT+03:00 Chase Cooley <chaselcoo...@gmail.com>: > Yes, I have tried makemigrations and migrate for all modules and it still > doesn't work. I have also tried makemigrations and migrate for individual > modules with no luck. > > On Sunday, April 12, 2015 at 10:12:08 AM UTC-5, Pavel Kuchin wrote: >> >> Hi Chase, >> >> Did you try makemigrations and migrate: >> $ python manage.py makemigrations >> $ python manage.py migrate >> You should run them for all modules at first time (do not set any specific >> module). >> >> Best regards, Pavel. >> >>> I can post code and errors here, but have already posted on >>> stackoverflow.com and so I figured it might be useful to see some of the >>> comments users on that site have suggested. If this is not acceptable let me >>> know and i'll post everything here. >>> Thanks! >>> >>> >>> http://stackoverflow.com/questions/29190190/django-programmingerror-no-relation-exists-when-using-manytomanyfield?noredirect=1#comment46603898_29190190 > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/MHngqha8fIk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/3d6bcc21-7176-4b45-8ae2-576872381521%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALyspwr9MeQ6KLOfEvmWo%2BF_L239a2ZokY3WoRpZXAy_Ct6QaQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Django ProgrammingError: no relation exists when using ManyToManyfield
Hi Chase, Did you try makemigrations and migrate: $ python manage.py makemigrations $ python manage.py migrate You should run them for all modules at first time (do not set any specific module). Best regards, Pavel. I can post code and errors here, but have already posted on > stackoverflow.com and so I figured it might be useful to see some of the > comments users on that site have suggested. If this is not acceptable let > me know and i'll post everything here. > Thanks! > > > http://stackoverflow.com/questions/29190190/django-programmingerror-no-relation-exists-when-using-manytomanyfield?noredirect=1#comment46603898_29190190 > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/97337198-b903-4541-9332-162452c3ce75%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: KeyError: 'default'
Hi Mike, I think the issue is that Django can't find your default DB settings. Please take a look: https://docs.djangoproject.com/en/1.8/ref/settings/#databases Best regards, Pavel понедельник, 6 апреля 2015 г., 15:44:01 UTC+3 пользователь Mike Dewhirst написал: > > Can someone please explain what KeyError: 'default' means? > > This is the first time I have tried Django 1.7 and without doing any > migrations all I have done here is this ... > > (xxex3) C:\Users\mike\env\xxex3\ssds>copy > substance\fixtures\test_data.json substance\fixtures\initial_data.json > > (xxex3) C:\Users\mike\env\xxex3\ssds>python manage.py test > --settings=ssds.settings.test --verbosity=1 common refer substance > company workplace credit > > Python: 3.4 > Django: 1.7.7 > 17:40:04 > SQLite3: memory > > Creating test database for alias 'default'... > Traceback (most recent call last): >File > "C:\Users\mike\env\xxex3\lib\site-packages\django\contrib\contenttypes\models.py", > > > line 19, in get_by_natural_key > ct = self.__class__._cache[self.db][(app_label, model)] > KeyError: 'default' > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): >File > "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\utils.py", > line 65, in execute > return self.cursor.execute(sql, params) >File > "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\sqlite3\base.py", > > > line 485, in execute > return Database.Cursor.execute(self, query, params) > sqlite3.OperationalError: no such table: django_content_type > > (there is more but the bottom line is ...) > > return Database.Cursor.execute(self, query, params) > django.core.serializers.base.DeserializationError: Problem installing > fixture 'C:\Users\ > mike\env\xxex3\ssds\substance\fixtures\initial_data.json': no such > table: django_content_type > > (xxex3) C:\Users\mike\env\xxex3\ssds> > > From my settings ... > > SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' > > #CACHES = { > #'default': { > #'BACKEND': 'django.core.cache.backends.dummy.DummyCache', > #} > #} > > The same error occurs whether CACHES is commented out or not. > > Not sure where to look in the documentation. > https://docs.djangoproject.com/en/1.7/topics/http/sessions/ got me > thinking (out of my depth) about sessions and serialization. > > It seems Django 1.7 (or maybe 1.8) removes the 'name' column from > content_types upon migration and the migrated tables crash Django 1.6 > (naturally I suppose). That means I'm stuck on 1.6 until I can get > things going on 1.7 and/or 1.8. > > Is it possible to run with 1.7 without migrating the Django apps? > > Any help will be much appreciated > > Thanks > > Mike > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/240490f9-eaa3-4b54-ba93-237218357a87%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.