Re: Django models
hi michael, Thanks for the tip. It is a huge step in my progress. However what does this error say? ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. Best Regards, Stanwin Siow On Jan 30, 2012, at 8:37 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 04:13:50AM -0800, St@n wrote: >> How do i ask django to query for a table that is already created in >> the database but not part of the models.py? >> >> the models.py is used to described the database and to create tables >> with that models.py. However i already have my tables created prior to >> creating the django app. >> >> How then do i get django to query those tables created before? > > You can use "django-admin.py inspectdb" to generate a models.py based on an > existing database: > > https://docs.djangoproject.com/en/1.3/ref/django-admin/#inspectdb > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django models
Thank you so much. This information is very useful. It work like a charm for me. Thank you once again mike. Cheers Best Regards, Stanwin Siow On Jan 30, 2012, at 9:35 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 09:26:10PM +0800, Stanwin Siow wrote: >> However what does this error say? >> >> ImportError: Settings cannot be imported, because environment variable >> DJANGO_SETTINGS_MODULE is undefined. > > If you have a manage.py for your project, you can just run "manage.py > inspectdb" and it will use the DATABASES defined in your settings.py. > > manage.py is just a wrapper around django-admin.py that sets the > DJANGO_SETTINGS_MODULE and PYTHONPATH for you. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django models
sorry to bother you again michael but once my terminal creates the model classes do i have to copy it into my app's model.py? I wanted to be sure. Best Regards, Stanwin Siow On Jan 30, 2012, at 9:35 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 09:26:10PM +0800, Stanwin Siow wrote: >> However what does this error say? >> >> ImportError: Settings cannot be imported, because environment variable >> DJANGO_SETTINGS_MODULE is undefined. > > If you have a manage.py for your project, you can just run "manage.py > inspectdb" and it will use the DATABASES defined in your settings.py. > > manage.py is just a wrapper around django-admin.py that sets the > DJANGO_SETTINGS_MODULE and PYTHONPATH for you. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django models
ok got it. I read the document and it was good stuff. Just got confused with copying pasting into my models.py. Thanks alot once again. :) Best Regards, Stanwin Siow On Jan 30, 2012, at 10:02 PM, Michael Elkins wrote: > On Mon, Jan 30, 2012 at 09:53:18PM +0800, Stanwin Siow wrote: >> but once my terminal creates the model classes do i have to copy it into my >> app's model.py? > > yes, you will need to copy the output to your models.py. you may need to > edit it to put the models in order so that dependencies like foreign keys in > the model definitions are satisified. see the link i posted earlier about > inspectdb for details on what you may need to edit. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Creating a hierarchy of objects in my api.py
Hello, Any luck on this yet? Best Regards, Stanwin Siow On Jan 31, 2012, at 11:39 AM, St@n wrote: > Hello, > > I am playing around with tastypie and i want to create a hierarchy of > data. > > What i currently have is this: > > > class keywordResource(ModelResource): >tweets = fields.ToManyField(timelineResource, 'tweets', full=True) >class Meta: >queryset = Keyword.objects.all() >resource_name = 'keyword' >excludes = ['id', 'keyword_id'] >include_resource_uri = False > >def alter_list_data_to_serialize(self, request, data_dict): >if isinstance(data_dict, dict): >if 'meta' in data_dict: ># Get rid of the "meta". >del(data_dict['meta']) ># Rename the objects. >data_dict['keyword'] = copy.copy(data_dict['objects']) >del(data_dict['objects']) >return data_dict > > > > Can someone explain the relationship to me in creating such a > hierarchy? > > in the line tweets = fields.ToManyField(timelineResource, 'tweets', > full=True) > > it means that timelineResource is a child of Keyword right? and > "tweets" would be the column name in timeline table or just a generic > name? > > or must i map a matching column that appears in both tables (keyword, > timeline)? > > > Thank you > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: regarding an error in settings.py
Hi You need to install the package psycopg2. Google and install the package. It should work Best Regards, Stanwin Siow On Feb 9, 2012, at 10:10 PM, kalyani ram wrote: > Hey all, > Tday is my first day with django and i tried configuring postgresql as > a backend and got an error like this: > > > raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) > django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 > module: No module named psycopg2 > > Please help me. Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: regarding an error in settings.py
can you show the actual error output? Best Regards, Stanwin Siow On Feb 10, 2012, at 4:58 PM, kalyani ram wrote: > Thank you very much. I managed to come out of this error and ended up > with a new one. > I get an error saying that the Name field is wrong. If i have not > mistaken, should the name filed be the table name ? or is it something > new? > thanks in advance. > > > On Feb 9, 7:30 pm, Stanwin Siow wrote: >> Hi >> >> You need to install the package psycopg2. Google and install the package. >> >> It should work >> >> Best Regards, >> >> Stanwin Siow >> >> On Feb 9, 2012, at 10:10 PM, kalyani ram wrote: >> >> >> >> >> >> >> >>> Hey all, >>> Tday is my first day with django and i tried configuring postgresql as >>> a backend and got an error like this: >> >>> raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) >>> django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 >>> module: No module named psycopg2 >> >>> Please help me. Thanks in advance. >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group >>> athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sqlite3 database error
Try this: >> DATABASES = { >> 'default': { >> 'ENGINE': 'django.db.backends.sqlite3', # Add >> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. >> 'NAME': 'test.db', # Or path to database >> file if using sqlite3. >> 'USER': '', # Not used with sqlite3. >> 'PASSWORD': '', # Not used with sqlite3. >> 'HOST': '', # Set to empty string for >> localhost. Not used with sqlite3. >> 'PORT': '', # Set to empty string for >> default. Not used with sqlite3. >> } > Best Regards, Stanwin Siow On Feb 13, 2012, at 9:03 PM, ajohnston wrote: > Try changing the slashes form \ to / > > On Feb 13, 4:50 am, Marcus Maximus wrote: >> Hey guys, >> >> i am using sqlite3 for my django app. BUT I have problems installing >> it. Here are my configs: >> >> DATABASES = { >> 'default': { >> 'ENGINE': 'django.db.backends.sqlite3', # Add >> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. >> 'NAME': 'C:\Users\Maximus\Desktop\Webseite\Django\sqlite-shell- >> win32-x86-3071000\test.db', # Or path to database >> file if using sqlite3. >> 'USER': '', # Not used with sqlite3. >> 'PASSWORD': '', # Not used with sqlite3. >> 'HOST': '', # Set to empty string for >> localhost. Not used with sqlite3. >> 'PORT': '', # Set to empty string for >> default. Not used with sqlite3. >> } >> >> } >> >> I tried this: >> >>>>> from django.db import connection >>>>> cursor = connection.cursor() >> >> But I got this error: >> >> Traceback (most recent call last): >> File "", line 1, in >> File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", >> line 250, >> in cursor >> cursor = self.make_debug_cursor(self._cursor()) >> File "C:\Python27\lib\site-packages\django\db\backends >> \sqlite3\base.py", line >> 207, in _cursor >> self.connection = Database.connect(**kwargs) >> OperationalError: unable to open database file >> >> Can sb pls help me? >> >> greetings >> >> Maximus >> >> PS.: I created my sqlite3 file like that: >> >>>sqlite3 test.db >> ...> >> ...> >> ...>); >> ...>Syntax error >>> >> >> Can sb show me a better way to create an empty sqlite3 db file? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Admin error
Hi there, i'm getting this error when trying to get the default admin page up. invalid syntax (admin.py, line 1) Any ideas where to rectify this? Thanks in advance Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin error
it's supposed to be django's admin page. I don't have an admin.py in my project folders Best Regards, Stanwin Siow On Feb 15, 2012, at 1:46 PM, Mike Dewhirst wrote: > On 15/02/2012 4:39pm, Stanwin Siow wrote: >> Hi there, >> >> i'm getting this error when trying to get the default admin page up. >> >> invalid syntax (admin.py, line 1) > > Could you post the contents of the offending file (admin.py) here? > >> >> >> Any ideas where to rectify this? >> >> Thanks in advance >> >> >> >> Best Regards, >> >> Stanwin Siow >> >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin error
Yes i have gone through the tutorial. And i've gotten my website up and running. But when i want to enable admin it gives me that error. Here is my urls.py: from django.conf.urls.defaults import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'r2.views.home', name='home'), # url(r'^r2/', include('r2.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/', include('django.contrib.admin.urls')), and INSTALLED APPS settings: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: 'django.contrib.admindocs', 'registration', 'r2.topic', 'r2.opinion', 'r2', 'r2.statistics', 'paypal.standard.ipn', ) besides the tutorial basically just says to uncomment the lines and we should access the page through localserver/admin Thanks for looking into this Best Regards, Stanwin Siow On Feb 15, 2012, at 2:08 PM, Mike Dewhirst wrote: > On 15/02/2012 4:59pm, Stanwin Siow wrote: >> it's supposed to be django's admin page. > > Not quite. Can you give me an overview of what you have done with Django so > far? For example, have you gone through the tutorial? > >> >> I don't have an admin.py in my project folders >> >> >> Best Regards, >> >> Stanwin Siow >> >> >> >> On Feb 15, 2012, at 1:46 PM, Mike Dewhirst wrote: >> >>> On 15/02/2012 4:39pm, Stanwin Siow wrote: >>>> Hi there, >>>> >>>> i'm getting this error when trying to get the default admin page up. >>>> >>>> invalid syntax (admin.py, line 1) >>> >>> Could you post the contents of the offending file (admin.py) here? >>> >>>> >>>> >>>> Any ideas where to rectify this? >>>> >>>> Thanks in advance >>>> >>>> >>>> >>>> Best Regards, >>>> >>>> Stanwin Siow >>>> >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django users" group. >>>> To post to this group, send email to django-users@googlegroups.com >>>> <mailto:django-users@googlegroups.com>. >>>> To unsubscribe from this group, send email to >>>> django-users+unsubscr...@googlegroups.com >>>> <mailto:django-users+unsubscr...@googlegroups.com>. >>>> For more options, visit this group at >>>> http://groups.google.com/group/django-users?hl=en. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com >>> <mailto:django-users@googlegroups.com>. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com >>> <mailto:django-users+unsubscr...@googlegroups.com>. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin error
it is to no avail think that's only for modifying the admin. Best Regards, Stanwin Siow On Feb 15, 2012, at 2:41 PM, Mike Dewhirst wrote: > On 15/02/2012 5:10pm, Stanwin Siow wrote: >> Yes i have gone through the tutorial. >> >> And i've gotten my website up and running. >> >> But when i want to enable admin it gives me that error. > > Try creating a file called admin.py in the same directory as models.py and > put this in it ... > > - - - - - - - > from polls.models import Poll > from django.contrib import admin > > admin.site.register(Poll) > - - - - - - - > > https://docs.djangoproject.com/en/dev/intro/tutorial02/#make-the-poll-app-modifiable-in-the-admin > > > >> >> Here is my urls.py: >> >> from django.conf.urls.defaults import patterns, include, url >> >> # Uncomment the next two lines to enable the admin: >> from django.contrib import admin >> admin.autodiscover() >> >> urlpatterns = patterns('', >> # Examples: >> # url(r'^$', 'r2.views.home', name='home'), >> # url(r'^r2/', include('r2.foo.urls')), >> # Uncomment the admin/doc line below to enable admin documentation: >> url(r'^admin/doc/', include('django.contrib.admindocs.urls')), >> >> # Uncomment the next line to enable the admin: >> (r'^admin/', include('django.contrib.admin.urls')), >> >> >> >> and INSTALLED APPS settings: >> >> INSTALLED_APPS = ( >> 'django.contrib.auth', >> 'django.contrib.contenttypes', >> 'django.contrib.sessions', >> 'django.contrib.sites', >> 'django.contrib.messages', >> 'django.contrib.staticfiles', >> *# Uncomment the next line to enable the admin:* >> *'django.contrib.admin',* >> *# Uncomment the next line to enable admin documentation:* >> *'django.contrib.admindocs',* >> 'registration', >> 'r2.topic', >> 'r2.opinion', >> 'r2', >> 'r2.statistics', >> 'paypal.standard.ipn', >> ) >> >> besides the tutorial basically just says to uncomment the lines and we >> should access the page through localserver/admin >> >> Thanks for looking into this >> >> >> >> >> >> >> Best Regards, >> >> Stanwin Siow >> >> >> >> On Feb 15, 2012, at 2:08 PM, Mike Dewhirst wrote: >> >>> On 15/02/2012 4:59pm, Stanwin Siow wrote: >>>> it's supposed to be django's admin page. >>> >>> Not quite. Can you give me an overview of what you have done with >>> Django so far? For example, have you gone through the tutorial? >>> >>>> >>>> I don't have an admin.py in my project folders >>>> >>>> >>>> Best Regards, >>>> >>>> Stanwin Siow >>>> >>>> >>>> >>>> On Feb 15, 2012, at 1:46 PM, Mike Dewhirst wrote: >>>> >>>>> On 15/02/2012 4:39pm, Stanwin Siow wrote: >>>>>> Hi there, >>>>>> >>>>>> i'm getting this error when trying to get the default admin page up. >>>>>> >>>>>> invalid syntax (admin.py, line 1) >>>>> >>>>> Could you post the contents of the offending file (admin.py) here? >>>>> >>>>>> >>>>>> >>>>>> Any ideas where to rectify this? >>>>>> >>>>>> Thanks in advance >>>>>> >>>>>> >>>>>> >>>>>> Best Regards, >>>>>> >>>>>> Stanwin Siow >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Django users" group. >>>>>> To post to this group, send email to django-users@googlegroups.com >>>>>> <mailto:django-users@googlegroups.com> >>>>>> <mailto:django-users@googlegroups.com>. >>>>>> To unsubscribe from this group, send email to >>>>>> django-users+unsubscr...@googlegroups.com >>>>>> <mailto:django-users+unsubscr...@googlegroups.com> >>>>&
Re: Admin error
ok i figured where that error was coming from. It was from the method: admin.autodiscover() What does this method do? Best Regards, Stanwin Siow On Feb 15, 2012, at 3:12 PM, Mike Dewhirst wrote: > On 15/02/2012 5:41pm, Mike Dewhirst wrote: >>> >>> invalid syntax (admin.py, line 1) > > Your original error indicated there is an admin.py but with an error on line > 1 or a missing admin.py which you have confirmed. > > That is the problem. > > To get your models to appear in the admin app you need an admin.py in each > app directory. That is, each app listed in INSTALLED_APPS which also has a > models.py. > > Inside each admin.py you need to import the models you want to see in the > admin and then do admin.site.register > > If you are not even getting to the admin login prompt there is something else > wrong. Even so I think it will be related to admin.py somewhere. > > Mike > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin error
I did. When admin.autodiscover() was uncommented out, It gives the syntax error when my admin.py was only as such: from r2.models import Keyword from django.contrib import admin admin.site.register(Keyword) Best Regards, Stanwin Siow On Feb 15, 2012, at 5:20 PM, Ervin Hegedüs wrote: > hello, > > On Wed, Feb 15, 2012 at 04:48:18PM +0800, Stanwin Siow wrote: >> ok i figured where that error was coming from. >> >> It was from the method: admin.autodiscover() >> >> What does this method do? > > in Django doc: > > https://docs.djangoproject.com/en/dev/ref/contrib/admin/ > > "Above we used admin.autodiscover() to automatically load the > INSTALLED_APPS admin.py modules." > > Did you import the required modules? > > > > a. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Help on forms.py
Hello, I'm trying to modify the default registration forms.py by adding in more fields. Currently it's like that: = keyword_info = { "queryset" : Keyword.objects.all(), } class RegistrationForm(forms.Form): username = forms.RegexField(regex=r'^\w+$', max_length=30, widget=forms.TextInput(attrs=attrs_dict), label=_(u'username')) email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=75)), label=_(u'email address')) password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False), label=_(u'password')) password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False), label=_(u'password (again)')) keywords = forms.ChoiceField(choices=keyword_info) label=_(u'keyword')) = The thing is i would like keywords to be a drop down menu of keywords which are derived from the keyword database table. Can someone check if what i'm doing is correct? Thank you! Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Help on forms.py
Awesome! Thank you and have a great Weekend! :D Best Regards, Stanwin Siow On Feb 17, 2012, at 1:50 AM, Alasdair Nicol wrote: > Hi Stanwin, > > On 16/02/12 17:43, Stanwin Siow wrote: >> Hello, >> >> I'm trying to modify the default registration forms.py by adding in more >> fields. >> >> Currently it's like that: >> >> = >> keyword_info = { >> "queryset" : Keyword.objects.all(), >> } >> >> class RegistrationForm(forms.Form): >> >> keywords = forms.ChoiceField(choices=keyword_info) >> label=_(u'keyword')) >> > You're using a ChoiceField, which requires a list of 2-tuples, for example: > >choices = [('keyword1', 'keyword1'), ('keyword1', 'keyword1')] > > What you probably want is a ModelChoiceField [1], which takes a queryset > argument. > > keywords = forms.ModelChoiceField(queryset=Keyword.objects.all()) > > [1]: https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield > > cheers, > > Alasdair > -- > Alasdair Nicol > Developer, MEMSET > > mail: alasd...@memset.com > web: http://www.memset.com/ > > Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, > Guildford, Surrey, GU2 7YD, UK. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
passing multiple query sets into a url pattern
Hello, I want to find out if there is anyway to pass two querysets into a url pattern. i have this url pattern at the moment. UserProfile_info = { "queryset" : UserProfile.objects.all(), "extra_context" : {"keyword_list" : Keyword.objects.all} } url(r'^profile/$', list_detail.object_list, UserProfile_info), I understand from http://www.djangobook.com/en/1.0/chapter09/ that the extra_context field is to defind another query set. in my Userprofile.html i have the following code: {% for userprofile in object_list %} {% if userprofile.username = user.username %} that will give me the list of items in userprofile table in the database. Is there a way to include the list of items from the keyword table as well? Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
registration forms.py
Hello, The below method is an excerpt taken from the default registration forms.py with a few additional inputs. class RegistrationForm(forms.Form): keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all()) def save(self, profile_callback=None): new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],password=self.cleaned_data['password1'],email=self.cleaned_data['email'],profile_callback=profile_callback) new_profile = UserProfile(user=new_user,username=self.cleaned_data['username'], keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name'],email=self.cleaned_data['email']) new_profile.save() return new_user The highlighted portions will draw your attention to what i'm doing. As you can see i'm using a modelmultiplechoicefield which allows me to select multiple choices. However when it gets stored into the database, it appends strange characters ( [http://groups.google.com/group/django-users?hl=en. <>
Re: passing multiple query sets into a url pattern
Cheers bill! Figured it out already. However i'm stuck on the database problem which i wrote in a separate email. Stan Best Regards, Stanwin Siow On Feb 19, 2012, at 9:34 PM, Bill Freeman wrote: > Yes, you can, as part of the extra context, by whatever name doesn't > collide. Then you > could use it in your template, in a "for" tag. > > You could also pass another one, by a name other than "queryset" at > the same level as > the first one, but that becomes an argument to the view, so don't > expect it to work with > the generic views, since they don't expect such an argument. If you > are writing your > own view function (or class), you could arrange to accept such an > argument. If the > view is only used with that one url pattern, however, why not just > specify the queryset > there? > > Bill > > On Sun, Feb 19, 2012 at 4:07 AM, Alfredo Alessandrini > wrote: >> Hi Stanwn, >> >> try this: >> >> def get_keyword(): >>return Keyword.objects.all() >> >> UserProfile_info = { >> "queryset" : UserProfile.objects.all(), >> "extra_context" : {"keyword_list" : get_keyword } >> } >> >> >> Now you can use the variable {{ keyword_list }} to populate the template. >> >> >> >> Alfredo >> >> >> 2012/2/19 Stanwin Siow >>> >>> Hi Alfredo, >>> >>> My apologies for not making my question clear. >>> >>> I want to pass two different querysets into the url pattern. Is it >>> possible? >>> >>> Best Regards, >>> >>> Stanwin Siow >>> >>> >>> >>> On Feb 19, 2012, at 2:01 AM, Alfredo Alessandrini wrote: >>> >>> Hi, >>> >>> I'm not sure that I've understand your question: >>> >>> url(r'^profile/(?P\d+)/(?P\d+)$', ..) >>> >>> and now you can use the variable var_1 and var_2 in your function. >>> >>> >>> Alfredo >>> >>> >>> >>> 2012/2/18 Stanwin Siow >>>> >>>> Hello, >>>> >>>> I want to find out if there is anyway to pass two querysets into a url >>>> pattern. >>>> >>>> i have this url pattern at the moment. >>>> >>>> UserProfile_info = { >>>> "queryset" : UserProfile.objects.all(), >>>> "extra_context" : {"keyword_list" : Keyword.objects.all} >>>> } >>>> >>>> url(r'^profile/$', list_detail.object_list, UserProfile_info), >>>> >>>> >>>> I understand from http://www.djangobook.com/en/1.0/chapter09/ that the >>>> extra_context field is to defind another query set. >>>> >>>> in my Userprofile.html i have the following code: >>>> >>>> {% for userprofile in object_list %} >>>>{% if userprofile.username = user.username %} >>>> >>>> that will give me the list of items in userprofile table in the database. >>>> >>>> Is there a way to include the list of items from the keyword table as >>>> well? >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> Best Regards, >>>> >>>> Stanwin Siow >>>> >>>> >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Django users" group. >>>> To post to this group, send email to django-users@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> django-users+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/django-users?hl=en. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: dropdown select box in django
Try removing "Event Type", in the following message = models.CharField("Event Type", max_length=12, choices=EVENT_TYPE_CHOICES) Best Regards, Stanwin Siow On Feb 21, 2012, at 8:32 AM, larry.mart...@gmail.com wrote: > ield("Event Type", max_length=12, > choices=EVENT_TYPE_CHOICES) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: registration forms.py
Thanks akaarial and bill, Much appreciated for the help on getting me to understand more about django. :) Best Regards, Stanwin Siow On Feb 20, 2012, at 5:11 AM, akaariai wrote: > On Feb 19, 1:42 pm, Stanwin Siow wrote: >> Hello, >> >> The below method is an excerpt taken from the default registration forms.py >> with a few additional inputs. >> >> class RegistrationForm(forms.Form): >> >> keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all()) >> >> def save(self, profile_callback=None): >> >> new_user = >> RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],password=self.cleaned_data['password1'],email=self.cleaned_data['email'],profile_callback=profile_callback) >> new_profile = >> UserProfile(user=new_user,username=self.cleaned_data['username'], >> keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name'],email=self.cleaned_data['email']) >> new_profile.save() >> return new_user >> >> The highlighted portions will draw your attention to what i'm doing. As you >> can see i'm using a modelmultiplechoicefield which allows me to select >> multiple choices. >> >> However when it gets stored into the database, it appends strange characters >> ( [> >> Is there a way to get rid of the special characters? or how is it even >> appearing or getting populated? > > If keywords_subscribed is a character field (as it seems), you should > store something like [keyword.text for keyword in > self.cleaned_data['keywords']] in the field, not the model list > directly. Another option is to store the keywords in a > ManyToManyField. In any case, the problem seems to be the mismatch of > saving models instances into a field that doesn't expect model > instances. > > - Anssi > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Beginner's question about urls.py
check your settings.py file to ensure that you have the admin line uncommented in installed apps. Best Regards, Stanwin Siow On Feb 23, 2012, at 10:58 AM, shartha wrote: > Hello, > > I am trying to deploy a simple django site. The host I have chosen > installed django for me. But the problem is they have modified the > files a little bit and it sometimes gets confusing for a novice person > like me. Here is my question: > > This is the urls.py on the server: > === > from django.conf.urls.defaults import patterns, include, url > > from django.shortcuts import render_to_response > from django.contrib import admin > > admin.autodiscover() > > def index(request): >return render_to_response('index.html', {}) > > urlpatterns = patterns('', >url(r'^$', 'hello.urls.index'), >url(r'^admin/', include(admin.site.urls)), > ) > > > Now I have done the django tutorial part 1 and part 2 up to the point > where it asks you to uncomment 3 lines inthe urls.py. The lines that > are extra in the above files are the ones that were in it by default. > The problem I have is when I try to go to /domain/admin I get the > following error: > > Page not found (404) > Request Method: GET > Request URL: http://chekonam.info/admin > Using the URLconf defined in hello.urls, Django tried these URL > patterns, in this order: > ^$ > The current URL, admin, didn't match any of these. > > > The django instance is installed in the hello folder. Could someone > please tell me what's going on here? I could do all other steps in the > tutorial without problem. But this one perplexes me! > > Thank you! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Beginner's question about urls.py
Check your urls.py there could be conflicting statements: http://stackoverflow.com/questions/4174610/django-admin-page-not-found-at-admin Check out the stackoverflow question Best Regards, Stanwin Siow On Feb 23, 2012, at 11:20 AM, shartha wrote: > I have "django.contrib.admin" added to my INSTALLED_APP and database > is also sync'ed! > > On Feb 22, 9:04 pm, Stanwin Siow wrote: >> check your settings.py file to ensure that you have the admin line >> uncommented in installed apps. >> >> Best Regards, >> >> Stanwin Siow >> >> On Feb 23, 2012, at 10:58 AM, shartha wrote: >> >> >> >> >> >> >> >>> Hello, >> >>> I am trying to deploy a simple django site. The host I have chosen >>> installed django for me. But the problem is they have modified the >>> files a little bit and it sometimes gets confusing for a novice person >>> like me. Here is my question: >> >>> This is the urls.py on the server: >>> === >>> from django.conf.urls.defaults import patterns, include, url >> >>> from django.shortcuts import render_to_response >>> from django.contrib import admin >> >>> admin.autodiscover() >> >>> def index(request): >>>return render_to_response('index.html', {}) >> >>> urlpatterns = patterns('', >>>url(r'^$', 'hello.urls.index'), >>>url(r'^admin/', include(admin.site.urls)), >>> ) >>> >> >>> Now I have done the django tutorial part 1 and part 2 up to the point >>> where it asks you to uncomment 3 lines inthe urls.py. The lines that >>> are extra in the above files are the ones that were in it by default. >>> The problem I have is when I try to go to /domain/admin I get the >>> following error: >> >>> Page not found (404) >>> Request Method:GET >>> Request URL: http://chekonam.info/admin >>> Using the URLconf defined in hello.urls, Django tried these URL >>> patterns, in this order: >>> ^$ >>> The current URL, admin, didn't match any of these. >> >>> The django instance is installed in the hello folder. Could someone >>> please tell me what's going on here? I could do all other steps in the >>> tutorial without problem. But this one perplexes me! >> >>> Thank you! >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group >>> athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Using query set in views.py
Hello, I was wondering if we are able to use querysets in views.py so i can use one of the columns in my method below: def keyword_subscribe(request): keyword= '' if request.method == 'POST': subscription_days = "7" new_keyword = request.POST.get('myTextField') new_keyword_subscribed = subscribe_keyword(username,subDay =7,KEYWORD_SET=frozenset()) response = simplejson.dumps({'new_keyword': new_keyword_subscribed}) else: html = form.errors.as_ul() response = simplejson.dumps({'success':'False', 'html':html}) if request.is_ajax(): return HttpResponse(response, mimetype='application/json') else: return HttpResponseRedirect("/") Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using query set in views.py
Sorry if i have misled anyone. Here's a better view on what i'm asking. def get_keyword(): return Keyword.objects.all() That method above returns me a list of Keyword items correct? How then do i get a specific item from that list? Keyword is a table in my database but i need a specific column's information in my views.py. Hope that makes it clearer. Best Regards, Stanwin Siow On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote: > Your question is not at all clear. You can use whatever you like in your > view. What problem are you having? > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using query set in views.py
Ok disregard my previous question. Here's the latest one. I have the following form in my HTML: Keyword: when the user presses the submit button, it will go to the method keyword_subscribe in views.py The method is as shown: def keyword_subscribe(request): if request.POST: username = UserProfile.objects.all() #userid = username.objects.all() subscription_days = "7" new_keyword = request.POST.get('myTextField') print new_keyword new_keyword_subscribed = subscribe_keyword(username,subscription_days,new_keyword) response = simplejson.dumps({'new_keyword': new_keyword_subscribed}) print new_keyword_subscribed else: # html = form.errors.as_ul() response = simplejson.dumps({'success':'False'}) return HttpResponseRedirect("/accounts/login/") #if request.is_ajax(): # return HttpResponse(response, mimetype='application/json') #else: # return HttpResponseRedirect("/") Once in this method, i'm supposed to extract the word which the user entered in the textfield and store it in a variable called new_keyword However, i've been getting NONE which means there's something wrong somewhere and i do hope someone can help me. In addition, i would like to get the username which is stored in the UserProfile table in my database to be passed as a parameter to the next function too. How then do i implement the queryset needed? This should be clearer. Thank you. Best Regards, Stanwin Siow On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote: > Your question is not at all clear. You can use whatever you like in your > view. What problem are you having? > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Question on unknown error
Hello, I have the following method: def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()): try: ... sub_datetime = datetime.datetime.now() exp_datetime = sub_datetime + timedelta(days=subDay) print 'time' However when i try to run my app, The following error throws at those two lines. Err: sequence item 0: expected string, int found Is there something wrong with the module? Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Question on unknown error
It's ok guys! I figured out the error. At the end of the method we were returning 0 and 1 that will throw the error. Is there some rule in django that we are not supposed to return integers? Best Regards, Stanwin Siow On Feb 27, 2012, at 5:38 AM, Mario Gudelj wrote: > In print 'time' what's time? Should you not have print exp_datetime? > > On 27 February 2012 01:27, Stanwin Siow wrote: > Hello, > > I have the following method: > > def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()): > try: > ... > > sub_datetime = datetime.datetime.now() > exp_datetime = sub_datetime + timedelta(days=subDay) > print 'time' > > However when i try to run my app, > > The following error throws at those two lines. > > Err: sequence item 0: expected string, int found > Is there something wrong with the module? > > > > > > Best Regards, > > Stanwin Siow > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using query set in views.py
i see. Thanks guys. I've got it working thanks to your inputs. Really appreciate it. Best Regards, Stanwin Siow On Feb 27, 2012, at 4:36 PM, doniyor wrote: > yes, as Ian said, you need name attr in your input so that you can > navigate to the real string input the user gives.. > > > > On 27 Feb., 08:38, Ian Clelland wrote: >> On Sunday, February 26, 2012, Stanwin Siow wrote: >>> Ok disregard my previous question. >> >>> Here's the latest one. >> >>> I have the following form in my HTML: >>> * * >>> * Keyword: * >>> * * >> >> Your immediate problem here is that your element has an id, but no >> name attribute. That is why you are getting None when you try to retrieve >> it from the POST dictionary -- the browser never sent it to the server. >> >> I'm certain that you have additional issues with your view function, but >> this is the reason for the error that you are seeing right now. >> >> Ian >> >> >> >> >> >> >> >> >> >>> * * >>> * * >>> * * >> >>> when the user presses the submit button, it will go to the method >>> keyword_subscribe in views.py >> >>> The method is as shown: >> >>> *def keyword_subscribe(request):* >>> *if request.POST:* >>> * username = UserProfile.objects.all()* >>> * #userid = username.objects.all()* >>> *subscription_days = "7"* >>> * new_keyword = request.POST.get('myTextField')* >>> * print new_keyword* >>> *new_keyword_subscribed = >>> subscribe_keyword(username,subscription_days,new_keyword)* >>> ** >>> *response = simplejson.dumps({'new_keyword': >>> new_keyword_subscribed}) * >>> * print new_keyword_subscribed * >>> *else:* >>> * # html = form.errors.as_ul()* >>> *response = simplejson.dumps({'success':'False'})* >>> * return HttpResponseRedirect("/accounts/login/")* >>> *#if request.is_ajax():* >>> * # return HttpResponse(response, mimetype='application/json')* >>> *#else:* >>> * # return HttpResponseRedirect("/")* >> >>> Once in this method, i'm supposed to extract the word which the user >>> entered in the textfield and store it in a variable called new_keyword >> >>> However, i've been getting NONE which means there's something wrong >>> somewhere and i do hope someone can help me. >> >>> In addition, i would like to get the username which is stored in the >>> UserProfile table in my database to be passed as a parameter to the next >>> function too. >> >>> How then do i implement the queryset needed? >> >>> This should be clearer. >> >>> Thank you. >> >>> Best Regards, >> >>> Stanwin Siow >> >>> On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote: >> >>> Your question is not at all clear. You can use whatever you like in your >>> view. What problem are you having? >>> -- >>> DR. >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ. >>> To post to this group, send email to >>> django-users@googlegroups.com>> 'django-users@googlegroups.com');> >>> . >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com >> 'django-users+unsubscr...@googlegroups.com');>. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to >>> django-users@googlegroups.com>> 'django-users@googlegroups.com');> >>> . >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com >> 'django-users%2bunsubscr...@googlegroups.com');>. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >> >> -- >> Regards, >> Ian Clelland >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Jquery/ajax + django
Hello, I've gotten this json object back from django. I was wondering how do we use ajax/jquery to retrieve just the words that are highlighted? I'm stumped. {"new_list":{"blue": {"sub_datetime": "2012-02-29 22:14:44", "exp_datetime": "2012-03-07 22:14:44", "keyword": "blue"}, "teleport": {"sub_datetime": "2012-02-29 22:09:26", "exp_datetime": "2012-03-07 22:09:26", "keyword": "teleport"}, "blink182": {"sub_datetime": "2012-02-29 22:12:40", "exp_datetime": "2012-03-07 22:12:40", "keyword": "blink182"}, "a1": {"sub_datetime": "2012-02-29 22:13:31", "exp_datetime": "2012-03-07 22:13:31", "keyword": "a1"}, "jolie": {"sub_datetime": "2012-02-29 22:08:46", "exp_datetime": "2012-03-07 22:08:46", "keyword": "jolie"}, "santa claus": {"sub_datetime": "2012-02-29 22:14:13", "exp_datetime": "2012-03-07 22:14:13", "keyword": "santa claus"}}} Here are the methods i've tried: function updateKeywords(e) { e.preventDefault(); var keyword_form = jQuery(e.target); alert("Yay Jquery is working!!!"); $.ajax({ url : keyword_form.attr('action'), type : keyword_form.attr('method'), data : keyword_form.serialize(), dataType : 'json', success : function(response) {alert("JSON Data: " + response.new_list.keyword); }, }); } }); Unfortunately, when i put the above, it returns an undefined json data. When i just put response.new_list, it returns the whole chunk. Do appreciate any help. Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How do i view json data returned from django
Hello, I want to view the actual json data from django view, is there anyway i can do that before i parse it into jQuery? Below are my two methods def refresh_list(request): if request.method == 'POST': if 'name_input2' in request.POST: username = request.POST['name_input2'] print username refresh_keyword = get_keyword_subscription_dict(username) #message = refresh_keyword response = simplejson.dumps({'new_list': refresh_keyword}) return HttpResponse(response, mimetype='application/json') print 'Success' else: response = simplejson.dumps({'success':'False'}) if request.is_ajax(): return HttpResponse(response, mimetype='application/json') else: return HttpResponseRedirect("/") def get_keyword_subscription_dict(userid = None, keyword = None): try: keyword_subscription_dict = {} if(userid): cf = settings.cf_users_kw list_of_keywords_for_user_cf = cf.get(userid, columns=['keyword']) keyword_subscription_dict = ujson.decode(list_of_keywords_for_user_cf['keyword']) if(keyword): return simplejson.dumps(keyword_subscription_dict[keyword]) return simplejson.dumps(keyword_subscription_dict) except: return simplejson.dumps('\\') Do appreciate any help i can get Thanks! Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Anyone experience any thing like this before?
Thanks creecode. I totally forgot about that! cheers for pointing that out! Best Regards, Stanwin Siow On Mar 3, 2012, at 11:52 PM, creecode wrote: > def __unicode__ ( self ): > > return '%s' % self.pk -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django registration
Greetings, How do i save a user's profile into the database once i entered the details in my custom registration form? Also right now when i'm testing it out, i get the following error: create_inactive_user() got an unexpected keyword argument 'profile_callback' What could be the problem here? Am i overriding the original form correctly? Appreciate any inputs. Cheers here are the snippets you require: Forms.py from django import forms from r2.models import Keyword from r2.models import UserProfile from registration.forms import RegistrationForm from registration.models import RegistrationProfile from django.utils.translation import ugettext_lazy as _ from registration.forms import RegistrationForm, attrs_dict class ProjectSpecificRegistrationForm(RegistrationForm): keywords = forms.ModelChoiceField(queryset=Keyword.objects.all()) first_name =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'First Name')) last_name =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'Last Name')) def save(self): new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], password=self.cleaned_data['password1'], email=self.cleaned_data['email']) new_profile = UserProfile(user=new_user,username=self.cleaned_data['username'], keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name']) new_profile.save() project urls.py from r2.registration.views import activate from r2.registration.views import register from r2.forms import ProjectSpecificRegistrationForm url(r'^accounts/', include('registration.urls')), #url(r'^accounts/profile/', 'r2.views.profile'), url(r'^keyword_subscribe/$', 'r2.views.keyword_subscribe'), url(r'^refresh_list/$', 'r2.views.refresh_list'), url(r'^test/$', 'r2.views.test'), #registrations URLS url(r'^activate/(?P\w+)/$',activate,name='registration_activate'), url(r'^login/$',auth_views.login,{'template_name': 'registration/login.html'}, name='auth_login'), url(r'^logout/$',auth_views.logout,{'template_name': 'registration/logout.html'},name='auth_logout'), url(r'^password/change/$',auth_views.password_change,name='auth_password_change'), url(r'^password/change/done/$',auth_views.password_change_done,name='auth_password_change_done'), url(r'^password/reset/$',auth_views.password_reset,name='auth_password_reset'), url(r'^password/reset/confirm/(?P[0-9A-Za-z]+)-(?P.+)/$',auth_views.password_reset_confirm,name='auth_password_reset_confirm'), url(r'^password/reset/complete/$',auth_views.password_reset_complete,name='auth_password_reset_complete'), url(r'^password/reset/done/$',auth_views.password_reset_done,name='auth_password_reset_done'), url(r'^register/$',register, {'form_class' : ProjectSpecificRegistrationForm}, name='registration_register'), url(r'^register/complete/$',direct_to_template,{'template': 'registration/registration_complete.html'},name='registration_complete'), Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django registration
Even after doing that, The error still occurs. And my data is still unsaved in the database. Should i be creating a backend? Best Regards, Stanwin Siow On Mar 5, 2012, at 7:13 PM, nicolas HERSOG wrote: > I looked at my code in order to notice diffs. > > You should add return new_user() after your new_profile.save() > > > On Mon, Mar 5, 2012 at 11:54 AM, Stanwin Siow > wrote: > Greetings, > > How do i save a user's profile into the database once i entered the details > in my custom registration form? > > Also right now when i'm testing it out, i get the following error: > > create_inactive_user() got an unexpected keyword argument 'profile_callback' > What could be the problem here? > > Am i overriding the original form correctly? > > Appreciate any inputs. Cheers > > here are the snippets you require: > > Forms.py > > from django import forms > from r2.models import Keyword > from r2.models import UserProfile > from registration.forms import RegistrationForm > from registration.models import RegistrationProfile > from django.utils.translation import ugettext_lazy as _ > from registration.forms import RegistrationForm, attrs_dict > > class ProjectSpecificRegistrationForm(RegistrationForm): > keywords = forms.ModelChoiceField(queryset=Keyword.objects.all()) > first_name > =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'First > Name')) > last_name > =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'Last > Name')) > > def save(self): > new_user = > RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], > password=self.cleaned_data['password1'], > email=self.cleaned_data['email']) > new_profile = > UserProfile(user=new_user,username=self.cleaned_data['username'], > keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name']) > > new_profile.save() > > project urls.py > > from r2.registration.views import activate > from r2.registration.views import register > from r2.forms import ProjectSpecificRegistrationForm > > url(r'^accounts/', include('registration.urls')), > #url(r'^accounts/profile/', 'r2.views.profile'), > url(r'^keyword_subscribe/$', 'r2.views.keyword_subscribe'), > url(r'^refresh_list/$', 'r2.views.refresh_list'), > url(r'^test/$', 'r2.views.test'), > > #registrations URLS > > url(r'^activate/(?P\w+)/$',activate,name='registration_activate'), > url(r'^login/$',auth_views.login,{'template_name': > 'registration/login.html'}, name='auth_login'), > url(r'^logout/$',auth_views.logout,{'template_name': > 'registration/logout.html'},name='auth_logout'), > > url(r'^password/change/$',auth_views.password_change,name='auth_password_change'), > > url(r'^password/change/done/$',auth_views.password_change_done,name='auth_password_change_done'), > > url(r'^password/reset/$',auth_views.password_reset,name='auth_password_reset'), > > url(r'^password/reset/confirm/(?P[0-9A-Za-z]+)-(?P.+)/$',auth_views.password_reset_confirm,name='auth_password_reset_confirm'), > > url(r'^password/reset/complete/$',auth_views.password_reset_complete,name='auth_password_reset_complete'), > > url(r'^password/reset/done/$',auth_views.password_reset_done,name='auth_password_reset_done'), > url(r'^register/$',register, {'form_class' : > ProjectSpecificRegistrationForm}, name='registration_register'), > > url(r'^register/complete/$',direct_to_template,{'template': > 'registration/registration_complete.html'},name='registration_complete'), > > > > > Best Regards, > > Stanwin Siow > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django registration
what is Pinax? And this is not a learning exercise. Well i'll still want to know the other way too. Best Regards, Stanwin Siow On Mar 5, 2012, at 9:41 PM, Alec Taylor wrote: > DRY principle is what Django is all about. > > Use Pinax instead of developing your own Profile system. > > If Pinax profiles don't show exactly what you want, extend them. > > Unless you're doing this as a learning exercise? > > On Mon, Mar 5, 2012 at 10:46 PM, Stanwin Siow > wrote: >> Even after doing that, >> >> The error still occurs. And my data is still unsaved in the database. >> >> Should i be creating a backend? >> >> Best Regards, >> >> Stanwin Siow >> >> >> >> On Mar 5, 2012, at 7:13 PM, nicolas HERSOG wrote: >> >> I looked at my code in order to notice diffs. >> >> You should add return new_user() after your new_profile.save() >> >> >> On Mon, Mar 5, 2012 at 11:54 AM, Stanwin Siow >> wrote: >>> >>> Greetings, >>> >>> How do i save a user's profile into the database once i entered the >>> details in my custom registration form? >>> >>> Also right now when i'm testing it out, i get the following error: >>> >>> create_inactive_user() got an unexpected keyword argument >>> 'profile_callback' >>> >>> What could be the problem here? >>> >>> Am i overriding the original form correctly? >>> >>> Appreciate any inputs. Cheers >>> >>> here are the snippets you require: >>> >>> Forms.py >>> >>> from django import forms >>> from r2.models import Keyword >>> from r2.models import UserProfile >>> from registration.forms import RegistrationForm >>> from registration.models import RegistrationProfile >>> from django.utils.translation import ugettext_lazy as _ >>> from registration.forms import RegistrationForm, attrs_dict >>> >>> class ProjectSpecificRegistrationForm(RegistrationForm): >>> keywords = forms.ModelChoiceField(queryset=Keyword.objects.all()) >>> first_name >>> =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'First >>> Name')) >>> last_name >>> =forms.CharField(widget=forms.TextInput(attrs=attrs_dict),label=_(u'Last >>> Name')) >>> >>> def save(self): >>> new_user = >>> RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], >>> password=self.cleaned_data['password1'], >>> email=self.cleaned_data['email']) >>> new_profile = >>> UserProfile(user=new_user,username=self.cleaned_data['username'], >>> keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name']) >>> >>> new_profile.save() >>> >>> project urls.py >>> >>> from r2.registration.views import activate >>> from r2.registration.views import register >>> from r2.forms import ProjectSpecificRegistrationForm >>> >>> url(r'^accounts/', include('registration.urls')), >>> #url(r'^accounts/profile/', 'r2.views.profile'), >>> url(r'^keyword_subscribe/$', 'r2.views.keyword_subscribe'), >>> url(r'^refresh_list/$', 'r2.views.refresh_list'), >>> url(r'^test/$', 'r2.views.test'), >>> >>> #registrations URLS >>> >>> url(r'^activate/(?P\w+)/$',activate,name='registration_activate'), >>> url(r'^login/$',auth_views.login,{'template_name': >>> 'registration/login.html'}, name='auth_login'), >>> url(r'^logout/$',auth_views.logout,{'template_name': >>> 'registration/logout.html'},name='auth_logout'), >>> >>> url(r'^password/change/$',auth_views.password_change,name='auth_password_change'), >>> >>> url(r'^password/change/done/$',auth_views.password_change_done,name='auth_password_change_done'), >>> >>> url(r'^password/reset/$',auth_views.password_reset,name='auth_password_reset'), >>> >>> url(r'^password/reset/confirm/(?P[0-9A-Za-z]+)-(?P.+)/$',
Re: django registration
I don't think using another external app now would be ideal since i want to push it to production soon. >From what i found online, it says i'm calling that profile_callback() that is >in the original forms.py. But having said that, i think Pinax is quite cool if i've got the time to take a look at it. I've had a brief read. One thing that's bothering me is if i do use Pinax, do i have to rewrite everything again? Best Regards, Stanwin Siow On Mar 5, 2012, at 9:53 PM, roy moss wrote: > Pinax is an open-source platform built on the Django Web Framework. By > integrating numerous reusable Django apps and providing starter projects and > infrastructure tools, Pinax takes care of the things that many sites have in > common so you can focus on what makes your site different. Pinax has been > used for everything from social networks to conference websites, and from > intranets to online games. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django-subscription
Hello, I was wondering whether there are any links that teaches you how to integrate django-subscription into your app in detail? To give a general view of what i would be doing, i want to integrate the django-subscription so i can give recurring billing to my customers. So far what i have found are documentations on git hub that don't give a clear picture. if there is a better solution i am all ears. Appreciate any kind of help offered. Thanks! Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Passing a query set into a template
Hello, I have the following view method: def index(request): form = OpinionOptionForm(initial={'keyword': 'singtel', 'start_date': datetime.today()-timedelta(days=7), 'end_date': datetime.today(), 'resolution': '8-hour', 'influence': 'all', 'sentiment_type': 'pos-neg'}) return render_to_response('r2/opinion/index.html', {'form': form}, context_instance=RequestContext(request)) i know i can do some queryset passing into the render_to_response method so i can use that queryset list in my template. How do i go about doing that? The queryset i want to pass is Keywords that is imported from r2.models. Thank you Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Help with django-paypal anyone?
Hello, I was following this tutorial on django-paypal from this link: http://od-eon.com/blogs/nai/django-paypal-step-step-integration/?c=619 i managed to get the paypal button working but when i click return to home page i get a CSRF token not found. Please advise on how i should continue? I would appreciate any help rendered. Thank you. Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Help with django-paypal anyone?
hey daniel, I used the johnbox version. Should be ok right? Best Regards, Stanwin Siow On Mar 22, 2012, at 6:01 PM, Daniel Hilton wrote: > On 22 March 2012 05:47, Jonathan Baker wrote: >> You'll need to enable the CSRF middleware, adjust your view and make use of >> the {% csrf_token %} template tag in your template. Details can be found >> here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/ >> >> >> On Wed, Mar 21, 2012 at 11:35 PM, Stanwin Siow >> wrote: >>> >>> Hello, >>> >>> I was following this tutorial on django-paypal from this link: >>> http://od-eon.com/blogs/nai/django-paypal-step-step-integration/?c=619 >>> >>> i managed to get the paypal button working but when i click return to home >>> page i get a CSRF token not found. >>> >>> Please advise on how i should continue? >>> >>> I would appreciate any help rendered. >>> >>> Thank you. >>> >>> Best Regards, >>> >>> Stanwin Siow > > Hey! > > Which fork are you using? dcramer's on github was the best when I was > working with this last year. > > HTH > Dan > > > >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >> >> >> >> >> -- >> Jonathan D. Baker >> Web Developer >> http://jonathandbaker.com >> 303.257.4144 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. > > > > -- > Dan Hilton > > www.twitter.com/danhilton > www.DanHilton.co.uk > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Help with django-paypal anyone?
ok thank you. I'll take a look tonight. Cheers Best Regards, Stanwin Siow On Mar 22, 2012, at 6:30 PM, Daniel Hilton wrote: > On 22 March 2012 10:20, Stanwin Siow wrote: >> hey daniel, >> >> I used the johnbox version. >> > > I found this version has more uptodate bug fixes and features: > https://github.com/dcramer/django-paypal > > HTH > Dan > > > >> Should be ok right? >> >> Best Regards, >> >> Stanwin Siow >> >> >> >> On Mar 22, 2012, at 6:01 PM, Daniel Hilton wrote: >> >> On 22 March 2012 05:47, Jonathan Baker wrote: >> >> You'll need to enable the CSRF middleware, adjust your view and make use of >> >> the {% csrf_token %} template tag in your template. Details can be found >> >> here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/ >> >> >> >> On Wed, Mar 21, 2012 at 11:35 PM, Stanwin Siow >> >> wrote: >> >> >> Hello, >> >> >> I was following this tutorial on django-paypal from this link: >> >> http://od-eon.com/blogs/nai/django-paypal-step-step-integration/?c=619 >> >> >> i managed to get the paypal button working but when i click return to home >> >> page i get a CSRF token not found. >> >> >> Please advise on how i should continue? >> >> >> I would appreciate any help rendered. >> >> >> Thank you. >> >> >> Best Regards, >> >> >> Stanwin Siow >> >> >> Hey! >> >> Which fork are you using? dcramer's on github was the best when I was >> working with this last year. >> >> HTH >> Dan >> >> >> >> >> >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> >> "Django users" group. >> >> To post to this group, send email to django-users@googlegroups.com. >> >> To unsubscribe from this group, send email to >> >> django-users+unsubscr...@googlegroups.com. >> >> For more options, visit this group at >> >> http://groups.google.com/group/django-users?hl=en. >> >> >> >> >> >> -- >> >> Jonathan D. Baker >> >> Web Developer >> >> http://jonathandbaker.com >> >> 303.257.4144 >> >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> >> "Django users" group. >> >> To post to this group, send email to django-users@googlegroups.com. >> >> To unsubscribe from this group, send email to >> >> django-users+unsubscr...@googlegroups.com. >> >> For more options, visit this group at >> >> http://groups.google.com/group/django-users?hl=en. >> >> >> >> >> -- >> Dan Hilton >> >> www.twitter.com/danhilton >> www.DanHilton.co.uk >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. > > > > -- > Dan Hilton > > www.twitter.com/danhilton > www.DanHilton.co.uk > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Simple question on queryset.
Hello, How do i transform this SQL query into a queryset? select membership_type from memberships where id ='4' i tried the following: queryset = Memberships.objects.get(id__exact=4) however django is throwing me an error with the following: Memberships has no attribute all. I know this is a trivial question but i've been through the tutorials https://docs.djangoproject.com/en/dev/topics/db/queries/ and i don't unds where this error is coming from. Do appreciate any help rendered. Thank you. Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Simple question on queryset.
I tried changing it to what you said. It's still showing the error. "Memberships object has no attribute all" This only happens when i use get. When i use order_by. the page shows but with unnecessary options. Best Regards, Stanwin Siow On Mar 27, 2012, at 3:32 PM, Denis Darii wrote: > I think the error "Memberships has no attribute all" is not related to your > QuerySet. Try to look deeply into your code. > > BTW, your QuerySet must be: > > queryset = Memberships.objects.get(id=4) > > or better, if your id is also the primary key: > > queryset = Memberships.objects.get(pk=4) > > On 27 March 2012 08:57, Stanwin Siow wrote: > > Hello, > > How do i transform this SQL query into a queryset? > > select membership_type from memberships where id ='4' > > i tried the following: > > queryset = Memberships.objects.get(id__exact=4) > > however django is throwing me an error with the following: > > Memberships has no attribute all. > > > I know this is a trivial question but i've been through the tutorials > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > and i don't unds where this error is coming from. > > Do appreciate any help rendered. > > Thank you. > > > Best Regards, > > Stanwin Siow > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- > I'm using Linux because i'm freedom dependent. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Simple question on queryset.
ok i managed to get it to work by using filter. Cheers Best Regards, Stanwin Siow On Mar 27, 2012, at 3:32 PM, Denis Darii wrote: > I think the error "Memberships has no attribute all" is not related to your > QuerySet. Try to look deeply into your code. > > BTW, your QuerySet must be: > > queryset = Memberships.objects.get(id=4) > > or better, if your id is also the primary key: > > queryset = Memberships.objects.get(pk=4) > > On 27 March 2012 08:57, Stanwin Siow wrote: > > Hello, > > How do i transform this SQL query into a queryset? > > select membership_type from memberships where id ='4' > > i tried the following: > > queryset = Memberships.objects.get(id__exact=4) > > however django is throwing me an error with the following: > > Memberships has no attribute all. > > > I know this is a trivial question but i've been through the tutorials > https://docs.djangoproject.com/en/dev/topics/db/queries/ > > and i don't unds where this error is coming from. > > Do appreciate any help rendered. > > Thank you. > > > Best Regards, > > Stanwin Siow > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- > I'm using Linux because i'm freedom dependent. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django: 404 page not found
check your Media_root in settings.py. It could be a missing stroke. Best Regards, Stanwin Siow On Apr 3, 2012, at 8:14 AM, Homer wrote: > I met "404" page not found when I try to enter 127.0.0.1:8000/cn/bedroom . It > says on the webpage that "C:/Django/final/media/bedroom" does not exist". Why > would this happen? > > urls.py: > > from django.conf.urls.defaults import * > from final import settings > > from django.contrib import admin > > admin.autodiscover() > > urlpatterns = patterns('', > > url(r'^admin/', include(admin.site.urls)), > > url(r'^cn/', include('final.photo.urls')), > > url(r'^cn/(?P.*)$', 'django.views.static.serve', > > {'document_root': settings.MEDIA_ROOT}), > > ) > photo/urls.py: > > from django.conf.urls.defaults import * > > from final.photo.views import List, Detail > > urlpatterns = patterns('', > > url(r'^$', List), > url(r'^/bedroom/', Detail), > > ) > > photo/views.py: > > > from django.template import loader, Context, RequestContext > > from django.http import HttpResponse > > from final.photo.models import Image, Audio, Pinyin, SImage > > from django.shortcuts import render_to_response > > def List(request): > > ShowSImage = SImage.objects.all() > ShowLink = Image.objects.all() > > context = RequestContext(request, { > > 'ShowSImage': ShowSImage, 'ShowLink': ShowLink > > }) > > return render_to_response('list.html', context) > > def Detail(request): > ShowImage = Image.objects.all() > ShowPinyin = Pinyin.objects.all() > ShowAudio = Audio.objects.all() > context = RequestContext(request, { > 'ShowAudio': ShowAudio, 'ShowImage': ShowImage, 'ShowPinyin': > ShowPinyin > }) > return render_to_response('detail.html', context) > detail.html: > > {% extends "base.html" %} > > {% block title %}{{ item.title }}{% endblock %} > > {% block content %} > > {{ item.title }} > > {% if object.caption %}{{ object.caption }}{% endif %} > > {% endblock %} > Thanks in advance! > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/V1uKDrAvYS0J. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Git migration
Hello there, Just wanted to enquire about a project that i have been working on. It was previously hosted on an svn repository however my supervisor then decided to migrate it to GIT. my question here would be do i need to reinstall the external modules that i used in my django project like django-registration and django-paypal in GIT? Or would the functionalities be the same? I'm asking this is because i discovered a break in the program after the migration. Any help or advice is appreciated. Thanks in advance! Best Regards, Stanwin Siow -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Git migration
Thanks everyone for the replies. Reason why i'm asking was because after the migration it seemed that my django registration module was not picked up. Hence login and registration are now unavailable. Was looking at all ways to resolve it. Shall dig deeper. Thanks! Best Regards, Stanwin Siow On May 4, 2012, at 11:55 AM, Rivsen wrote: > hi Stanwin, > > I think git is tool to manage your code, no matter it is python or php or etc. > > Migrate code from svn to git, you just make sure your svn commit log is right > in git repo. > > And if you just want use git in your development, don't care the remote is > svn or git, you can try git-svn, this is a great tool for git clone and > manage svn repo! > > Best regards, > > Rivsen > > 2012/5/4 Stanwin Siow > Hello there, > > Just wanted to enquire about a project that i have been working on. > > It was previously hosted on an svn repository however my supervisor then > decided to migrate it to GIT. > > my question here would be do i need to reinstall the external modules that i > used in my django project like django-registration and django-paypal in GIT? > > Or would the functionalities be the same? > > I'm asking this is because i discovered a break in the program after the > migration. > > Any help or advice is appreciated. > > Thanks in advance! > > > > Best Regards, > > Stanwin Siow > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: "Connection refused" with backend psycopg2
On May 23, 2012, at 1:41 PM, Tanuva wrote: > Am 22.05.2012 23:52, schrieb akaariai: >> On May 22, 11:51 pm, Tanuva wrote: >>> Moin, >>> >>> lately, I wanted to switch my database from the testing sqlite file to a >>> more productive pgsql 8.4 server. Now I'm constantly getting a >>> "connection refused" from the psycopg2 backend:http://dpaste.org/0Ezka/ >>> Database configuration:http://dpaste.org/QPjD2/(not that verbose...) >>> >>> Funny enough, connecting manually using psycopg2 in a python2 shell and >>> using pgadmin to confirm changes done there works just fine, so there >>> must be something in between. >>> >>> What information might help you help me helping myself? ;) >> >> I would take a wild guess that this is related to pg_hba.conf. Is the >> database on the localhost? If so, can you connect to it using 'psql -d >> thedb', but not with 'psql -d thedb -h www0.com -U >> the_user_in_settings'. >> >> - Anssi >> > > No, the db is not running on localhost, the machine sits in some > datacentre. On that db server, your first command indeed doesn't work. > Sadly that doesn't tell us much now I guess. The second one works fine > both on the machine and here on my local box. > > Marcel I had the same problem when i was working on a school project. I informed my supervisor and he restarted the servers which solved the problem. I don't know if that may solve your problem but do be careful because i believe you are dealing with production servers. Just my two cents worth. Stanwin > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: JQuery Django
On May 23, 2012, at 2:06 PM, cocoza4 wrote: > I'm new to Django. > How can i connect Django with jQuery? > > is there any additional tool that i need to install? > > could you show me a sample code also? > > Thanks in advance. > All you need to do is to insert the jquery code into the html pages that require jquery. Remember to add the jquery file at the top > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/OIGnCdgMJooJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.