Re: Automatically direct unauthenticated users to homepage

2011-11-15 Thread Colin Bean
On Tue, Nov 15, 2011 at 8:25 AM, CrabbyPete  wrote:
> I have a site with lots of views. When someone comes to my site and is
> not logged in I direct them to the homepage to login. However a user
> could type in a whole url for a view and it will go there and cause an
> error because the view expects the user to be logged in. I could put
> logic in every view to see if the user is logged in but it seems
> redundant. Is there a way to force anonymous users to the home even if
> they type in a full url to a specific view
>
> --
> 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 can use middleware to redirect all unauthenticated users to your
login page, something like this:

http://stackoverflow.com/questions/3214589/django-how-can-i-apply-the-login-required-decorator-to-my-entire-site-excludi

Colin

-- 
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: Deleting a model object then returning it

2011-08-15 Thread Colin Bean
On Mon, Aug 15, 2011 at 5:29 PM, Kevin Anthony
 wrote:
> Accoding to the documentation all i need to do is
> object = someobject.objects.all().filter(somefield=somevalue)
> print object
> object.delete()
> print object
>
> and theoretically, object should be unchanged, since according to the
> documentation:
> Issues a SQL DELETE for the object. This only deletes the object in the
> database; the Python instance will still be around, and will still have data
> in its fields.
> but when i run this command
> i get
> []
> []
> so the python instance looses it's data. Is there another way to delete the
> data from SQL while still being about to use it in Python?
> because after i delete it, i need to serialize the data to JSON
> Thanks
> Kevin Anthony
>
>
> --
> 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.
>

Hi Kevin,

It looks like you're calling delete on a queryset rather than
individual objects.  I think [i.delete() for i in object] would do
what you want, although I haven't tested it.

Colin

-- 
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: get_object_or_404

2010-11-15 Thread Colin Bean
On Sun, Nov 14, 2010 at 9:23 PM, Akn  wrote:
> Hi,
> I would like to use get_object to retrieve an object form the
> database, but if the object does not exist I do not want to display an
> error page(404). Is there any command that does that.
>
> ob=get_object(Table,x=y)
> if not ob
>    
>
> --
> 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.
>
>

The answer is in your subject line :)

http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#get-object-or-404

Colin

-- 
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: virtualenv used with mod_wsgi

2010-09-15 Thread Colin Bean
Have you tried the steps described here:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments ?

Colin

On Tue, Sep 14, 2010 at 10:44 PM, Jagdeep Singh Malhi
 wrote:
> I am try to use Multiple version of Django on same machine.
> I am using the Virtual Python Environment builder (virtualenv 1.5). I
> am able to install this using documentation.
> http://pypi.python.org/pypi/virtualenv#downloads
>
> but now i am facing problem with mod-wsgi.
> i am not able to understand how mod-wsgi work with virtualenv.
> when i try this, it use the same python , not created by virtualenv
>
> file used for virtualenv is:- django.wsgi
> {
> import os
> import sys
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'djangocms.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
> sys.path.append('/home/jagdeep/')
> }
>
> Actually, I want mod-wsgi is working with different version of Django.
> Now, what i can do?
>
> --
> 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.
>
>

-- 
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: Database relations concepts

2010-02-19 Thread Colin Bean
On Thu, Feb 18, 2010 at 11:31 PM, Timothy Kinney
 wrote:
> This is a fabulous response, Peter. Thank you very much for making this so
> clear. The samurai_set is a revelation for me as well. I see now that I
> should look more carefully at the methods available for the models.
>
> If I can ask another question about this same topic, is there a way to store
> a list variable in a model as a field (without creating another table)? For
> example, I want to store a list of the exits for a province (one can only
> exit to a bordering province). Is there an SQL field that lets me do this so
> I can just do a "if province.has_exit() ..." check? Or do I need to
> cross-reference it to a table called Exits which has multiple exits
> associated with each province.
>
> There will only ever be 61 provinces and there is no province with more than
> 6 or 7 exits. With such a small set, I doubt there would be database
> efficiency reasons to use a table. So I'd prefer a list if possible.
>
> Cheers.
>
> -Tim
>
>

Take a look at the CommaSeparatedInteger Field:
http://docs.djangoproject.com/en/dev/ref/models/fields/#commaseparatedintegerfield

Colin

-- 
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: Django/GoDaddy

2009-11-15 Thread Colin Bean
On Sun, Nov 15, 2009 at 6:15 AM, mkumm  wrote:
> I recently took on a new project for a new client where I was forced
> into using a GoDaddy Virtual Server (literally it was a deal breaker).
> Anyway I have configured about 1/2 dozen servers to run django - but I
> am stumped on this. I am looking for help from anyone who may have
> this experience.
> Server: CentOS 5
> Python 1.4
> Django 1.1.1
>
> 1. mod_wsgi was not available so I tried to compile from source. The
> apache apsx was not available and other attempts to config failed. I
> grabbed the apache source-dev to get the apsx, but the config failed.
> No problem I moved on to mod_python
>
> 2. Attempted to launch the app and got an error that there was no
> pysqlite2, they had the previous version. I pulled the latest version
> but again had failed at config. I moved to mysql and again the version
> that was available on yum was too old and trying to compile by the
> newer version failed at config.
>
> Their technical support person was mean and less helpful than a sharp
> stick.
>
> In short: I can't compile any of the necessary components, all of the
> yum updates are too old. My only other options for server are Cent OS
> 4 and Fedora Core 7 (I come from the Debian World mostly). Any
> recommendations?
>
> --
>
> 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=.
>
>
>

If it's a normal CentOS 5 install you should be able to yum install
httpd-devel to get aspx.  If your pysqlite build is failing because of
prerequisites, there might be other development packages that you
could install with yum (python-devel at the very least, probabaly
sqlite-devel too).  'yum search' is helpful for finding out what
packages are out there.

Also are you really running python 1.4?

Colin

--

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=.




Re: SOLVED Is there a way to just submit a simple form? -- Mis-nested tags break things!

2009-10-30 Thread Colin Bean

On Fri, Oct 30, 2009 at 7:00 PM, Mike Ramirez  wrote:
> On Friday 30 October 2009 18:44:02 sstein...@gmail.com wrote:
>> Normally validation is the first thing I check but the w3c validator
>> can't validate localhost addresses so I had to use the old "cut &
>> past" method to submit my HTML.
>>
>> Thanks,
>>
>> S
>>
>
> If it's important to you, you can install  the validator to run on your
> machine, through a web server.  The validator itself is open sourced, so you
> can make fixes to it, if you find any.  The link provide will take you to the
> instructinons on dling the source and then leads you to the install and
> developer information.
>
> Source: http://validator.w3.org/source/
>
>
> Mike
>
> --
> Do nothing unless you must, and when you must act -- hesitate.
>

Cool, never realized that about the validator code.
The web developer toolbar extension for firefox will upload a local
page to the validator for you:
https://addons.mozilla.org/en-US/firefox/addon/60

Colin

--~--~-~--~~~---~--~~
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: Model instance refreshing

2009-08-17 Thread Colin Bean

On Mon, Aug 17, 2009 at 1:31 PM, mettwoch wrote:
>
> Hi,
>
> I use a session to store several instances of different models coming
> from a:
>
> some_model.objects.get(pk = some_pk)
>
> When the data in the db changes the model instances in the session
> still contain the old data. What would be a good strategy to make
> shure that all objects in a session get fresh data on every request?
>
> Marc
>
> PS: Hopefully going live in 2 weeks ... to be continued
> >
>

I would only store the PK in the session and use it to get a new
instance of the model with every request.

Colin

--~--~-~--~~~---~--~~
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: Views runs twice when using custom context processor

2009-05-22 Thread Colin Bean

On Fri, May 22, 2009 at 7:23 AM, eightflower  wrote:
>
> It appears that {% thumbnail %} tag from sorl-thumbnail app is causing
> this. When my context processor is off,
> thumbnail just does not have anything to do because it has no context.
> >
>

Are the image tags pointing to the correct path?  If you have
something like , then your browser will
make a second request to your view trying the fetch the image.  This
wouldn't happen with curl, if it's not fetching any of the resources
in the page.
You could tell if this is happening using TamperData, or just
examining your server's request logs / console output.

Colin

--~--~-~--~~~---~--~~
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 works directly in browser, but not in DJango... Why???

2009-05-19 Thread Colin Bean

On Tue, May 19, 2009 at 11:44 AM, Alex Gaynor  wrote:
>
>
> On Tue, May 19, 2009 at 1:42 PM, Social Network in DJango
>  wrote:
>>
>> I put the below code to embed an mp3 file in an html page in an html
>> file and pointed my browser to it.  It works.
>>
>> I then try
>>     url(r'^$','django.views.generic.simple.direct_to_template',
>> {"template": "wimpybutton.html"}, name="home"),
>>
>> Then, http://127.0.0.1:8080/
>>
>> I do not see the button. I view page source.  The page source is
>> identical to the below.
>>
>> Please let me know how I can see the button and hear the music from
>> DJango if I already can do so in html.
>>
>> Thank you in advance,
>>
>> Jonathan
>>
>>
>>
>>
>> 
>> > codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/
>> swflash.cab#version=8,0,0,0" width="35" height="35"
>> id="wimpybutton288">
>> 
>> 
>> 
>> 
>> 
>> 
>> > bgcolor="#FF" loop="false" menu="false" quality="high"
>> name="wimpybutton288" align="middle" allowScriptAccess="sameDomain"
>> type="application/x-shockwave-flash" pluginspage="http://
>> www.macromedia.com/go/getflashplayer" />
>> 
>> 
>>
>
> The browser probably isn't rendering it because there are no starting 
> tag, or  tag, which are required by the spec AFAIK.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

Also, your embed code is trying load several things (flash file, MP3
file) from a "file:///" url.  Your browser might have a problem with
this (cross domain restrictions).  I'd try serving all of your static
resources through django (of course you'll want to use something else
for static media when if you put this into production).

Colin

--~--~-~--~~~---~--~~
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: Limiting the queryset for a foreign key field in the admin change_list view

2009-05-14 Thread Colin Bean

On Thu, May 14, 2009 at 5:26 PM, Margie  wrote:
>
> Sorry for the length of this - I hope someone knowledgable about ajax
> has a minute to take a look, I've been working on it for awhile.
> George - if you are reading this - this is my attempt to do the jquery/
> ajax that you recommended a few days back when I posted a more general
> question.
>
> Ok - here's the high level: I have a Task model that contains an owner
> field.  In the admin change_list view for the task, I am am trying to
> create a jquery ajax request that will override the queryset for the
> task's owner  field so that it contains the users returned by a GET
> request to  http://mysite.com/admin/taskmanager/task/get_owner_queryse
> /.
>
> In other words, I don't want the queryset for owner to contain all
> Users in the system, I want it to just contain the users that are
> specified in the task's 'resources' field, which is a ManyToMany
> field.
>
> Note: all code is also at http://dpaste.com/44241 - more readable
> there.
>
> I'm trying hard to leverage the admin interface, which I think will
> work for me if I can just figure out how to configure it with some
> spiffy jquery/ajax.
>
> I'm doing this by overriding formfield_for_foreignkey () so that it
> uses a special OwnerSelectWidget for the 'owner' field, like this:
>
>
>
>    def formfield_for_foreignkey(self, db_field, request, **kwargs):
>        if db_field.name == "owner":
>            kwargs["widget"] = OwnerSelectWidget()
>            return db_field.formfield(**kwargs)
>        return super(TaskAdmin, self).formfield_for_foreignkey
> (db_field, request, **kwargs)
>
> My OwnerSelectWidget looks like this:
>
> class OwnerSelectWidget(widgets.Select):
>
>    class Media:
>        css = {}
>        js = (
>            'js/jquery.js',
>        )
>
>    def render(self, name, value, attrs=None):
>        rendered = super(OwnerSelectWidget, self).render(name, value,
> attrs)
>        return rendered + mark_safe(u'''
>            
>                $('#id_%(name)s').mousedown(function() {
>                            $.getJSON("get_owner_queryset/
> NEED_TASK_ID_HERE",
>                                      function(data) {
>                                        var options = '';
>                                        for (var i = 0; i <
> data.length; i++) {
>                                           /* set options based on
> data - not quite sure how */
>                                        $('#id_%(name)s').html
> (options);
>                                      })
>                            })
>            
>            ''' % {'name': name, })
>
> My code that services the GET is in my admin.py file and looks like
> this:
>
> class TaskAdmin(admin.ModelAdmin):
>
>    def __call__(self, request, url):
>        if url is None:
>            pass
>        else:
>            match = re.search('get_owner_queryset/(\d+)', url)
>            if  match:
>                return self.getOwnerQuerySet(match.group(0))
>            else:
>                return super(TaskAdmin, self).__call__(request, url)
>
>    def getOwnerQuerySet(self, taskId):
>        task = Task.objects.get(taskId)
>        resourcesToReturn = task.resources.all() # resources are users
>        return HttpResponse(simplejson.dumps(resourcesToReturn),
> mimetype='application/json')
>
>
> I have a couple problems (so far that I know of).
>
> 1. In line 8 of the render() method, where I have NEED_TASK_ID_HERE,
> I'm trying to figure out how I get the task id.  It seems like at
> this  point in the code  I don't have access to that.  The id is
> output as part of the change_list  form, but it doesn't have an id
> associated with it.  What is the best approach to take?
>
> 2. In getOwnerQuerySet(), I don't think what I'm returning is
> correct.  When I play around in pdb and create a User queryset and
> then try to call simplejson.dumps() on it:
>   resources = User.objects.all()
>   return HttpResponse(simplejson.dumps(resourcesToReturn),
> mimtype='application/json')
> I get the error:
>
>  *** TypeError: [, ] is not JSON serializable
>
> So I think I am not really returning the data correctly.  And when I
> run the app
> this way, I get a 500 INTERNAL SERVER ERROR.
>
> 3. Once I do manage to return whatever it is that I'm supposed to
> return (ie,  question 2), I'm not quite sure what it is going to look
> like when it gets back to the jquery callback function.  I have a
> little for loop in there, but I think I need to come up name/value
> pairs.  If the GET is returning a list of user names, where does the
> value come from?
>
>
> Ok - sorry for the length of this but I've been working for awhile now
> on it and could really use some pointers from someone knowledgable out
> there.  I know there is doc on this simplejson stuff, but the first
> time around, it's just hard to make sense of it all.
>
> Margie
> >
>

Re: your second question, you'll want to use django's built in 

Re: disable django cache

2009-05-14 Thread Colin Bean

On Thu, May 14, 2009 at 6:53 PM, online  wrote:
>
> This is my code
>
>
> from django.http import HttpResponse
> from django.template import Context, loader
> from django.shortcuts import render_to_response
> from django.views.decorators.cache import cache_control
> @cache_control(no_cache=True)
> def index(request):
>        #t = loader.get_template('home.html')
>        return render_to_response('home.html')
>
>
> i don't think it was browser cache. I have tried both IE and firefox.
>
>
> Whatever i changed 'home.html' to other page i always get the same
> result.
>
>
> Thanks
>

What are the TEMPLATE_DIRS that you're using in your settings file? Do
they point to the same file you're editing?  Any chance you copied the
project from somewhere else and it's loading the templates from the
original location?

Colin

--~--~-~--~~~---~--~~
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: Signals giving: global name 'MyModel' is not defined

2009-05-14 Thread Colin Bean

On Thu, May 14, 2009 at 6:48 AM, phoebebright  wrote:
>
> Have been at this now for some hours and still can't see the wood for
> the trees.  Failed to get two signals working - one called on pre_save
> to keep an audit trail of one field on a model (didn't implemenet the
> Audit.py version in the wiki as more complex than I needed).  The
> other to create some default records in a related table.  Both are
> failing with the same error and I suspect I am going to kick myself
> when someone points out the obvious, but here goes.
>
> Model.py
>
> (simplified)
>
> class Version(models.Model):
>
>        version_no = models.CharField(_('ver'), max_length=10, unique=True)
>        name = models.CharField(_('name'), max_length=50, unique=True)
>
> class VersionDocs(models.Model):
>
>        version = models.ForeignKey('Version')
>        doc_content = models.TextField(_('content'))
>
>
> class VersionDocsVer(models.Model):
>
>        doc = models.ForeignKey('VersionDocs')
>        doc_content = models.TextField(_('content'))
>
>
> pre_save.connect(keep_version, sender=VersionDocs)
> post_save.connect(default_docs, sender=Version)
>
>
>
> signals.py
>
> (simplified)
>
> from devcycle.models import *
>
> def default_docs(instance, **kwards):
>
>        try:
>                doc = VersionDocs.objects.filter(version=instance.id)
>
>        except:
>
>            
>
> def keep_version(instance, **kwargs):
>
>        print 'version instance =',instance.id
>        original = VersionDocs.objects.get(id=instance.id)
>
>        
>
>
>
> Using Django version 1.1 beta 1,
>
>
>
>
>
> >
>


What error were you getting?

Those signals both take a "sender" argument as the first instance, so
you might try something like:

def keep_version(sender, instance, **kwargs):


"Sender" will be class of the model that's being saved.

Colin

--~--~-~--~~~---~--~~
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: Template issue

2009-05-07 Thread Colin Bean

On Thu, May 7, 2009 at 2:13 AM, 83nini <83n...@gmail.com> wrote:
>
> Hi guys,
>
> I have a template.surf which i'm trying to style with CSS external
> file, but it's not working! any idea how to deal with .surf templates?
> and how to style them with the CSS external files?
> internally working, externally...NOT!
>
> cheers.
> >
>

I don't know what a .surf template is, but can you access the
stylesheet in your browser at the URL your template is using?  If you
want further help debugging that, you'll need to provide some
information about your setup and how you're serving static media.

Colin

--~--~-~--~~~---~--~~
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: Really really basic,,, use of @ sign in code

2009-05-05 Thread Colin Bean

On Tue, May 5, 2009 at 3:56 PM, dartdog  wrote:
>
> When you're starting out it is often the simplest stuff
> I'm reading some code and I see tow blocks with @permalink at the
> start, it looks to me that this s just a comment (that requires no
> termination i.e. one word??)  but I just wanted confirmation, believe
> it or not it is about impossible to search the docs or groups for @
> sign!!! much less @ sign usage or comments!! My books and doc's show
> many other methods but not �...@comment!!
> >
>

This is really a general python question, so a group like
comp.lang.python might be a more appropriate place to ask it.  But
what you're seeing is a decorator:
http://docs.python.org/glossary.html#term-decorator


Colin

--~--~-~--~~~---~--~~
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: Authenication for django.views.generic Views

2009-04-16 Thread Colin Bean

On Thu, Apr 16, 2009 at 8:25 AM, Col Wilson
 wrote:
>
> I'm using generic views to render my pages
> (django.views.generic.date_based, django.views.generic.list_detail
> etc) and they're very handy.
>
> However, the app I'm trying to build would like a security and on
> reading the "User Authentication in Django" document, it just talks
> about adding authentication to the views.
>
> Generic views of course are buried in the django installation
> directories and you don't want to go messing about in there, so it's
> not obvious to me how I can do that.
>
> Can someone give me a hand please?
> >
>

Middleware would be one option.  You could write a process_view
function that checks request.user and redirects requests with no
authentication.  This will all happen before the view gets called.
More here:

http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-view

Colin

--~--~-~--~~~---~--~~
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: Linking Back to Home Page from Template

2009-04-10 Thread Colin Bean

Take a look at the reverse() function and the "url" template tag:
http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url

The "url" tag is what you want to generate a link in your template
based on one of your URL patterns.

Colin

On Fri, Apr 10, 2009 at 11:50 AM, Anthony  wrote:
>
> Hi Everyone,
>
> This is really basic and I tried looking up this question since it
> can't be a new one, but the closest thread I found was this one:
>
> http://groups.google.com/group/django-users/browse_thread/
> thread/d2524403e13fcd22/515358199feebc68?lnk=gst=url+home
> +page#515358199feebc68">Home page question thread
>
>
> I'm trying to set up my templates so that I have a link back to my
> home page.  I've got the following URL conf set up so that it points
> to "http://www.mysite.com":
>
> url(r'^$', myapp.views.home, name = "url-home")
>
>
> Is there a way to de-reference "url-home" from within my templates so
> I don't have to hard code my home page?
>
> Thanks!
> Anthony
>
> >
>

--~--~-~--~~~---~--~~
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: referencing a specific item in a list...

2009-04-09 Thread Colin Bean

On Thu, Apr 9, 2009 at 3:23 PM, Walt  wrote:
>
> After extensive searching, I'm still unable to find a way to reference
> individual items in a list without using a for loop.
>
> For example, I have this basic code in my views.py:
>
>    project_list = Project.objects.all().order_by('-id')[:6]
>
>    t = loader.get_template('portfolio/index.php')
>    c = Context({
>        'project_list' : project_list,
>    })
>
> Now, in my template file I want to be able reference the six
> different elements in the list directly, without having to loop
> through them. How can I do this?
>
> I've tried project_list[1] but that just errors out.
>
> Thanks,
> Walt
>
> -~
>
> >
>

The default "dot" lookup works with array indices, so you can do
project_list.1
project_list.2, etc.

From:
http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context

Colin

--~--~-~--~~~---~--~~
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: troubleshooting runserver

2009-03-20 Thread Colin Bean

On Fri, Mar 20, 2009 at 11:28 AM, QUILAD  wrote:
>
> I'm starting my first Django python project.  Running on Linux RH4
> server.
>
> When I run
> manage.py runserver 10.112.112.12:8080
>
> I get:
>
> Validating models...
> 0 errors found
>
> Django version 1.0.2 final, using settings 'repairwf.settings'
> Development server is running at http://10.112.112.12:8080/
> Quit the server with CONTROL-C.
>
>
> But when I go to my pc browser to pull up http://10.112.112.12:8080
> I get the Internet Explorer cannot display the webpage
>
> Any recommendations on how to resolve or troubleshoot this?
>
> >
>

Firewall rules perhaps?  You could see if running the dev server on
port 80 gets through.

Colin

--~--~-~--~~~---~--~~
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: Is safe unsafe?

2009-02-23 Thread Colin Bean

On Mon, Feb 23, 2009 at 12:03 PM, Michael Repucci  wrote:
>
> I'm certainly worried about both, but I would like the users to be
> able to add JavaScript. Changes to the site will actually have to be
> monitored for offensive content (including both JavaScript and
> offensive language), so hopefully such content wouldn't be up for very
> long. But I was just worried that an attack on the server could (in
> theory) be made before the site manager had a chance to monitor, and
> remove, an offending script.
>
> But perhaps I'm going about this in completely the wrong way. I'm by
> no means a professional web developer; I'm completely self-taught. So
> any further advice you could give would be great. Thanks!
>

Malicious javascript could be used to steal users' cookies or to
redirect the page to a different site.  I doubt you'd want to risk
either of these things on your site.  I'd recommend you read up on
cross site scripting (XSS) to get a better idea of the risk involved.

Colin


> On Feb 23, 2:48 pm, Mark Jones  wrote:
>> Kind of sucks that you are worried about your server, but not worried
>> about the people that might use your site.
>>
>> I'd answer your question regarding JS except for the fact I think the
>> server and the clients should be safe for the general public, and I
>> don't want to make it that easy on you.  Allowing some script kiddie
>> to load JS into a field that will play back on someone else's machine
>> is reprehensible, even if those users aren't smart enough to install
>> noscript.
>>
>> On Feb 23, 1:32 pm, Michael Repucci  wrote:
>>
>> > Hi Django'ers, this will probably sound like a silly question, but
>> > normally I haven't had to think about server security (that's been
>> > someone else's job). However, on my current project I do need to
>> > consider this, and I just wanted to double-check that I understand the
>> > risks of using the "safe" tag in HTML templates.
>>
>> > I've got users that I shouldn't entirely trust, who have access to a
>> > TextField in a model, and that field is displayed in the resultant
>> > HTML with the safe filter. Now, I understand that that means the user
>> > could put JavaScript (or similar) in this field, and it will be
>> > triggered when the page loads. But this doesn't present a threat to
>> > the server security does it? PHP includes won't be interpreted, so
>> > that's not a problem, and JavaScript doesn't have access to the server
>> > file system, right? I'm just not sure whether there is potential HTML
>> > code that could be used to actually damage the server, access its
>> > files, or cause a DoS attack.
>>
>> > Any help would be greatly appreciated! 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
-~--~~~~--~~--~--~---



Re: WYSIWYG Image upload challenge

2009-02-19 Thread Colin Bean

On Thu, Feb 19, 2009 at 7:18 AM, phoebebright <phoebebright...@gmail.com> wrote:
>
> Where do I do the compare though as the headers are not being returned
> - the file is being downloaded so I don't get to see what might be
> different.  (Using Firefox Firebug NET option - very helpful
> otherwise).  It's the browser making the decision about how to handle
> the request (Isn't it?).
>


The headers are still being sent, even if your browser prompts you to
download a file.  If the Firebug NET option is not able to show the
request, try the TamperData extension.  It should provide details for
every request that your browser sends in a separate window.

Colin


> On Feb 18, 8:23 pm, Colin Bean <ccb...@gmail.com> wrote:
>> On Wed, Feb 18, 2009 at 10:50 AM, phoebebright
>>
>>
>>
>> <phoebebright...@gmail.com> wrote:
>>
>> > The javascript makes a call to this view on submitting the form that
>> > uploads the image.
>>
>> > def uploadimage(request):
>> >try:
>> >upload_full_path = settings.CONTENT_IMAGES
>>
>> >upload = request.FILES['image']
>> >dest = open(os.path.join(upload_full_path,
>> > upload.name), 'wb+')
>>
>> >for chunk in upload.chunks():
>> >dest.write(chunk)
>>
>> >dest.close()
>>
>> >result='{status:"UPLOADED",image_url:"%s%s"}' %
>> > (settings.CONTENT_IMAGES_URL, upload.name)
>>
>> >return_data = HttpResponse(result,mimetype='Content-
>> > Type: text/
>> > html')
>>
>> >except Exception, e:
>> >return_data = HttpResponse("Error in uploading image")
>>
>> >return_data.flush()
>>
>> >return return_data
>>
>> > In Firefox/Mac it uploads the file and returns
>> > "{status:"UPLOADED",image_url:"/site_media/content/
>> > dalston_cranes.JPG"}" to javascript which tells javascript all went
>> > well.  In IE/Safari the file is uploaded successfully but the above
>> > text is downloaded as a file called something like 2s6OP6WO(2).part so
>> > control doesn't return to the javascript.  Have applied a similar
>> > program in PHP and it works fine. Tried different mime types and tried
>> > to trace what is going on but without progress.
>>
>> > Phoebe
>>
>> > On Feb 18, 2:33 pm, Almost George <almostgeo...@almostexciting.com>
>> > wrote:
>> >> On Feb 18, 5:36 am, phoebebright <phoebebright...@gmail.com> wrote:
>>
>> >> > There is something different about the way django is handling to 
>> >> > response to php I think.
>>
>> >> I use the YUI Rich Editor in admin, and have no problems. I know
>> >> debugging isn't as easy in IE as others, but do your best to find out
>> >> the exact response (mostly, response headers) that's being sent to the
>> >> browser. Also, could you clarify the above "response to PHP"
>> >> statement? Perhaps explaining the technical details of what's going on
>> >> would be of some help?
>>
>> Tools like Tamper Data (firefox extension) or WebScarab (standalone
>> proxy) let you examine all the header values sent with an HTTP
>> request.   You could use this to compare the exact headers returned by
>> PHP vs. Django, and fix any differences in the Django response.
>>
>> Colin
> >
>

--~--~-~--~~~---~--~~
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: WYSIWYG Image upload challenge

2009-02-18 Thread Colin Bean

On Wed, Feb 18, 2009 at 10:50 AM, phoebebright
 wrote:
>
> The javascript makes a call to this view on submitting the form that
> uploads the image.
>
> def uploadimage(request):
>try:
>upload_full_path = settings.CONTENT_IMAGES
>
>upload = request.FILES['image']
>dest = open(os.path.join(upload_full_path,
> upload.name), 'wb+')
>
>for chunk in upload.chunks():
>dest.write(chunk)
>
>dest.close()
>
>result='{status:"UPLOADED",image_url:"%s%s"}' %
> (settings.CONTENT_IMAGES_URL, upload.name)
>
>return_data = HttpResponse(result,mimetype='Content-
> Type: text/
> html')
>
>except Exception, e:
>return_data = HttpResponse("Error in uploading image")
>
>return_data.flush()
>
>return return_data
>
> In Firefox/Mac it uploads the file and returns
> "{status:"UPLOADED",image_url:"/site_media/content/
> dalston_cranes.JPG"}" to javascript which tells javascript all went
> well.  In IE/Safari the file is uploaded successfully but the above
> text is downloaded as a file called something like 2s6OP6WO(2).part so
> control doesn't return to the javascript.  Have applied a similar
> program in PHP and it works fine. Tried different mime types and tried
> to trace what is going on but without progress.
>
> Phoebe
>
>
> On Feb 18, 2:33 pm, Almost George 
> wrote:
>> On Feb 18, 5:36 am, phoebebright  wrote:
>>
>> > There is something different about the way django is handling to response 
>> > to php I think.
>>
>> I use the YUI Rich Editor in admin, and have no problems. I know
>> debugging isn't as easy in IE as others, but do your best to find out
>> the exact response (mostly, response headers) that's being sent to the
>> browser. Also, could you clarify the above "response to PHP"
>> statement? Perhaps explaining the technical details of what's going on
>> would be of some help?
> >
>


Tools like Tamper Data (firefox extension) or WebScarab (standalone
proxy) let you examine all the header values sent with an HTTP
request.   You could use this to compare the exact headers returned by
PHP vs. Django, and fix any differences in the Django response.

Colin

--~--~-~--~~~---~--~~
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 doesn't like serving a view to Apache

2009-01-21 Thread Colin Bean

On Wed, Jan 21, 2009 at 12:18 PM, joshuajonah <j...@joshuajonah.com> wrote:
>
> Why wouldn't it at least except?
>
> On Jan 21, 3:17 pm, joshuajonah <j...@joshuajonah.com> wrote:
>> It doesn't even get to start the session:http://dpaste.com/111586/
>>
>> On Jan 21, 3:14 pm, joshuajonah <j...@joshuajonah.com> wrote:
>>
>> > It works and outputs what it should:http://dpaste.com/111584/
>>
>> > I'll try commenting out some lines and seeing how far it gets.
>>
>> > On Jan 21, 3:10 pm, Colin Bean <ccb...@gmail.com> wrote:
>>
>> > > On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah <j...@joshuajonah.com> 
>> > > wrote:
>>
>> > > > I'm having an issue getting Apache to serve a view. It appears to work
>> > > > fine through shell (http://dpaste.com/111549/), however when viewed
>> > > > through a web browser, it loads indefinitely.
>>
>> > > > Here is the view:http://dpaste.com/111551/
>>
>> > > > Any ideas guys?
>>
>> > > What's the contents of the response in the shell?  Perhaps the shell
>> > > version encounters an exception and returns, while the server version
>> > > gets hung up on something further along (looks like you're accessing a
>> > > remote session, which might take a while).  Either way, I'd put some
>> > > debugging statements in your view and see how far it gets...
>>
>> > > Colin
> >
>

How long were you waiting for the view to return?  I'm not familiar
with the library you're using, but if it's timing out on the network
access it might take a while before it generates an exception.

It does look like accessing your remote session under apache is
causing the problem (your shell test was done from the same box as the
apache server, correct?).  If you're using mod_python, your code is
stuck running under the 'apache' user... could that be a problem?  You
could start a shell with sudo -u apache and run your view test again
to check.

Beyond that, all I can recommend is doing something to examine your
network traffic and see if there's anything that points to a problem.
Might be worth checking the apache error log too, if you haven't
already.

Colin

--~--~-~--~~~---~--~~
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 doesn't like serving a view to Apache

2009-01-21 Thread Colin Bean

On Wed, Jan 21, 2009 at 11:34 AM, joshuajonah  wrote:
>
> I'm having an issue getting Apache to serve a view. It appears to work
> fine through shell (http://dpaste.com/111549/), however when viewed
> through a web browser, it loads indefinitely.
>
> Here is the view: http://dpaste.com/111551/
>
> Any ideas guys?
> >
>


What's the contents of the response in the shell?  Perhaps the shell
version encounters an exception and returns, while the server version
gets hung up on something further along (looks like you're accessing a
remote session, which might take a while).  Either way, I'd put some
debugging statements in your view and see how far it gets...

Colin

--~--~-~--~~~---~--~~
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: xml -> django model

2008-12-23 Thread Colin Bean

On Tue, Dec 23, 2008 at 12:11 PM, dick...@gmail.com  wrote:
>
> i'm working on a simple concept i'm sure others have solved, but i
> can't get it.
>
> basically, given some  input, i parse it, find which objects to
> create, and do it.
>
> so with a model:
>
> class Foo(models.Model):
>  name = models.CharField(max_length=20)
>
> and input xml of bar
>
> my view would parse that xml, find the Element Request name "Foo",
> instantiate Foo, set the "name" value to bar, and save it.
>
> import myproject.test.models as test_models
> createobj = getattr(test_models, "Foo")
> setattr(createobj, "name", "bar")
> createobj.save()
>
> the current code there above gives me
>
> unbound method save() must be called with Foo instance as first
> argument (got nothing instead)
>
> i've also tried
> save =  getattr(createobj, "save")
> save(createobj)
>
> unbound method save() must be called with Foo instance as first
> argument (got ModelBase instance instead)
>
> i've probably gone about the whole problem all wrong, so feel feel to
> correct this approach if it is way off base
>
> >
>

Does this work?

from myproject.test.models import Foo
f = Foo(name="bar")
f.save()


Colin

--~--~-~--~~~---~--~~
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: time it takes django to read database?

2008-12-09 Thread Colin Bean

On Tue, Dec 9, 2008 at 3:22 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> ok, server time is 2 hours and 11 minutes behind... this could explain
> the issue then. The admin section, when creating a new entry takes the
> time current actual time. So it makes 100% sense that django/python is
> reading the incorrect time. I've attempted to update the server time
> using the usual date "time" crap and was told the procedure was not
> allowed, i assume this is due the server being a virtual server.
>
> what would the best way to fix this?
>

Call tech support...

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time it takes django to read database?

2008-12-09 Thread Colin Bean

On Tue, Dec 9, 2008 at 12:16 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> Server is Red Hat 7, set up by godaddy, its a virtual server. Python
> 2.5 w/ mod_python and python-devel installed. running latest django.
>
> I am using webmonkey.com's tutorial for this:
> http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First_App
>
> so you can find the blog app as well as the templates in there. The
> part that is working instantly is the "secondary" section located in
> the base.html template that the other two blog templates extend
>
> thanks for lookin
>

Ah, didn't realize that it was showing one part of the page and not
another.  Looks like the template tag in the "secondary" section
queries all of the blog post objects, while the main section uses the
"latest" variable from django.views.generic.date_based.archive_index.
According to the docs, "Objects with a date in the future are not
included (in latest) unless you set allow_future to True."

http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-index

Any chance the dates on your posts are set to the future?  Is the date
set correctly on your server?

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time it takes django to read database?

2008-12-09 Thread Colin Bean

On Sun, Dec 7, 2008 at 7:32 PM, garagefan <[EMAIL PROTECTED]> wrote:
>
> following another tutorial to build a blog (webmonkey.com's) at it was
> rather frustrating to see nothing show up after creating a new blog...
>
> the admin section seems to see these right away, as they are there as
> soon as you hit save. But it seems to take the one section 10-20(or
> more?) minutes to read that they are there, while another section on
> the same page (that lists the items by title) no time at all. though
> when I update something that is listed already in the main section
> (the area that takes a while to get new info) it gets updated
> immediately... such as the title or entry
>
> http://kennethdavid.net/mysite/blog/
>
> most likely if you look within 5-10 minutes you'll see how there are
> three entry titles, and two blogs... i'll go ahead and add another
> entry, so at the very least there will be 4 titles and three available
> entries...
>
> what would possibly cause this?
> >
>

Also, what kind of server setup are you using?  Can you reproduce this
issue on a local development server?

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread Colin Bean

On Fri, Dec 5, 2008 at 4:06 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?
>
> did anybody try Ruby on Rails so can give us a feedback ?
>
> thanks
>
> >
>


Another big difference between Django and Rails is the template
system:  Django tries very hard to separate presentation from business
logic, Rails lets you do anything you want in a template (including
database queries and other egregious abuse :).
Also, Rails comes with numerous helper functions to generate common
html elements, and a bundled javascript framework.  Django leaves the
javascript framework and HTML generation largely up to you (you can
create your own shortcuts with templatetags, of course).
Although I've used and enjoyed Rails, I prefer the Django approach in
both of these areas.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem saving form data in sams "24 hour" book example

2008-12-02 Thread Colin Bean

On Tue, Dec 2, 2008 at 5:09 PM, Margie <[EMAIL PROTECTED]> wrote:
>
> I'm a new user to django and am attempting to go through the Sams
> "Teach Yourself Django in 24 hours"  book and am having an issue
> related to the chapter on saving form data.  I'm hoping someone can
> give me a hand.
>
> I'm using Django 1.0
>
> Here's my model:
>
> class Person(models.Model):
>userID = models.ForeignKey(User, unique=True)
>name = models.CharField('name', max_length=200)
>birthday = models.DateField('Birthday', blank = True, null=True)
>email=models.EmailField('Email', max_length=100, unique=True)
>
> Here's what the book says to use for the form:
>
> def person_form(request, pID='0'):
>p = get_object_or_404(Person, pk=pID)
>if request.method == 'POST':
>if request.POST['submit'] == 'update':
>message = 'Update Request for %s.' % p.name
>PersonForm = forms.form_for_instance(p)
>f = PersonForm(request.POST.copy())
>if f.is_valid():
>try:
>f.save()
>message += ' Updated.'
>except:
>message = ' Database Error.'
>else:
>message += ' Invalid.'
>
>
> That seems to be the "old" way of doing forms (I found that
> forms_for_instance doesn't exist),
> so I've modified it to look like this:
>
> class PersonForm(ModelForm):
>class Meta:
>model=Person
>
> def person_form(request, pID='0'):
>p = get_object_or_404(Person, pk=pID)
>if request.method == 'POST':
>if request.POST['submit'] == 'update':
>message = 'Update Request for %s.' % p.name
>f = PersonForm(request.POST)
>if f.is_valid():
>try:
>f.save()
>message += ' Updates.'
>except:
>message = ' Database Error.'
>else:
>message += ' Invalid.'
>
> I hope my modications are correct here - they could be part of the
> issue.
>
> The problem I have is that when I go to the form for a person, such as
> http://127.0.0.1:8000/people/Form/3/, and then modify a field such
> as the birthday, when I then click on the update button, the is_valid
> ()
> method returns false and the errors that get printed to the form are:
>  * Person with this UserID already exists
>  * Person with this Email already exists
>
> It seems like update is trying to create a new person with the
> same UserID, when really I want to just be modifying the person
> with that UserID.
>
> Can anyone tell me what I'm doing wrong?
>
> Thanks,
>
> Margie
>
>
>
> >
>

Change the way you create your form from this:

 f = PersonForm(request.POST)

to this:

 f = PersonForm(request.POST, instance=p)

Then your form will be populated with the data from 'p', and update
that record instead of creating a new one.


Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Develop in windows, serve in linux

2008-11-25 Thread Colin Bean

On Tue, Nov 25, 2008 at 10:13 AM, Jeff Anderson
<[EMAIL PROTECTED]> wrote:
> TheIvIaxx wrote:
>> This isnt really a django specific question, but i figured some folks
>> have a similar setup and might be able to offer advice.  I'm
>> developing my django site on vista and i have a server running linux/
>> apache.  Im not sure how to get all my files from the windows box onto
>> the server.  The linux box doesnt have X installed so no remoting :(
>>
>> Is there a common set of tools for this type of thing?
>>
> Absolutely-- ssh, scp, sftp.
>
> Use putty for ssh shell access. There is also winscp, and several gui
> ftp clients can handle sftp. All the tools mentioned use an ssh
> connection to provide their various services. There's plenty of info
> "out there" about using the terminal.
>
>
> Take care!
>
> Jeff Anderson
>
>

To add one more suggestion to what Jeff said, if you're using revision
control you can commit your files in Windows, then check out the
latest version of your code onto your remote server when you deploy (I
usually write a script to do this).  Of course, you'll still need an
SCP client to transfer anything that you don't want in version
control.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: localhost host only webservices/authentication in general

2008-11-05 Thread Colin Bean

On Wed, Nov 5, 2008 at 4:24 PM, craic <[EMAIL PROTECTED]> wrote:
>
> with django, is it possible to restrict the calling host of particular
> urls to be the localhost?
>
> namely, is there a way to restrict say a set of web services
> implemented in django to be only accepted if they are the same domain
> as the hosted page?
>
> so if i have a php page on foo.com/bar.php, which contains javascript
> with some ajax calls to a web service: http://foo.com/ws/blah, that
> would be allowed.
>
> but if someone on another host/location atttemps to call: 
> http://foo.com/ws/blah
> they will get permission denied.
>
> tnks,
> g'craic
> >
>

In your view, you could check the value of
request.META['REMOTE_ADDR']  and return a 404 if it's not coming from
an allowed location.
You could write a decorator or middleware to make it easy to apply
this to several views.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caught an exception while rendering: no such table: django_admin_log

2008-11-04 Thread Colin Bean

On Tue, Nov 4, 2008 at 3:00 PM, joshuajenkins <[EMAIL PROTECTED]> wrote:
>
> I'm running into an issue when just starting with Django 1.0 where the
> following exception is caught:
> Caught an exception while rendering: no such table: django_admin_log
>
> I've done some searching and it appears that this is common if you're
> not running Django 1.0, but 0.96 or lower.
>
> I've verified that I'm running 1.0 by checking at the command line
> (manage.py --version) which outputs 1.0-final-SVN-unkown
>
> Is this a common problem? All I have is a very simple model and a
> modified urls.py file.
>
> Any help would be appreciated.
> >
>


Did you run manage.py syncdb after adding django.contrib.admin to your
installed apps?

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Building Django web application

2008-10-10 Thread Colin Bean

On Fri, Oct 10, 2008 at 12:34 PM, mguthrie <[EMAIL PROTECTED]> wrote:
>
> I've been looking into Django for building something that is more web
> application than it is website.  I understand that Django has been
> developed in a sort of CMS mindset but to date I haven't found any
> reason why it couldn't create non-content centric web apps as well.
>
> My project requirements are as follows:
>
> 1.) I need to be able to host this project for multiple clients.  No
> customization, just everybody using the same thing.  Therefore ideally
> they should all share the same codebase.
> 2.) Each client should have their own user table/authentication since
> I want client A to be able to have a user named john.doe and client B
> to as well.  I would not mind if they shared the same table but they
> needed to provide a client id so the login can differentiate.
> 3.) Media should be separate per client.  Client A media should not be
> mixed with Client B or vice versa.
> 4.) Database either needs to be single db per client or one large db
> with multiple prefixed tables per client.  So each client would get
> their own users table (or shared table with client id field), tables
> for data, etc.
>
> I've researched the options available and here's what I've found
> (correct me if I'm wrong):
> 1.) I can host each client separately by providing a different
>  for each and specifying a different settings file.  This
> should allow me to specify separate DB's, media locations, etc but I'm
> concerned about the overhead of hosting them.  I've read that for each
> instance of Django requires another python interpreter.  If that is
> the case wouldn't I run out of RAM quickly hosting several clients?
> Is there a way I can do this using only one instance of Django?  If I
> use Django with multiple 's per client would that be one
> Django instance or multiple?  Is mod_python not the way to go for this
> project?
> 2.) I can use django.contrib.sites but every client shares the
> authentication.  Is there a way I can specify a client id to
> distinguish Client A's john.doe from Client B's?  If I do this can I
> specify where media for either would go?  How about they all share the
> same DB but have different table prefixes?
>
> I know it's a lot but I wanted to be as specific as I could so I don't
> waste someone's time. Is Django probably the wrong framework for this
> project?  Should this be a Pylons/Turbogears thing or what?
>
> All ideas/critiques/reworkings will be accepted.  Thanks in advance.
>
> -MG
>

Django is quite capable of doing everything you described.  You've
almost answered your own question because hosting separate django
instances under different  directives (or virtual hosts)
seems like the ideal solution.  I wouldn't worry too much about the
overhead of multiple python interpreters -- if python is using shared
libraries, they will use a little extra ram, but I doubt they will
exhaust your system resources before something else does.  I don't
have any numbers to back this, but I've run several django instances
on a single host with no problem, and it seems to be fairly common
practice.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login problem, Django 1.0

2008-10-09 Thread Colin Bean

On Thu, Oct 9, 2008 at 4:15 PM, Robocop <[EMAIL PROTECTED]> wrote:
>
>
> actually i read that wrong, i do not know what path it is being sent
> to.


I think that's the root path... you can verify in firefox if you look
under preferences > privacy > show cookies.  You said you moved from a
dev setup under 0.96, are you running another dev setup under 1.0, or
something else?  If you're using something else, have you tried it
under the dev server?  That would probably be the simplest possible
case...

Also, does the session id stay the same between requests?

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login problem, Django 1.0

2008-10-09 Thread Colin Bean

On Thu, Oct 9, 2008 at 3:25 PM, Robocop <[EMAIL PROTECTED]> wrote:
>
> All right, this is getting absolutely ridiculous.  I tried to
> workaround my problems by using the built in contrib.auth.views.login,
> and of course this resulted in the same behavior.  I am very reluctant
> to think this is a bug, but rather some type of session
> misunderstanding, but i'm running out of options.  I'm getting
> desperate on this project and would really really appreciate some type
> of constructive commentary, no matter how outrageous.
>
>

One thing you can do (below the django level) is to use TamperData for
firefox or something similar to examine your headers and make sure the
session cookie is indeed being set, with the right path.  Always good
to confirm that if you're having weird session behavior.  Are you
experiencing this on the development server, or some other setup?

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange, one app only appears rarely in the admin interface on apache2 (a reload sometimes works)

2008-09-29 Thread Colin Bean

Sounds like you could have some apache processes holding on to old
versions of your code... have you restarted apache recently?

Colin

On Mon, Sep 29, 2008 at 1:00 PM, rmnl <[EMAIL PROTECTED]> wrote:
>
> I'm experiencing a strange problem with my project. I have an app
> named products and this app doesn't show up in the Admin site. Most of
> the times that is, because I can reload the page a few times and about
> 1 out of 4 times the app does show up.
>
> This only happens with Apache2 with mod_python. Whenever I use the
> development server, it works fine.
>
> I have looked around and tried to figure out what the problem is, but
> I cannot find any errors. I've tried setting all debug options on (via
> settings.py and via PythonDebug), but without any problem. I've also
> checked the apache logs, but they also don't report any errors. The
> HTML of the Admin page without the products app is also without
> errors. The admin part for the app just isn't there.
>
> If I access the different models of the app directly, I also get no
> errors. It just doesn't show up most of the time.
>
> Does anybody have a clue about what could be the cause of this
> problem? I just don't find it.
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IE Hell. Blank Page

2008-09-18 Thread Colin Bean

On Thu, Sep 18, 2008 at 3:57 PM, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> Strangest thing...
>
> I primarily use and develop on Ubuntu and use Firefox.  So I went to
> check out how many bugs IE was generous enough to give me to fix.
> Using the Django development server, I can connect fine from a Windows
> computer and view the site using Firefox.  When I use IE (tested 6 &
> 7), I get a blank page.  However I can view the source and see all the
> HTML is there!  My connections to the development server were either
> on the local network or over an SSH tunnel.
>
> Anyone ever experience this?  Any chance its related to the Django
> development server?
>

This has happened to me before when I didn't properly close a 

Re: Take an integer and string and make one string

2008-07-16 Thread Colin Bean

Format strings are your friend:

"%s: %d" % (self.consequence, self.slope_height_rr)

Colin


On Wed, Jul 16, 2008 at 8:14 AM, Molly <[EMAIL PROTECTED]> wrote:
>
> I am trying to add an integer and a string:
>
> 
> def __unicode__(self):
>   return self.consequence + ': ' + self.slope_height_rr
> 
>
> When I run my app, I get an error:
>
> 
> TypeError at /admin/base/incident/add/
> coercing to Unicode: need string or buffer, float found
> 
>
> I think that I need to make the integer and the string one string.
>
> Any ideas?
>
> Thanks!
> Molly
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django, Apache, and CSS

2008-07-08 Thread Colin Bean

The blank page seems suspicious, as usually you'd be getting an error
message if something was wrong with your configuration.  What do you
see if you view the source of that page?  Perhaps there's an error in
your HTML, like forgetting to close a  tag.  It's impossible to
tell without seeing at the source of your base.html, but I'd start
there.

Colin

On Tue, Jul 8, 2008 at 7:47 PM, foo <[EMAIL PROTECTED]> wrote:
>
> First, I want to thank you for your reply Milan!  I just recently
> joined the group and I'm impressed at how active the group is and how
> helpful all of the advice I've found here has been.
>
> I've made the changes that you suggested and unfortunately, I'm still
> seeing the same behavior.  What I did was:
>
> Created the alias in my apache2.conf file...that file now looks as
> such:
>
> # Django initialization
> LoadModule python_module modules/mod_python.so
>
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
>
> 
>SetHandler None
> 
>
> Alias /media/ /opt/python/django-apps/foo/templates/media/
>
> I changed MEDIA_URL to only be '/media/'
>
> And I changed base.html template to use /media/style.css instead of
> media/style.css
>
> (I appreciate your comment about the location of my media
> directory...I'll be sure to change it as soon as I have all of this
> working!)
>
> DEBUG was already set to true in my settings.py file and per your
> advice, I checked the apache logs to see if there was anything odd in
> there and there wasn't anything useful.  Is there another log to check
> besides /var/log/apache2/error.log?
>
> Any other ideas?
>
> On Jul 8, 9:22 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>> On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote:
>>
>> > OK, I know this has been posted in the forums before, but for some
>> > reason, I'm still struggling to get my CSS stylesheet applied to my
>> > django templates.  I'm hoping that if I post my configuration, someone
>> > can point out what I'm missing.
>>
>> > I have my django project at:  /opt/python/django-apps/foo/
>> > In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
>> > apps/foo/templates/media/ and MEDIA_URL set tohttp://localhost/media
>>
>> > In my apache2.conf file, I have the following:
>>
>> > # Django configuration
>> > LoadModule python_module modules/mod_python.so
>>
>> > 
>> >SetHandler python-program
>> >PythonHandler django.core.handlers.modpython
>> >SetEnv DJANGO_SETTINGS_MODULE foo.settings
>> >PythonDebug On
>> >PythonPath "['/opt/python/django-apps/'] + sys.path"
>> > 
>> > 
>> >SetHandler python-program
>> >PythonHandler django.core.handlers.modpython
>> >SetEnv DJANGO_SETTINGS_MODULE foo.settings
>> >PythonDebug On
>> >PythonPath "['/opt/python/django-apps/'] + sys.path"
>> > 
>>
>> > 
>> >SetHandler None
>> > 
>>
>> An alias directive to tell apache where to find your media is probably
>> all you need. Assuming your apache's DocumentRoot is something other
>> than your templates dir.
>>
>> 
>>SetHandler None
>> 
>> Alias /media/ /opt/python/django-apps/foo/templates/media/
>>
>> Also putting your media dir in your templates dir is kind of odd.
>> Usually it's at the top of the project directory.
>>
>> Then set MEDIA_URL='/media/' you don't need 'http://localhost'.
>>
>> > In my base.html file, I reference the stylesheet as > > rel="stylesheet" type="text/css" href="media/style.css"
>> > media="screen" />
>>
>> Finally in your templates use '/media/foo' not 'media/foo', that way
>> it doesn't matter what location you are serving from, /media/ will
>> work.
>>
>>
>>
>> > When I point my browser athttp://localhost/contact, all I get is a
>> > blank page... no style and no text.  The contact.html template is
>> > below:
>>
>> > {% extends "base.html" %}
>>
>> > {% block title %}
>> >- Contact Us
>> > {% endblock %}
>>
>> > {% block content %}
>> >some content...please show up
>> > {% endblock %}
>>
>> > I'm not sure if there not being any text is related to the CSS problem
>> > or not.  I haven't spent any time troubleshooting that just yet, but I
>> > thought I'd throw it in for good measure.
>>
>> > Any help that anyone can give is greatly appreciated!
>>
>> Also don't forget to set DEBUG=True in your settings.py and check your
>> error log for more info.
>>
>> --
>> Milan
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this 

Re: I'm sure this is one of those clueless newbie mistakes

2008-06-26 Thread Colin Bean

For a start, you want your KVM model to subclass models.Model.

Colin

On Thu, Jun 26, 2008 at 11:59 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Karen;
>
> On Jun 26, 12:56 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>> If you post the contents of your cmdb/models.py file on someplace like
>> dpaste.com someone might be able to help identify what is going on.
>
> Thanks for that advice.
>
> You can find my models.py at:
>
> http://pastebin.sfee-hosted.com/562
>
> There's a very good possibility that I've screwed something
> fundamental up, so don't be afraid to tell me that my implementation
> is totally incorrect.
>
> Ian
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving root from static

2008-06-10 Thread Colin Bean

On Mon, Jun 9, 2008 at 10:58 PM, Andre Meyer <[EMAIL PROTECTED]> wrote:
> thanks a lot, Colin, i will contact the WebFaction guys for the apache
> setup. they are always very helpful ;-)
>
> HOWEVER: for testing purposes only, using only runserver and sqlite, how to
> preceed for making this work?
>
> http://localhost:8000/--> static/index.html (NOT a template)
> http://localhost:8000myapp1--> myapp1/index.html (a template)
> http://localhost:8000/myapp2--> myapp2/index.html (a template)
> http://localhost:8000/admin--> the admin interface
>
> how to get the first url work with runserver? i can only get it to render a
> template, but not server up an html file from the static directory.
>
> thanks again
> André
>

Don't have time to test this out, but did you try serving your root
url with django.views.static.serve ?  That should do what you're
looking for; you might have to type in the full path
(http://localhost:8000/index.html) as I'm not sure if the dev server
will automatically use index files like apache does.  Try using
something like the following in your urls.py:
(r'^$', 'django.views.static.serve', {'document_root': '/path/to/static'}),

HTH,
Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving root from static

2008-06-09 Thread Colin Bean

On Mon, Jun 9, 2008 at 3:25 PM, Andre Meyer <[EMAIL PROTECTED]> wrote:
> thanks Jeff
>
> yes, i had found this method of having django serve static content, too, and
> know it is not ideal.
>
> what i want is different: use apache for serving the static content at the
> root of the site (defind in settings.py and urls.py) and have a couple of
> django apps which are accessible just with simple paths. the urls are what
> disturbs me, because i cannot get anything from just http://mysite.org/, but
> instead need to access http://mysite.org/myproject.
>
> again, the non-functional code (raises "TemplateDoesNotExist at
> /static/index.html" in views):
>
> urls.py
>
> urlpatterns = patterns('myproject.views',
> (r'^$', 'home')
>
> views.py
>
> def home(request):
> return render_to_response('static/index.html')
>
> maybe use something like
> return HttpResponse('/static/index.html')
> but how?
>
>

Hi Andre,

You'll need to set this up in your apache configuration, and the part
that deals with serving static files is going to be independent of any
django code or settings.

You just need to change the DocumentRoot of your site to the "static"
directory where your index.html is located.  It sounds like you've
already got django set up to serve the "myproject" directories, so
you're pretty close.  Don't know how apache setup works at WebFaction,
but if you're having trouble you should post the relevant sections
from your apache configuration (if possible).

A quick read over the apache docs will explain this much more
thourghly than I did :)  If there's one concept to take away, remember
that if apache's serving a static file, apache handles absolutely
every step of the process, and if python/django got involved in any
way you'd lose the performance benefit of serving directly from from
apache.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why so slow?

2008-06-03 Thread Colin Bean

On Tue, Jun 3, 2008 at 4:01 PM,  <[EMAIL PROTECTED]> wrote:
>
> now i see, ty very much. django seems awesome though now that it is
> working for me.
>
> On 4 Juni, 00:57, "Colin Bean" <[EMAIL PROTECTED]> wrote:
>> On Tue, Jun 3, 2008 at 2:00 PM,  <[EMAIL PROTECTED]> wrote:
>>
>> > im running part 2 of the tutorial right now and im inside the admin.
>> > when connecting to localhost it is s slow, why?
>>
>> Well, the tutorial does say:
>>
>> "You've started the Django development server, a lightweight Web
>> server written purely in Python. We've included this with Django so
>> you can develop things rapidly, without having to deal with
>> configuring a production server — such as Apache — until you're ready
>> for production.
>> Now's a good time to note: DON'T use this server in anything
>> resembling a production environment. It's intended only for use while
>> developing. (We're in the business of making Web frameworks, not Web
>> servers.)"
>>
>> So the development server is a pure python implementation that has
>> been written with simplicity in mind rather than performance.  In
>> addition to this, it reloads your code with every request so any
>> changes you make are immediately reflected.  So yes, it's going to be
>> slow... You don't really quantify how slow it is or if it's unusable
>> for you.
>>
>> If you're looking for a faster local deployment, your best bet is
>> probably to setup apache, but you'll need to restart that every time
>> you want changed code to take effect.
>>

On a second reading I realized that I oversimplified how Apache needs
to be restarted.  There's several django hosting mechanisms to choose
from -- mod_python requires a restart for new code to take effect, but
there's various WSGI setups automatically will reload / restart when
your code is changed:
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

Anyhow, that's overkill for a beginning user, but there it is :)  Glad
django is working out for you!

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why so slow?

2008-06-03 Thread Colin Bean

On Tue, Jun 3, 2008 at 2:00 PM,  <[EMAIL PROTECTED]> wrote:
>
> im running part 2 of the tutorial right now and im inside the admin.
> when connecting to localhost it is s slow, why?


Well, the tutorial does say:

"You've started the Django development server, a lightweight Web
server written purely in Python. We've included this with Django so
you can develop things rapidly, without having to deal with
configuring a production server — such as Apache — until you're ready
for production.
Now's a good time to note: DON'T use this server in anything
resembling a production environment. It's intended only for use while
developing. (We're in the business of making Web frameworks, not Web
servers.)"

So the development server is a pure python implementation that has
been written with simplicity in mind rather than performance.  In
addition to this, it reloads your code with every request so any
changes you make are immediately reflected.  So yes, it's going to be
slow... You don't really quantify how slow it is or if it's unusable
for you.

If you're looking for a faster local deployment, your best bet is
probably to setup apache, but you'll need to restart that every time
you want changed code to take effect.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cut-and-paste traceback error actually the error from the time before --

2008-04-29 Thread Colin Bean

In this situation it might be helpful to use tamper data (or something
similar) to examine the all of the requests / responses and see
exactly what your server is sending and when  Could at least
determine if this is broswer behavior or if Django is really sending
the incorrect trace.

Colin

On Tue, Apr 29, 2008 at 1:05 PM, Mike H <[EMAIL PROTECTED]> wrote:
>
>  Are you using firefox? I think this is a "helpful" feature of firefox
>  where if you fill out a form and refresh the page, it remembers the
>  form content so you don't have to fill it in again. So if you get an
>  error page, fix the problem, refresh and get a different error,
>  firefox messes up the textarea. Extremely unhelpful. I'm pretty
>  certain django is outputting the correct data. A random name and id
>  for the textarea would probably fix this, but it's really a firefox
>  problem from what I've seen.
>
>
>
>  On 29 Apr 2008, at 19:49, Joe Murphy wrote:
>
>  >
>  > I thought this was "maybe it's just me" problems -- but it happens on
>  > every install of Django, in every environment I've dealt with Django
>  > (which is now up to six).
>  >
>  > When I get a Django error page, the error that's listed in the cut-
>  > and-
>  > paste traceback is actually the error that existed  the time before.
>  >
>  > That means I get a page kind of like this:
>  > http://dpaste.com/47439/
>  >
>  > Anybody else experience this?
>  >
>
>  >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Has anyone made an MS excel exporter in a django site yet?

2008-04-09 Thread Colin Bean

If your users don't need a binary .xls file, there's an XML-based
format for excel.  I've rolled my own python code to export data to
it, it's pretty easy to do and the excel users didn't seem to notice
the difference :)

Colin

On Wed, Apr 9, 2008 at 3:45 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> Roboto wrote:
>
> > I'm curious =P  A couple of my users are requesting that I find a way
> > to export some data to excel so that they can manipulate as fit.
> >
> > Any thoughts?
> >
> >
>  I remember seeing an MS office library for perl a very very long time ago.
> I'm sure that there is something out there for python that can spit native
> ms office formats out.
>
>  If worse comes to worse, make a csv exporter. There is details on doing
> that in the official django docs. csv is a standard that would allow whoever
> needs it to import it into more than just excel.
>
>  Jeff Anderson
>
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Finding out the index of a model instance in a list

2008-03-29 Thread Colin Bean

>
> lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
> lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
> lImagesInAlbum = lAlbumImages.count()
> lImagePosition = None
> lPreviousImage = None
> lNextImage = None
> for lPosition in range(lImagesInAlbum):
> lEachImage = lAlbumImages[lPosition]
> if lEachImage.id == lImage.id:
> lImagePosition = lPosition + 1
> if lPosition > 0:
> lPreviousImage = lAlbumImages[lPosition-1]
> if lPosition < lImagesInAlbum-1:
> lNextImage = lAlbumImages[lPosition+1]
> break
>


Pagination might be what you're looking for:
http://www.djangoproject.com/documentation/pagination/

Colin

>
>
>  On Saturday 29 Mar 2008, Tim Sawyer wrote:
>  > Hi Folks,
>  >
>  > If I have an image, and a list of images, how can I work out what position
>  > in the list my image is so I can do a Image 4 of 24 type annotation?
>  >
>  > lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
>  > lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
>  > lImagesInAlbum = lAlbumImages.count()
>  > lImagePosition = ???
>  >
>  > My view is passed pImageSerial which is the id of the image to display.  I
>  > can work out the Image object from this.  I can also get the full list of
>  > images for this particular album, and work out how many images there are in
>  > total. The images are ordered by filename, so I know the order will be
>  > consistent.
>  >
>  > How do I work out lImagePosition?  Can anyone give me any pointers?
>  >
>  > Thanks,
>  >
>  > Tim.
>  >
>  >
>
>
>  >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: usernames and case sensitivity

2008-03-28 Thread Colin Bean

On Fri, Mar 28, 2008 at 10:02 AM, Jonathan Lukens
<[EMAIL PROTECTED]> wrote:
>
>  Hi Evert,
>
>
>  > > 2) Validate new usernames for case-insensitive uniqueness and filter
>  > > with case-insensitive queries whenever the username is URL param.
>
>
> > def view(request, username, child=None, ...):
>  >username = username.lower()
>
>  The problem here is that that even if 'Charlie' and 'charlie' cannot
>  exist as usernames concurrently, 'Charlie' still can if he gets there
>  first.  So if that were the case and I had '/Charlie/' and passed
>  username.lower() to `widgets =
>  Widget.objects.get(owner__username=username), it is going to look for
>  charlie and won't find it.  At least I am pretty sure that happened to
>  me last evening when I was trying this, though it was pretty late...

Hey Jonathan,

Using the "iexact" option would fix this case.  Take a look at:
http://www.djangobook.com/en/1.0/appendixC/
towards the bottom, in the Field Lookups section.

I *think* that:
 Widget.objects.get(owner__username__iexact='charlie') would get
Charlie, charlie, or any other case variation...  That way you could
also the original username value in the template, complete with
capitalization.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---