Editing a many to many field in a save method
Hi, I've got the following model and I want it so that each delivery has a default category of undefined class Delivery(models.Model): . categories = models.ManyToManyField(Category, blank = True, null = True) . Then if other categories are selected undefined is automatically removed from the delivery's categories. I thought I would be able to do this using the save method below, but it doesn't work. If categories are none it doesn't add undefined and if serveral are selected it doesn't remove undefined. def save(self): super(Delivery, self).save() if self.categories.count() == 0: undefined = Category.objects.get(name='undefined') self.categories.add(undefined) if self.categories.count() > 1: undefined = Category.objects.get(name='undefined') for category in self.categories.all(): if category == undefined: self.categories.remove(undefined) super(Delivery, self).save() if i select/deselect them using the admin interface they work fine, just not the changes i try to make in save. I'd appreciate any help, I don't know if i've misunderstood something or if its something else. thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Mod_WSGI and lib python
Hi, I have been trying to setup mod_wsgi with apache 2 but when I do: sudo a2enmod mod-wsgi sudo /etc/init.d/apache2 restart I get this error message: Restarting web server: apache2apache2: Syntax error on line 185 of / etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods- enabled/mod-wsgi.load: Cannot load /usr/lib/apache2/modules/ mod_wsgi.so into server: libpython2.7.so.1.0: cannot open shared object file: No such file or directory failed! but I have that file here: /usr/local/lib/libpython2.7.so.1.0 and i can do: echo $LD_LIBRARY_PATH :/usr/local/ lib I imangine I have misunderstood something here, and its trying to find the libpython file somewhere else. Could somebody please help me, thanks Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Extending admin views?
If i have an admin form and want to transform some data to another format using AJAX within the form, what is the best way to do this. In a normal form I can do this within the view but is there any way to extend admin views to add new functionality without loosing the default admin view functionality? This is more a theoretical question than a practical one. I have searched the docs but maybe I was searching for the wrong thing since I couldn't find anything. Thanks in advance, Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Extending admin views?
If i have an admin form and want to transform some data to another format using AJAX within the form, what is the best way to do this. In a normal form I can do this within the view but is there any way to extend admin views to add new functionality without loosing the default admin view functionality? This is more a theoretical question than a practical one. I have searched the docs but maybe I was searching for the wrong thing since I couldn't find anything. Thanks in advance, Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
queryset in clean method
hello, i have a clean method in my forms.py. I want this to check a person is old enough to enter a competiton The problem i have is that the minimum age changes and is a field in the competition model(it is entered by the user). My clean method is like this (pseudo code): class personform(forms.Form): ... def clean_recipients(self): dateOfBirth = self.cleaned_data['dob'] if dateOfBirth > competition.min_age .. return data The same form is used to enter any competition, and uses the url to get the competition id eg: mysite.com/enter_competition/my_competition since competition_slug will only become apparent from the url in views how can i find out the relevant min_age for my clean method in forms.py? I would be greatful for any help, sorry if i haven't explained this very well. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Resize image if too large
Turned out it was all up the pole, but have it working now. The validation to check the size did work though. On 15 Mar, 16:12, "ge...@aquarianhouse.com" wrote: > well, something is missing, like > > def save(self, *args, **kwargs): > #your code > > but in our case the form class should do the validation... > > On Mar 15, 5:07 pm, When ideas fail wrote: > > > Hello, I've been trying to create a save method which resizes an image > > if it is too large. Using pil this is what I have so far: > > > class Photo(models.Model): > > > title = models.CharField(max_length=750) > > photo = models.FileField(upload_to='full_size/') > > alt = models.CharField(max_length=50, null=True, blank=True) > > > # Save the photo in less than or equal to 800x600 > > > if image.size[0] > 800: > > if image.size[1] > 600: > > #resize image if its too large > > MAX_SIZE = (800,600) > > if self.photo: > > filename = self.photo.path > > image = Image.open(filename) > > image.thumbnail(MAX_SIZE, Image.ANTIALIAS) > > image.save(filename) > > super(Photo, self).save() > > else: > > super(Photo, self).save() > > > but it doesn't seem to work. It doesn't produce any errors but the > > images are the same size that they where before. Could someone tell me > > what i'm doing wrong? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Resize image if too large
Hello, I've been trying to create a save method which resizes an image if it is too large. Using pil this is what I have so far: class Photo(models.Model): title = models.CharField(max_length=750) photo = models.FileField(upload_to='full_size/') alt = models.CharField(max_length=50, null=True, blank=True) # Save the photo in less than or equal to 800x600 if image.size[0] > 800: if image.size[1] > 600: #resize image if its too large MAX_SIZE = (800,600) if self.photo: filename = self.photo.path image = Image.open(filename) image.thumbnail(MAX_SIZE, Image.ANTIALIAS) image.save(filename) super(Photo, self).save() else: super(Photo, self).save() but it doesn't seem to work. It doesn't produce any errors but the images are the same size that they where before. Could someone tell me what i'm doing wrong? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Toggle TinyMCE in admin
Would that just do one field rather than all the text areas? On 22 Feb, 16:41, orokusaki wrote: > I think you can do this by adding the exact HTML that you need into > the label field for a form (I can't remember if you have to explicitly > turn off HTML filtering though, check the docs to be sure). I would > just put Toggle a> The id_tag_of_field is of course available dynamically. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Toggle TinyMCE in admin
Oh I should mention I have already added the javascript function to the page by including the JS file. So I really only need to include the link next to textareas. On 22 Feb, 16:34, When ideas fail wrote: > Hello, I've been using TinyMCE for a WYSIWYG editor on my admin text > areas. However I would like to be able to toggle it on and off like > this: > > http://tinymce.moxiecode.com/examples/example_01.php > > But I wasn't sure of the best way to do this. Does anyone have any > suggestions? > > Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Toggle TinyMCE in admin
Hello, I've been using TinyMCE for a WYSIWYG editor on my admin text areas. However I would like to be able to toggle it on and off like this: http://tinymce.moxiecode.com/examples/example_01.php But I wasn't sure of the best way to do this. Does anyone have any suggestions? Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 Javascript
Thanks, got it working using that method after abit of messing. On 16 Feb, 14:01, Xavier Ordoquy wrote: > Hi, > > > Hi, I've been trying to use TinyMCE in my admin pages, I've followed > > this tutorial but so far have had no luck. > > >http://code.djangoproject.com/wiki/AddWYSIWYGEditor > > I also followed this tutorial and had few issues. > I went for this > solution:http://code.djangoproject.com/wiki/AddWYSIWYGEditor#Withnewforms-admin > > Hopes this will help, > Xavier. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 Javascript
I got it working after abit of messing using the newforms-admin section instructions: http://code.djangoproject.com/wiki/AddWYSIWYGEditor#Withnewforms-admin I didn't look at django-tinymce. Thanks, Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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 Javascript
Hi, I've been trying to use TinyMCE in my admin pages, I've followed this tutorial but so far have had no luck. http://code.djangoproject.com/wiki/AddWYSIWYGEditor I tried using this method (http://beshrkayali.com/posts/4/) , that incoporates the Javascript directly into the templates and that works fine. But I want to get it to work through the models.py file. This is my models.py: class Post(models.Model): prepopulated_fields = {"post_slug": ("post_title", )} #model fields def __unicode__(self): return self.post_title def get_absolute_url(self): return "/blog/%s/" % self.post_slug class Admin: js = ( 'tiny_mce/tiny_mce.js', 'js/textareas.js', ) these paths start in my media directory as specified in settings.py, so I can go to myurl.com/media/js/textarea.js and see the files. The other thing i noticed is that if I view source for the admin files there is no mention of any javascript, so I thought maybe it wasn't the paths, but something else, maybe something wrong with the class admin. I'd appreciate any suggestions, thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: URL Matching: 404 Error
Ah, I see, the problem is with the keys.., not the URLs On 30 Jan, 22:16, When ideas fail wrote: > Hi, I seem to be having a problem matching one of my URLs. > I have this URL in my .py file in one of my user app. > > url(r'^activate/(?P\w+)/$', > activate, > name='registration_activate'), > > and then thats added to my project urls: > > (r'^users/', include('mysite.users.urls')), > > but then if I try to go > onhttp://localhost:8080/mysite/users/activate/sha1$7a0a7$37aacf25bd9d26... > > it says Page not found (404) > > but then it shows the list of URL patterns on the debug screen > including: > > ^users/ ^activate/(?P\w+)/$. > > All my other URLs work fine, could someone suggest what might be wrong > with this one? > > Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
URL Matching: 404 Error
Hi, I seem to be having a problem matching one of my URLs. I have this URL in my .py file in one of my user app. url(r'^activate/(?P\w+)/$', activate, name='registration_activate'), and then thats added to my project urls: (r'^users/', include('mysite.users.urls')), but then if I try to go on http://localhost:8080/mysite/users/activate/sha1$7a0a7$37aacf25bd9d262fe6137666cb29c558fb7630bd/ it says Page not found (404) but then it shows the list of URL patterns on the debug screen including: ^users/ ^activate/(?P\w+)/$. All my other URLs work fine, could someone suggest what might be wrong with this one? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Imports, works from directory but not from file
I used this in my settings.py to add the open id folder on my path sys.path.append(os.path.join(FILE_ROOT, 'lib', 'openid')) and on my path it say: 'C:\\TheAbeonaFile\\Python26\\Lib\\idlelib\\lib\\openid' And both the yadis file and openid file have an init.py On 10 Nov, 22:18, Bill Freeman wrote: > Which all of these directories are on your python path, and which of > them have __init__.py files? > > Bill > > [Hint to answer first question: > > from pprint import pprint as pp > import sys > pp(sys.path) > > ] > > On Tue, Nov 10, 2009 at 5:12 PM, When ideas fail > > wrote: > > > I have a folder called lib on my path and in there I have a folder > > called openid. > > > If i want to import things from openid i have a problem. > > > For example if I have these 2 import statements: > > > from openid.yadis import xri > > from openid.association import Association as OIDAssociation > > > yadis is a directory (in openid) and then there is xri.py inside. This > > works fine. > > association is a .py file not in a subdirectory, just in lib/openid > > this produces the following error: > > > Traceback (most recent call last): > > File "C:\TheAbeonaFile\Apache2.2\MyProject\test.py", line 18, in > > > > from openid.association import Association as OIDAssociation > > ImportError: No module named association > > > I don't see why one would be a problem and not the other, does anyone > > have any ideas? > > > thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Imports, works from directory but not from file
I have a folder called lib on my path and in there I have a folder called openid. If i want to import things from openid i have a problem. For example if I have these 2 import statements: from openid.yadis import xri from openid.association import Association as OIDAssociation yadis is a directory (in openid) and then there is xri.py inside. This works fine. association is a .py file not in a subdirectory, just in lib/openid this produces the following error: Traceback (most recent call last): File "C:\TheAbeonaFile\Apache2.2\MyProject\test.py", line 18, in from openid.association import Association as OIDAssociation ImportError: No module named association I don't see why one would be a problem and not the other, does anyone have any ideas? thanks --~--~-~--~~~---~--~~ 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: Middleware stored locally
I have an init.py, is the path the likely problem or is it something else? thanks, Andrew On 15 Oct, 02:07, BenW wrote: > I think every dir on the import path needs and __init__.py > > On Oct 14, 5:10 pm, When ideas fail wrote: > > > If i have a lib folder in my app what is the correct way to reference > > it in settings.py? > > > I've tried this > > > MIDDLEWARE_CLASSES = ( > > 'myapp.lib.django_authopenid.middleware.OpenIDMiddleware' > > # and > > 'myapp.django_authopenid.middleware.OpenIDMiddleware' > > ) > > > the file its in is > > > \Apache2.2\myapp\lib\django_authopenid > > > but I get a 500 Internal Server and the error log tells me the > > following: > > > [Thu Oct 15 00:56:39 2009] [error] [client 127.0.0.1] raise > > exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' > > % (mw_module, e) > > [Thu Oct 15 00:56:39 2009] [error] [client 127.0.0.1] > > ImproperlyConfigured: Error importing middleware > > abeona.django_authopenid.middleware: "No module named > > django_authopenid.middleware" > > > I'd appreciate any help > > > Thanks > > > Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Middleware stored locally
If i have a lib folder in my app what is the correct way to reference it in settings.py? I've tried this MIDDLEWARE_CLASSES = ( 'myapp.lib.django_authopenid.middleware.OpenIDMiddleware' # and 'myapp.django_authopenid.middleware.OpenIDMiddleware' ) the file its in is \Apache2.2\myapp\lib\django_authopenid but I get a 500 Internal Server and the error log tells me the following: [Thu Oct 15 00:56:39 2009] [error] [client 127.0.0.1] raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e) [Thu Oct 15 00:56:39 2009] [error] [client 127.0.0.1] ImproperlyConfigured: Error importing middleware abeona.django_authopenid.middleware: "No module named django_authopenid.middleware" I'd appreciate any help Thanks Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Extending Django's Flatpages
Hello, i've been having a look at this post on overmortal about Extending Django's Flatpages: http://www.overmortal.com/blog/post/17-extending-django-s-flatpages specifically this section " Finally, in order to continue using the flatpages/default.html template file as the singular file for handling flatpage content, we need to create helper tags to bring out the keywords and description:" Would that part of the code go in the views.py because I get a 505 error and the error log tells me that it is an invalid tag: [Fri Oct 02 22:40:11 2009] [error] [client 127.0.0.1] TemplateSyntaxError: Invalid block tag: 'meta_keywords' Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Named URL Patterns -- Syntax Error
Can somebody tell me why i get a syntax error with this named URL pattern? urlpatterns = patterns('', url(r'^feed/(?P.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds} name="feed"), ) This is the traceback: Traceback: File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response 83. request.path_info) File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in resolve 216. for pattern in self.url_patterns: File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns 245. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module 240. self._urlconf_module = import_module (self.urlconf_name) File "C:\Python26\lib\site-packages\django\utils\importlib.py" in import_module 35. __import__(name) Exception Type: SyntaxError at / Exception Value: ('invalid syntax', ('C:\\Apache2.2\\myapp\\urls.py', 28, 73, '{\'feed_dict \': feeds} name="feed"),\n')) Thanks, Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
URL Tag for feeds
If i want to create a URL tag for feeds then where should the path.to.view point to? Should it point to urls.py or feeds.py? or do i need to do something else entirely? This is using the standard sydication framwork. Thanks, Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
URL Tag
Hello, I was wondering if somebody could tell me what i'm doing wrong. I keep getting this error relating to a url tag: Traceback: File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "C:\Apache2.2\myproject\myapp\views.py" in myapp 42.context_instance=RequestContext (request)) File "C:\Python26\lib\site-packages\django\shortcuts\__init__.py" in render_to_response 20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) File "C:\Python26\lib\site-packages\django\template\loader.py" in render_to_string 108. return t.render(context_instance) File "C:\Python26\lib\site-packages\django\template\__init__.py" in render 178. return self.nodelist.render(context) File "C:\Python26\lib\site-packages\django\template\__init__.py" in render 779. bits.append(self.render_node(node, context)) File "C:\Python26\lib\site-packages\django\template\debug.py" in render_node 81. raise wrapped Exception Type: TemplateSyntaxError at / Exception Value: Caught an exception while rendering: Reverse for 'myapp_views.title_view' with arguments '(u'Hello',)' and keyword arguments '{}' not found. my view for this is defined like this def title_view(request, slug): if request.method == 'POST': ... and in my template I have this: {% for object in posts.object_list %} {{ object.post_title }} .. I'd appreciate any help. Thanks, Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
mod_python to mod_wsgi
Hello, I've recently updated my setup to use mod_wsgi instead of mod_python. I'm having some problems with my urls. The home page loads fine but none of my other urls seems to work (404 errors). They worked before with mod_python. Do i need to include something else in my .wsgi file? import os import sys os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' sys.path.append('/usr/local/django') import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() or directives? Order deny,allow Allow from all WSGIScriptAlias /mysite/ C:/Apache2.2/mysite/django.wsgi -- I'm guessing its correct that whatever is in my urls would just go after my site, for example http://localhost:8080/mysite/thanks/ for ('^thanks/$', 'mysite.blog.views.thanks'), Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
MySQL
Hello, when I run python manage.py syncdb I get this error: File "C:\\Python26\lib\site-packages\MySQLdb\connections.py", lin e 170, in __init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'lo calhost' (10061)") I know mysql is working because I can connect using the client, I left it running on the default port when I set it up. This is my settings.py DATABASE_ENGINE = 'mysql' DATABASE_NAME = 'mydb' DATABASE_USER = 'root' DATABASE_PASSWORD = '' DATABASE_HOST = '' DATABASE_PORT = '' This is on Vista so that could be messing about but i'd appreciate any help, thanks. Andrew --~--~-~--~~~---~--~~ 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: html Escape
Thanks, can i strip out all tags other than tags. I would like people to be able to put links in comments. Andrew On 25 Aug, 03:42, Parag Shah wrote: > Hi, > > You can use the strip_tags function to strip all html from text. > > from django.utils.html import strip_tags > > In your view > comment = strip_tags(request.POST["comment"]) > > -- > Regards > Parag > > On Tue, Aug 25, 2009 at 4:25 AM, When ideas fail > wrote: > > > > > Hello, i want to allow users to post comments and I don't want them to > > be allowed to put html in comments. > > > However I would like the to be able to use paragraph p tags and > > tags but not anything other. Could someone tell me how to do this? > > > Thanks > > > Andrew > > -- > Thanks & Regards > Parag Shahhttp://blog.adaptivesoftware.biz --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
html Escape
Hello, i want to allow users to post comments and I don't want them to be allowed to put html in comments. However I would like the to be able to use paragraph p tags and tags but not anything other. Could someone tell me how to do this? Thanks Andrew --~--~-~--~~~---~--~~ 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: Image Location
Seems to be working now. Thanks. On 23 Aug, 18:28, When ideas fail wrote: > I changed it to post_img.url but i assume thats a different way of > doing the same thing. > > 1.The html source gives the image location as "http://www.mysite.net/ > content/imgs/newMessage.jpg" > > 2. I am using a RequestContext. > > Its an apache server and these are the related directives: > > > SetHandler None > > > > allow from all > order allow,deny > SetHandler None > > Alias /imgs/ "/home/mysite/content/imgs/" > > Andrew > > On 23 Aug, 17:18, "J. Cliff Dyer" wrote: > > > On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote: > > > Hello, i'm having a problem getting images to display so I was > > > wondering if someone would be kind enough to help? > > > > I have my settings.py set up as follows (content is the folder where > > > my static images are stored): > > > > MEDIA_ROOT = '/home/mysite/content/' > > > MEDIA_URL = 'http://www.mysites.net/content/' > > > > Then my template is like so: > > > > > > > > where object.post_img = imgs/newMessage.jpg > > > > but if i load the page up it doesn't appear. I checked the error log > > > it says: > > > > File does not exist: /home/mysite/public_html/content, referer: > > >http://www.mysite.net > > > 1. Check what's getting rendered in your HTML file for the src of that > > img. > > > 2. Make sure you're using a RequestContext, otherwise you won't have > > MEDIA_URL available to your templates. > > > 3. Figure out why public_html is showing up in the path reported by the > > error log. > > > Some information that will help with debugging: > > > * Are you using apache, the dev server, or something else? > > * If the dev server, where does your URLConf point to for > > static images? > > * What does the URLConf and view look like for the page that's > > getting rendered? > > > Cheers, > > Cliff --~--~-~--~~~---~--~~ 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: Image Location
I changed it to post_img.url but i assume thats a different way of doing the same thing. 1.The html source gives the image location as "http://www.mysite.net/ content/imgs/newMessage.jpg" 2. I am using a RequestContext. Its an apache server and these are the related directives: SetHandler None allow from all order allow,deny SetHandler None Alias /imgs/ "/home/mysite/content/imgs/" Andrew On 23 Aug, 17:18, "J. Cliff Dyer" wrote: > On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote: > > Hello, i'm having a problem getting images to display so I was > > wondering if someone would be kind enough to help? > > > I have my settings.py set up as follows (content is the folder where > > my static images are stored): > > > MEDIA_ROOT = '/home/mysite/content/' > > MEDIA_URL = 'http://www.mysites.net/content/' > > > Then my template is like so: > > > > > > where object.post_img = imgs/newMessage.jpg > > > but if i load the page up it doesn't appear. I checked the error log > > it says: > > > File does not exist: /home/mysite/public_html/content, referer: > >http://www.mysite.net > > 1. Check what's getting rendered in your HTML file for the src of that > img. > > 2. Make sure you're using a RequestContext, otherwise you won't have > MEDIA_URL available to your templates. > > 3. Figure out why public_html is showing up in the path reported by the > error log. > > Some information that will help with debugging: > > * Are you using apache, the dev server, or something else? > * If the dev server, where does your URLConf point to for > static images? > * What does the URLConf and view look like for the page that's > getting rendered? > > Cheers, > Cliff --~--~-~--~~~---~--~~ 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: Image Location
I changed it to post_img.url but i assume thats a different way of doing the same thing. 1.The html source gives the image location as "http://www.mysite.net/ content/imgs/newMessage.jpg" 2. I am using a RequestContext. Its an apache server and these are the related directives: SetHandler None allow from all order allow,deny SetHandler None Alias /imgs/ "/home/mysite/content/imgs/" Andrew On 23 Aug, 17:18, "J. Cliff Dyer" wrote: > On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote: > > Hello, i'm having a problem getting images to display so I was > > wondering if someone would be kind enough to help? > > > I have my settings.py set up as follows (content is the folder where > > my static images are stored): > > > MEDIA_ROOT = '/home/mysite/content/' > > MEDIA_URL = 'http://www.mysites.net/content/' > > > Then my template is like so: > > > > > > where object.post_img = imgs/newMessage.jpg > > > but if i load the page up it doesn't appear. I checked the error log > > it says: > > > File does not exist: /home/mysite/public_html/content, referer: > >http://www.mysite.net > > 1. Check what's getting rendered in your HTML file for the src of that > img. > > 2. Make sure you're using a RequestContext, otherwise you won't have > MEDIA_URL available to your templates. > > 3. Figure out why public_html is showing up in the path reported by the > error log. > > Some information that will help with debugging: > > * Are you using apache, the dev server, or something else? > * If the dev server, where does your URLConf point to for > static images? > * What does the URLConf and view look like for the page that's > getting rendered? > > Cheers, > Cliff --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Image Location
Hello, i'm having a problem getting images to display so I was wondering if someone would be kind enough to help? I have my settings.py set up as follows (content is the folder where my static images are stored): MEDIA_ROOT = '/home/mysite/content/' MEDIA_URL = 'http://www.mysites.net/content/' Then my template is like so: where object.post_img = imgs/newMessage.jpg but if i load the page up it doesn't appear. I checked the error log it says: File does not exist: /home/mysite/public_html/content, referer: http://www.mysite.net so it has added public_html to the path, how can i solve this issue? Many Thanks Andrew --~--~-~--~~~---~--~~ 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 templates
Hello, i'm having some problems getting the admin templates up and running. If i have my admin templates at '/home/mysite/media/admin/' what should my ADMIN_MEDIA_PREFIX be? and is that all i need to specify where the templates are? Also do i need to set up a directive along the lines of: Order Allow,Deny Allow from all SetHandler None Many thanks --~--~-~--~~~---~--~~ 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: if forloop.counter
Thanks! On 13 Aug, 20:52, Jonas Obrist wrote: > When ideas fail wrote: > > Hello, i know you can have things like {% if forloop.last %} > > but is it possible to have an if statement that matches the value of a > > forloop counter > > so it would be like: > > > {% if forloop.counter = 6 % } > > > or similar and how could i do that? > > > Thanks > > {% ifequal forloop.counter 6 %} > ... > {% endif %} > > Jonas --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
if forloop.counter
Hello, i know you can have things like {% if forloop.last %} but is it possible to have an if statement that matches the value of a forloop counter so it would be like: {% if forloop.counter = 6 % } or similar and how could i do that? Thanks --~--~-~--~~~---~--~~ 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: Filter based on dates
Thanks, i'd just worked that out, was about to come and post it. Thanks though. On 12 Aug, 20:23, Dj Gilcrease wrote: > On Wed, Aug 12, 2009 at 12:02 PM, When ideas > > fail wrote: > > def months_archive(request, year, month): > > blog_posts = Post.objects.all().order_by("-post_date") > > blog_posts = Post.objects.filter(post_date__year=year, > post_date__month=month).order_by("-post_date") --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Filter based on dates
Hello, if i have this view: def months_archive(request, year, month): blog_posts = Post.objects.all().order_by("-post_date") ... how can i filter the post objects by date? I have a field post_date which is a datetime field, and i need it to return all the posts written during the specified month in the year. I had a few goes but i'm stuck. I'd appreciate any help. Thanks --~--~-~--~~~---~--~~ 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: Post matching query does not exist.
After some more experiments i've decided its definetly some sort of problem with the URLs, if i comment one out the 2nd works and if i have them uncomment it doesn't. Can anyone help me with this please? On 11 Aug, 19:30, When ideas fail wrote: > Hi, I have a strange error which i hope someone might be able to help > me with. Two of my urls seems to be conflicting somehow. i have these > two URLs: > > (r'^blog/(?P.+)/$', 'mysite.blog.views.title_view'), > (r'^blog/category/(?P.+)/$', > 'mysite.blog.views.category_view'), > > > > which relate to two views which summarised are like this: > > def title_view(request, category): > blog_post = Post.objects.get(post_slug=slug) > ... > return render_to_response('blogSite/index.html', locals(), > context_instance=RequestContext(request)) > > def category_view(request, category): > blog_posts = Post.objects.filter > (post_tags__tag_name='category').order_by("-post_date") > ... > return render_to_response('blogSite/index.html', locals(), > context_instance=RequestContext(request)) > > > > Title view works fine but if i go on mysite.com/blog/category/General > I get the following error: > > File "C:\ProgLangs\Python25\lib\site-packages\django\core\handlers > \base.py" in get_response > 86. response = callback(request, *callback_args, > **calhttp://localhost:8080/akonline/blog/category/Andrew/lback_kwargs) > File "C:/Program Files/Apache2.2\mysite\blog\views.py" in title_view > 100. blog_post = Post.objects.get(post_slug=slug) > File "C:\ProgLangs\Python25\lib\site-packages\django\db\models > \manager.py" in get > 93. return self.get_query_set().get(*args, **kwargs) > File "C:\ProgLangs\Python25\lib\site-packages\django\db\models > \query.py" in get > 309. % self.model._meta.object_name) > > Exception Type: DoesNotExist at /blog/category/Andrew/ > Exception Value: Post matching query does not exist. > > The error mentions File "C:/Program Files/Apache2.2\mysite\blog > \views.py" in title_view > 100. blog_post = Post.objects.get(post_slug=slug) but this > line is in the first view which works. > > Category isn't going to match post)slug and it shouldn't so they seem > to be conflicting somehow. > I'd appreciate any help or even suggestion. > > Thank you > > Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Post matching query does not exist.
Hi, I have a strange error which i hope someone might be able to help me with. Two of my urls seems to be conflicting somehow. i have these two URLs: (r'^blog/(?P.+)/$', 'mysite.blog.views.title_view'), (r'^blog/category/(?P.+)/$', 'mysite.blog.views.category_view'), which relate to two views which summarised are like this: def title_view(request, category): blog_post = Post.objects.get(post_slug=slug) ... return render_to_response('blogSite/index.html', locals(), context_instance=RequestContext(request)) def category_view(request, category): blog_posts = Post.objects.filter (post_tags__tag_name='category').order_by("-post_date") ... return render_to_response('blogSite/index.html', locals(), context_instance=RequestContext(request)) Title view works fine but if i go on mysite.com/blog/category/General I get the following error: File "C:\ProgLangs\Python25\lib\site-packages\django\core\handlers \base.py" in get_response 86. response = callback(request, *callback_args, **calhttp://localhost:8080/akonline/blog/category/Andrew/lback_kwargs) File "C:/Program Files/Apache2.2\mysite\blog\views.py" in title_view 100. blog_post = Post.objects.get(post_slug=slug) File "C:\ProgLangs\Python25\lib\site-packages\django\db\models \manager.py" in get 93. return self.get_query_set().get(*args, **kwargs) File "C:\ProgLangs\Python25\lib\site-packages\django\db\models \query.py" in get 309. % self.model._meta.object_name) Exception Type: DoesNotExist at /blog/category/Andrew/ Exception Value: Post matching query does not exist. The error mentions File "C:/Program Files/Apache2.2\mysite\blog \views.py" in title_view 100. blog_post = Post.objects.get(post_slug=slug) but this line is in the first view which works. Category isn't going to match post)slug and it shouldn't so they seem to be conflicting somehow. I'd appreciate any help or even suggestion. Thank you Andrew --~--~-~--~~~---~--~~ 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 about URLs
If i have a URL such as: (r'^(?P\w+)/blog/', include('foo.urls.blog')), what are the whats the purpose of the w and the +? i'm having some problems with 2 of my urls and i think it may have something to do with this. Thanks --~--~-~--~~~---~--~~ 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: Contact form
Ok thanks, i'll have a look at the setup then. On 10 Aug, 20:29, Daniel Roseman wrote: > On Aug 10, 8:23 pm, When ideas fail wrote: > > > > > Hi, i've created a contact fom based on the one in the docs but i > > don't know what to put as the action in the form element as part of > > template. I've got this template: > > > > > {{ form.as_p }} > > > > > > > but presuambly the data is being handled by the view. I'd appreciate > > any help, i tried it without an action and i got a 'Exception Value: > > (10061, 'Connection refused') ' error. > > > Could someone please help? > > > Thanks > > > I've included a copy of the view below > > --- > > - > > > def contact_me(request): > > if request.method == 'POST': > > form = ContactForm(request.POST) > > if form.is_valid(): > > subject = form.cleaned_data['subject'] > > message = form.cleaned_data['message'] > > sender = form.cleaned_data['sender'] > > cc_myself = form.cleaned_data['cc_myself'] > > > recipients = ['andrewkenyon...@gmail.com'] > > if cc_myself: > > recipients.append(sender) > > > from django.core.mail import send_mail > > send_mail(subject, message, sender, recipients) > > return HttpResponseRedirect('/thanks/') > > > else: > > form = ContactForm() > > > return render_to_response('blogSite/contact_me.html', {'form': > > form, }) > > An empty string, or alternatively "." , is the correct thing to put. > Action is misleadingly named - it's actually just a URL. So this means > that the URL to POST to is the same one that originally rendered the > view. > > Your form is acting correctly - the 'connection refused' error is > presumably coming from the send_mail function inside your view, > perhaps you haven't got the mail settings correct. > -- > DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Contact form
Hi, i've created a contact fom based on the one in the docs but i don't know what to put as the action in the form element as part of template. I've got this template: {{ form.as_p }} but presuambly the data is being handled by the view. I'd appreciate any help, i tried it without an action and i got a 'Exception Value: (10061, 'Connection refused') ' error. Could someone please help? Thanks I've included a copy of the view below def contact_me(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] cc_myself = form.cleaned_data['cc_myself'] recipients = ['andrewkenyon...@gmail.com'] if cc_myself: recipients.append(sender) from django.core.mail import send_mail send_mail(subject, message, sender, recipients) return HttpResponseRedirect('/thanks/') else: form = ContactForm() return render_to_response('blogSite/contact_me.html', {'form': form, }) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
2 Questions about feeds
Hi, i'm developing a feed but i still have a couple of questionss. 1. I have this in my models: def get_absolute_url(self): return "/blog/%s/" % self.post_slug but the rss has the links down as: http://example.com/blog/post_3/, the blog/post_3/ is correct, how can i make sure its linked to right domain name? for example have it go to andrew.com/blog/post_3? 2. What does the element do? I've changed it a few times and i can't see what difference it makes? Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Feed arguments
Hello, i've trying to do an rss feed. I've had alook at the docs and i have the feeds set as: feeds = { 'latest': LatestEntries, 'categories': LatestEntriesByCategory, } but it doesn't say much about LatestEntriesByCategory, is this if i have multiple catergories? Is it possible to just have " 'latest': LatestEntries,", i tried that but i got: feed() takes at least 2 non-keyword arguments (1 given) I don't really feel i need a feed for individual catergories although i could do that way Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Counting results
Hi, I was wondering what is the simpliest way to count the number of objects returned in a QuerySet? Basically i have a blog and i want to count the number of comment relating to each post and display it, the blog posts are shown on a seperate page to the comments but i guess you would still have to create the query set in the posts view so that you can count the results. Thanks --~--~-~--~~~---~--~~ 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: Printing a cetain number of characters
thank you, i should have looked at filters. On 3 Aug, 23:42, Jonas Obrist wrote: > use: {{ object.body|slice:":30" }} > > When ideas fail wrote: > > Hi, If i am using something like {{object.body}} is it possible to > > limit the number of characters being printed out. So say you wanted 30 > > characters, it would print the 30 and ignore the rest. > > > Thanks, > > > Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Printing a cetain number of characters
Hi, If i am using something like {{object.body}} is it possible to limit the number of characters being printed out. So say you wanted 30 characters, it would print the 30 and ignore the rest. Thanks, Andrew --~--~-~--~~~---~--~~ 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: Log in problem
Ok, thanks, i will try that. As a thought could i not have something like: {% ifequal user.username "" %} login form {% else %} you are already logged in I don't know if that would work or not though. On 1 Aug, 01:30, Luke Seelenbinder wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > No it doesn't. That would be your problem, you would have to write a > custom backend if you wanted to not show the login form to already > logged-in visitors. > > Luke > luke.seelenbin...@gmail.com > > "I [may] disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > > > > When ideas fail wrote: > > I'm using (r'^login/$', 'django.contrib.auth.views.login', > > {'template_name': 'blogSite/login.html'}), for the view, so does that > > pass a request of not? > > > On 1 Aug, 01:09, Luke Seelenbinder > > wrote: > > Are you passing the "request" to it? > > That's the only thing I can think of that would mess it up, otherwise it > > looks good syntactically. > > > Luke > > > luke.seelenbin...@gmail.com > > > "I [may] disapprove of what you say, but I will defend to the death your > > right to say it." -- Voltaire > > > When ideas fail wrote: > >>>> Hi, i am using this template to log people in, but it seems to always > >>>> return the login form no matter what i do, i can be logged in or > >>>> logged out and it will still say i need to log in. > >>>> Does anyone know what might be happening. Any help would be > >>>> appreciated. > >>>> Thanks > >>>> {% extends "blogSite/index.html" %} > >>>> {% block content %} > >>>> {% if not request.user.is_authenticated %} > >>>> {% if form.errors %} > >>>> Sorry, that's not a valid > >>>> username or > >>>> password > >>>> {% endif %} > >>>> Please enter you user name and password below: > >>>> > >>>> >>>> for="username">Username: > >>>> >>>> value="" > >>>> id="username"> > >>>> >>>> for="password">Password: > >>>> >>>> name="password" value="" > >>>> id="password"> > >>>> > >>>> >>>> value="../login/" /> > >>>> > >>>> {% else %} > >>>> you are already logged in > >>>> {% endif %} > >>>> {% endblock %} > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkpzjIsACgkQXQrGVCncjPwajACfaas+qNkiozhiTDdnxJHFb0OB > SuoAn31FpPjrbeD4AlOqeOt5B6adzXd/ > =qG2H > -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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: Log in problem
I'm using (r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'blogSite/login.html'}), for the view, so does that pass a request of not? On 1 Aug, 01:09, Luke Seelenbinder wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Are you passing the "request" to it? > That's the only thing I can think of that would mess it up, otherwise it > looks good syntactically. > > Luke > > luke.seelenbin...@gmail.com > > "I [may] disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > > > > When ideas fail wrote: > > Hi, i am using this template to log people in, but it seems to always > > return the login form no matter what i do, i can be logged in or > > logged out and it will still say i need to log in. > > > Does anyone know what might be happening. Any help would be > > appreciated. > > > Thanks > > > {% extends "blogSite/index.html" %} > > > {% block content %} > > {% if not request.user.is_authenticated %} > > {% if form.errors %} > > Sorry, that's not a valid > > username or > > password > > {% endif %} > > Please enter you user name and password below: > > > > Username: > > > value="" > > id="username"> > > Password: > > > value="" > > id="password"> > > > > > > value="../login/" /> > > > > {% else %} > > you are already logged in > > {% endif %} > > > {% endblock %} > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkpzh8AACgkQXQrGVCncjPxJVACfQ68PD0uA2KGisU43jpzSLTbj > p78AnjVqqu37G8JTPQHI4Lnuatn++JuJ > =DCaK > -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Log in problem
Hi, i am using this template to log people in, but it seems to always return the login form no matter what i do, i can be logged in or logged out and it will still say i need to log in. Does anyone know what might be happening. Any help would be appreciated. Thanks {% extends "blogSite/index.html" %} {% block content %} {% if not request.user.is_authenticated %} {% if form.errors %} Sorry, that's not a valid username or password {% endif %} Please enter you user name and password below: Username: Password: {% else %} you are already logged in {% endif %} {% endblock %} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Stopping people loging in twice
Hello, if i am using this generic view in my urls.py? (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'myapp/login.html'}), Is there a way i can stopped people who are already logged in logging in again? Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
redirecting after login
I was wondering if there was a way to redirect users after login to the page they where looking at before they logged in. So if they where on "/blog/" when they logged in they could be redirected back and if they where on "/about_us/" they could be redirected to "/about_us/"? I'd appreciate any help, thanks --~--~-~--~~~---~--~~ 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: Submitting a form
Thank you On 30 July, 00:04, Adam Yee wrote: > Use the model's verbose field > namehttp://docs.djangoproject.com/en/dev/topics/db/models/#id2 > > On Jul 29, 3:55 pm, When ideas fail wrote: > > > Is there a way i can change the label for a field in the model form? > > > On 29 July, 21:44, When ideas fail wrote: > > > > Ok thanks seems to work now. > > > > On 29 July, 21:27, Daniel Roseman wrote: > > > > > On Jul 29, 9:17 pm, When ideas fail wrote: > > > > > > I've created a model form and I was wondering what the correct way to > > > > > save this was. I've tried adapting the view from the standard django > > > > > forms docs but maybe it should be different? > > > > > > This is what i have in my view (it says contact form but its a form > > > > > that should save contacts in a db): > > > > > > class ContactForm(ModelForm): > > > > > class Meta: > > > > > model = Contact > > > > > > def contact_view(request): > > > > > if request.method == 'Post': > > > > > form = ContactForm(request.POST) > > > > > if form.is_valid(): > > > > > contact= form.save() > > > > > return HttpResponseRedirect('/thanks/') > > > > > else: return HttpResponseRedirect('/error/') > > > > > > else: > > > > > form = ContactForm() > > > > > tags = Tag.objects.all() > > > > > return render_to_response('Site/contact.html', locals(), > > > > > context_instance=RequestContext(request)) > > > > > > And my template is like this: > > > > > > > > > > > {{ form.as_p }} > > > > > > > > > value="Submit" /> > > > > > > My understanding is that with this setup it should go to thanks/ if > > > > > the form is valid and error/ if it is not and it doesn't do either, > > > > > and it doesn't save or come back with any errors either . could > > > > > someone help me please? > > > > > > Thanks > > > > > There are two problems, but the main one is in the first line of your > > > > view. request.method == 'Post' will *never* be true, because the > > > > method (as in shown in your template) is all upper case. > > > > request.method == 'POST' should work. > > > > > Secondly, don't redirect to /error/. Drop that else clause altogether, > > > > and let the view fall through to the final render_to_response. This > > > > will redisplay the form with any errors. > > > > -- > > > > DR.- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Submitting a form
Is there a way i can change the label for a field in the model form? On 29 July, 21:44, When ideas fail wrote: > Ok thanks seems to work now. > > On 29 July, 21:27, Daniel Roseman wrote: > > > On Jul 29, 9:17 pm, When ideas fail wrote: > > > > I've created a model form and I was wondering what the correct way to > > > save this was. I've tried adapting the view from the standard django > > > forms docs but maybe it should be different? > > > > This is what i have in my view (it says contact form but its a form > > > that should save contacts in a db): > > > > class ContactForm(ModelForm): > > > class Meta: > > > model = Contact > > > > def contact_view(request): > > > if request.method == 'Post': > > > form = ContactForm(request.POST) > > > if form.is_valid(): > > > contact= form.save() > > > return HttpResponseRedirect('/thanks/') > > > else: return HttpResponseRedirect('/error/') > > > > else: > > > form = ContactForm() > > > tags = Tag.objects.all() > > > return render_to_response('Site/contact.html', locals(), > > > context_instance=RequestContext(request)) > > > > And my template is like this: > > > > > > > {{ form.as_p }} > > > > > value="Submit" /> > > > > My understanding is that with this setup it should go to thanks/ if > > > the form is valid and error/ if it is not and it doesn't do either, > > > and it doesn't save or come back with any errors either . could > > > someone help me please? > > > > Thanks > > > There are two problems, but the main one is in the first line of your > > view. request.method == 'Post' will *never* be true, because the > > method (as in shown in your template) is all upper case. > > request.method == 'POST' should work. > > > Secondly, don't redirect to /error/. Drop that else clause altogether, > > and let the view fall through to the final render_to_response. This > > will redisplay the form with any errors. > > -- > > DR. --~--~-~--~~~---~--~~ 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: Submitting a form
Is there a way i can change the label for a field in the model form? On 29 July, 21:44, When ideas fail wrote: > Ok thanks seems to work now. > > On 29 July, 21:27, Daniel Roseman wrote: > > > On Jul 29, 9:17 pm, When ideas fail wrote: > > > > I've created a model form and I was wondering what the correct way to > > > save this was. I've tried adapting the view from the standard django > > > forms docs but maybe it should be different? > > > > This is what i have in my view (it says contact form but its a form > > > that should save contacts in a db): > > > > class ContactForm(ModelForm): > > > class Meta: > > > model = Contact > > > > def contact_view(request): > > > if request.method == 'Post': > > > form = ContactForm(request.POST) > > > if form.is_valid(): > > > contact= form.save() > > > return HttpResponseRedirect('/thanks/') > > > else: return HttpResponseRedirect('/error/') > > > > else: > > > form = ContactForm() > > > tags = Tag.objects.all() > > > return render_to_response('Site/contact.html', locals(), > > > context_instance=RequestContext(request)) > > > > And my template is like this: > > > > > > > {{ form.as_p }} > > > > > value="Submit" /> > > > > My understanding is that with this setup it should go to thanks/ if > > > the form is valid and error/ if it is not and it doesn't do either, > > > and it doesn't save or come back with any errors either . could > > > someone help me please? > > > > Thanks > > > There are two problems, but the main one is in the first line of your > > view. request.method == 'Post' will *never* be true, because the > > method (as in shown in your template) is all upper case. > > request.method == 'POST' should work. > > > Secondly, don't redirect to /error/. Drop that else clause altogether, > > and let the view fall through to the final render_to_response. This > > will redisplay the form with any errors. > > -- > > DR. --~--~-~--~~~---~--~~ 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: Submitting a form
Ok thanks seems to work now. On 29 July, 21:27, Daniel Roseman wrote: > On Jul 29, 9:17 pm, When ideas fail wrote: > > > > > I've created a model form and I was wondering what the correct way to > > save this was. I've tried adapting the view from the standard django > > forms docs but maybe it should be different? > > > This is what i have in my view (it says contact form but its a form > > that should save contacts in a db): > > > class ContactForm(ModelForm): > > class Meta: > > model = Contact > > > def contact_view(request): > > if request.method == 'Post': > > form = ContactForm(request.POST) > > if form.is_valid(): > > contact= form.save() > > return HttpResponseRedirect('/thanks/') > > else: return HttpResponseRedirect('/error/') > > > else: > > form = ContactForm() > > tags = Tag.objects.all() > > return render_to_response('Site/contact.html', locals(), > > context_instance=RequestContext(request)) > > > And my template is like this: > > > > > {{ form.as_p }} > > > /> > > > My understanding is that with this setup it should go to thanks/ if > > the form is valid and error/ if it is not and it doesn't do either, > > and it doesn't save or come back with any errors either . could > > someone help me please? > > > Thanks > > There are two problems, but the main one is in the first line of your > view. request.method == 'Post' will *never* be true, because the > method (as in shown in your template) is all upper case. > request.method == 'POST' should work. > > Secondly, don't redirect to /error/. Drop that else clause altogether, > and let the view fall through to the final render_to_response. This > will redisplay the form with any errors. > -- > DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Submitting a form
I've created a model form and I was wondering what the correct way to save this was. I've tried adapting the view from the standard django forms docs but maybe it should be different? This is what i have in my view (it says contact form but its a form that should save contacts in a db): class ContactForm(ModelForm): class Meta: model = Contact def contact_view(request): if request.method == 'Post': form = ContactForm(request.POST) if form.is_valid(): contact= form.save() return HttpResponseRedirect('/thanks/') else: return HttpResponseRedirect('/error/') else: form = ContactForm() tags = Tag.objects.all() return render_to_response('Site/contact.html', locals(), context_instance=RequestContext(request)) And my template is like this: {{ form.as_p }} My understanding is that with this setup it should go to thanks/ if the form is valid and error/ if it is not and it doesn't do either, and it doesn't save or come back with any errors either . could someone help me please? Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---