Re: Customizing admin form

2009-04-10 Thread Brian Neal

On Apr 10, 4:46 pm, Oleg Oltar  wrote:
> Hi!
>
> I have a model which contains several TextFields and CharFields. I want to
> make all char fields longer and wider. How to do it?
>
> Thanks,
> Oleg

You can supply your own form that is using customized widgets to
construct the fields with.

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form
http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs

BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help! PNG file upload error...

2009-04-10 Thread Brian Neal

On Apr 9, 12:45 am, higer  wrote:
> When I upload a PNG file and use PIL to handle it,there will be an
> error occured:
> 'NoneType' object is unsubscriptable
>
> I do not know why and other formats(BMP GIF JPG JPEG) are all ok.

I don't know if this is your problem, but in order to use certain file
formats in PIL you have to have some prequisites installed. Here is
the PIL doc page for PNG support:

http://www.pythonware.com/library/pil/handbook/format-png.htm

In particular, note:

"PIL identifies, reads, and writes PNG files containing "1", "L", "P",
"RGB", or "RGBA" data. Interlaced files are currently not supported."

And also:

"Note: To enable PNG support, you need to build and install the ZLIB
compression library before building the Python Imaging Library. See
the distribution README for details."

BN
--~--~-~--~~~---~--~~
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: How to widen the text fields in the admin pages for editing records

2009-04-07 Thread Brian Neal

On Apr 7, 3:04 pm, Mac  wrote:
> Any pointers to the documentation for getting the text fields larger
> for CharField data?  They're kinda puny for columns that are defined
> to have up to 255 characters.  Thanks!

You do it by supplying your own widget to the form field. See:

http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs

Best,
BN
--~--~-~--~~~---~--~~
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: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Brian Neal

On Apr 1, 10:19 pm, "Michael Rose Jr." 
wrote:
>
> Brian. Thanks for responding. I mean to post "name". I've been
> experimenting with other field types, which why I accidentally pasted
> "last". Here is the HTML for "name".
> Name: type="text" name="name" maxlength="45" />
>
> Here's the model.http://dpaste.com/22453/
> Thanks again for your help.
>
> Riz

Oh, one more thing. How are you displaying your form in your template?
Can you post that part of your template?

BN
--~--~-~--~~~---~--~~
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: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Brian Neal

On Apr 1, 10:19 pm, "Michael Rose Jr." 
wrote:
>
> Brian. Thanks for responding. I mean to post "name". I've been
> experimenting with other field types, which why I accidentally pasted
> "last". Here is the HTML for "name".
> Name: type="text" name="name" maxlength="45" />
>
> Here's the model.http://dpaste.com/22453/
> Thanks again for your help.
>
> Riz

Hmmm, I don't see anything obviously wrong. I just did something like
this myself with a model form and it worked fine for me.

What version of Django are you using? And sorry to have to ask this,
but are you using the development server? (Just ruling out that the
code is getting reloaded after you make changes.)

BN
--~--~-~--~~~---~--~~
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: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Brian Neal

On Apr 1, 8:16 pm, rizzoo  wrote:
> How do I make a field hidden when using ModelForm?  I tried
> HiddenInput but it appears to be ignored.
>
> code:http://dpaste.com/22290/
> Line 9
>
> Here's what View Source shows for that line in the browners:
> Last: name="last" maxlength="45"
>

Well it looks like you are trying to hide the field "name". So why are
you showing us the HTML for the field named "last"?

I just did this the other day and it worked for me.

Can you post your model code too?

BN
--~--~-~--~~~---~--~~
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 lookup

2009-03-31 Thread Brian Neal

On Mar 31, 5:31 am, LD  wrote:
> OK, but Django do not provide 'time' lookup so my problem is 'how to
> retrieve time part of datetime field in a query'

Ok, then why are you storing date and time together when all you care
about is time? To me, when you have a DateTimeField, that represents a
point in time. It doesn't make a lot of sense to ask: "does this point
in time occur less than 14:00 hours." 14:00 hours on what day? Today?
Yesterday? That is the source of friction for me. Maybe you could
explain your model a bit more.

Maybe you should consider using a TimeField instead, then your query
would be more natural.

But if you really do need to store dates and times together, then yes,
I don't think there is an easy way to just query on the time part of
the DateTime field. You might look into the new F() syntax, but you
might just have to write your own SQL.
--~--~-~--~~~---~--~~
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 lookup

2009-03-30 Thread Brian Neal

On Mar 30, 10:12 am, LD  wrote:
> Hi,
>
> I don't have idea how to do simple task.
> I have model with DateTimeField and I want to retrieve all objects
> that have time for example lower than 2pm.
>
> I know about Django queryset lookup like year, month, day. Is there
> something similar but for time? If not what is the simplest way to
> accomplish that?
>
> So it would be great to do something like this:
> MyModel.objects.filter(date_field__time__lt == datetime.time(14,0))
> assuming of course that MyModel.date_field is models.DateTimeField
>
Well, the model field is storing a date and a time. So you can't just
compare that against a time, I don't think. You need to pick a day and
a time. And then you can do the filtering, you've almost got the
syntax right. Something like this should work:

MyModel.objects.filter(date_field__time__lt=datetime.datetime.(yy, mm,
dd, 14, 0))
--~--~-~--~~~---~--~~
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: Date Filtering in Django-Sphinx

2009-03-30 Thread Brian Neal

On Mar 30, 6:11 am, Alfonso  wrote:
>
> And in my search view I have a simple filter (which is where I think
> the problem lies):
>
> if date == "next30":
>        results = queryset.filter(date_time>=(datetime.datetime.now))
>
> (Attempting to pull future dates just to see something happen)
>
> Where am I going wrong?

Assuming date_time is a field on your model:

results = queryset.filter(date_time__gte=datetime.datetime.now())

See the docs on field lookups:
http://docs.djangoproject.com/en/dev/topics/db/queries/#field-lookups

Also, you want to construct a datetime object that is equal to now,
not compare your field to the datetime.datetime.now function.

-BN
--~--~-~--~~~---~--~~
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.contrib.auth.models.User User model can't be saved

2009-03-28 Thread Brian Neal

On Mar 28, 7:02 am, Joshua Partogi  wrote:
> Yes you're right. In my template I only have username, first_name,
> last_name, email and password. I also print out the errors too.

Probably what is happening is that some of the other fields you are
excluding are required fields. Thus you should use the ModelForm save
with commit=False, then assign values to the rest of the fields, then
do a save on the object.

new_member = form.save(commit=False)
new_member.x = something
new_member.y = something_else
...
new_member.save()

Where x and y are the other required fields.

>
> Are you saying that I should have all the other fields from
> django.contrib.auth.models.User too?
>

No, typically you don't want the user to be able to say if they are an
admin, etc.

BN
--~--~-~--~~~---~--~~
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 wont display images on my CSS file

2009-03-27 Thread Brian Neal

On Mar 27, 7:33 am, Gath  wrote:
> Guys,
>
> Am having a problem in displaying images in my CSS file.
>
> I have a css file with the following class
>
> .header
> {
>  margin-left: auto;
>  bla bla
>  bla bla
>  ...
> background: url(/site_media/header_background.gif) no-repeat top left;
>
> }
>
> When i execute the template with this css, no image is displayed!
> But when i directly inject the background style on my template it
> works perfect.
>
> What am i not doing right!
>

I seem to recall that when you put references to files in your CSS,
they are relative to that CSS file, not to the document root. So if
that graphic file is in the same directory as your CSS file, change
your url to:

background: url(header_background.gif) no-repeat top left;

Best,
BN
--~--~-~--~~~---~--~~
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: Including username in FileField upload_to path

2009-03-26 Thread Brian Neal

On Mar 26, 3:56 pm, Rajesh D  wrote:
> On Mar 26, 3:21 pm, IanSR  wrote:
>
> > I've spent the last few hours trying variations on upload_to for my
> > FileField path generator get_file_path(instance,filename) that will
> > allow me to include the username from the POST HttpRequest object.  No
> > luck.  Does anyone have any suggestions on how to do this?  My
> > instance does have a "user" field that saves the request.user ID (as a
> > ForeignKey), however it appears that this is not yet available when
> > the callback for upload_to is run.
>
> It should be available. In your model definition, does the user
> ForeignKey appear _before_ the file field? Make sure it does. If that
> fails, can you describe what you mean by "No luck" above i.e. provide
> more details of your custom upload_to callable?
>
> -Rajesh D

Yeah, this works for me as well. Please provide more details and maybe
we can help.
--~--~-~--~~~---~--~~
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: need a multiselect list box for a static list of options

2009-03-26 Thread Brian Neal

On Mar 26, 9:59 am, Adam Fraser  wrote:
> hrm, I think I'm _finally_ starting to understand how django is meant
> to be used.
>
> Question: Why can't I just specify the widget used by a particular
> field from my model in the admin interface.
>
> stains = models.CommaSeparatedIntegerField(widget=SelectMultiple
> (choices=STAIN_CHOICES))
>
> ...or can I?  You suggested something like this earlier only referred
> to forms.CommaSeparatedIntegerField rather than
> models.CommaSeparatedIntegerField.
>
> hrm

Models are simply models. They don't really say much about forms. What
the admin application does is to make some default choices about how
to display your model in the admin interface. It automatically builds
the form to edit your model using some very reasonable defaults. If
you aren't happy with those choices, you can provide the form that the
admin should use instead of the default one. In your form, you are
free to use different widgets for your fields and/or provide custom
behavior.

The docs describe how to provide your own form to the admin here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form

You simply provide an attribute on your ModelAdmin called 'form', set
equal to the form class you want the admin to use. This form class
should inherit from ModelForm. You can then customize the widgets and
behavior anyway you would like.

ModelForms are discussed here:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#topics-forms-modelforms

Overriding the default field type for a field on a ModelForm is a bit
further down:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types

But before you read all that, make sure you understand forms in
Django, in general:
http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index

Armed with that info, you should be able to make a custom form for the
admin to use. Good luck.

BN
--~--~-~--~~~---~--~~
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: need a multiselect list box for a static list of options

2009-03-24 Thread Brian Neal

On Mar 24, 8:55 am, Adam Fraser  wrote:
> Still doesn't work.  Maybe I should be more specific.
>
> I'm editing projectprofiler/projects/models.py which hasn't needed to
> import forms for anything, and when I do I get very strange errors.
>
> Here's what it looks like now:
>
> from django.db import models
> from django.contrib.auth.models import User
> from projectprofiler.middleware import threadlocals
>
> #CHOICES defined here
> #...
>
> class Project(models.Model):
>     name  = models.CharField(max_length=200)
>     complexity                  = models.PositiveIntegerField
> (choices=COMPLEXITY_CHOICES, default=0)
>     affiliation                 = models.PositiveIntegerField
> (choices=AFFILIATION_CHOICES, default=0
>     description                 = models.TextField(max_length=300,
> blank=True) # not required
>    ...etc
>
> ...as you can see, everything is coming from django.db.models.  I have
> never had to specify the actual widgets that input the data in the
> admin pages on the site... they are just automatic.  What confuses me
> to death is how all I need to do is add "from django import forms" to
> the above code to make it break.
>
> -Adam
>

I thought you were trying to make a form. Are you trying to do all
this from the admin?
If that is the case you can provide your own form that the admin will
use. In that form is where you specify the fields and widgets you
need.
Take a look at the forms documentation and also the model-forms docs.
--~--~-~--~~~---~--~~
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: need a multiselect list box for a static list of options

2009-03-23 Thread Brian Neal

On Mar 23, 3:36 pm, Adam Fraser  wrote:
> I found the SelectMultiple widget here:
>
> http://docs.djangoproject.com/en/dev/ref/forms/widgets/
>
> But I still don't know how to hook that up to a model like
> CommaSeparatedIntegerField.
>
> help?
>

Did you try something like this? This is off the top of my head:

class MyForm(forms.ModelForm):
   my_choices = forms.CommaSeparatedIntegerField
(widget=forms.SelectMultiple(choices=STAIN_CHOICES))

See:
http://docs.djangoproject.com/en/dev/ref/forms/widgets/#specifying-widgets
--~--~-~--~~~---~--~~
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: need a multiselect list box for a static list of options

2009-03-23 Thread Brian Neal

On Mar 23, 1:49 pm, Adam Fraser  wrote:
> Hello,
>
> This should be a pretty simple question.  I have a list of options:
>
> STAIN_CHOICES = (
>     (1, 'DNA - DAPI'),
>     (2, 'DNA - Hoechst'),
>     (3, 'DNA - other'),
>     (4, 'Actin - Phalloidin'),
>     (5, 'Tubulin'),
> )
>
> I would like users to be able to select more than one of these things
> at a time.  It looks like models.CommaSeparatedIntegerField would be
> good for this, but how can I get a multi-selection list box as an
> input?
>

There is a form widget called SelectMultiple:

http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.SelectMultiple

You could use a ChoiceField with a SelectMultipleWidget, it would
seem.

-BN
--~--~-~--~~~---~--~~
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 ORM not compatible with postgres

2009-03-22 Thread Brian Neal

On Mar 22, 2:56 pm, Mike Ramirez  wrote:
> On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
>
>
> > But from what you posted, I'm guessing that line needs to read:
>
> > obj.user = User.objects.get(username=request.user)
>
> I think what you want to do with this style is:
>
>         obj.user = User.objects.get(username=request.user.username)

Yes, my mistake, thanks.

>
> > or maybe just
>
> > obj.user = request.user
>
> yeah, I think this is best.

Agreed.

>Tho if you're the type that sanitizes everything,
> the upper one is better.

I don't think so. request.user gets set by Django based on cookies, so
it should be trustworthy as request.user.username.
--~--~-~--~~~---~--~~
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: Additional Javascript include in ModelAdmin

2009-03-22 Thread Brian Neal

On Mar 22, 11:15 am, Roy  wrote:
> That would require the extra files be hosted on my media url though. I
> want to be able to link js externally so I can use stuff like YUI,
> etc. without having to host it.

No, not if you use a fully qualified string like "http://some-url-to-
my-media".
--~--~-~--~~~---~--~~
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 ORM not compatible with postgres

2009-03-22 Thread Brian Neal

On Mar 22, 8:15 am, Joshua Partogi  wrote:
> Dear all,
>
> I just encounter this error using pyscopg2 as my db adapter
> Exception Type:         ProgrammingError
> Exception Value:        can't adapt
> Exception Location:
>         /usr/lib/python2.5/site-packages/django/db/backends/util.py in
> execute, line 19
>
> The query that I'm trying to run from admin is as such:
>     def save_model(self, request, obj, form, change):
>         user = User.objects.get(username=request.user)
>
> Does anybody know how I can run this with psycopg? What's wrong with
> these statements? What did I miss here?

It would help if you posted your model.

But from what you posted, I'm guessing that line needs to read:

obj.user = User.objects.get(username=request.user)

or maybe just

obj.user = request.user

--BN
--~--~-~--~~~---~--~~
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: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread Brian Neal

On Mar 16, 2:14 pm, NoviceSortOf  wrote:
>
> So perhaps a better question would be is
>
> in view.py...
> ---
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Why is it form_class(data) does not accept the data
> as declared and enable it to presented it in
> templates in any other form than a writable field
>  --  when render_to_response allows the data to be
>      presented as a string?

Forms don't work that way. They aren't used to display arbitrary data.
They are used to display form fields. It sounds like you don't want
the username as a form field, you just want it as normal text. You
need to pass non-form field data to the template, in the context
dictionary. Forms should be constructed with data to bind to the form
fields (such as request.POST data) or maybe initial values for the
form fields [1]. Please see:

http://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view

and especially:

http://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api

So you'll need something like this (for the non-POST case):

form = MyForm()
username = ...
return render_to_response(template_name,
   { 'form': form,
 'username': username,
   },
   context_instance=context)

And then in your template, this should get you started:

{{ username }}
{{ form.as_p }}

but realize there are many other ways to display a form as the docs
note.

Hope that helps,
BN

[1] Maybe I am missing something but I don't see the initial keyword
argument to the forms.Form class documented?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django and Python Warnings

2009-03-06 Thread Brian Neal

I updated my working copy of Django after a long period and was
browsing the source and noticed it was taking advantage of the Python
warnings module. What is the best way to "see" such warnings when
doing development? Is it possible to configure Python or the Django
development server to display such warning messages?

For example, I was still using admin.site.root instead of include
(admin.site.urls) in my URLConf. I see the new code now issues a
PendingDeprecationWarning for this usage, however I didn't see it in
my development server window. I'm guessing I need to turn these on
somehow?

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: ModelAdmin get_urls w/ invalid literal for int() with base 10

2009-03-05 Thread Brian Neal

On Mar 4, 10:06 pm, Brian Neal  wrote:
> On Mar 4, 9:11 pm, Brian Neal  wrote:
>
> > I'd like to make my own custom view. In the past I did this by
> > following the django book and added a URL to my main urlpatterns above
> > the '^admin/(.*)' pattern. But I noticed a new get_urls function on
> > the ModelAdmin class in the docs. I'm on trunk, and just did an svn
> > update to 9975 to try this out.
>
> > The docs for get_urls show the view being registered as self.view. Is
> > that possible to register a class method as a view?
>
> > Anyway, just to try things out, I created a view function right in my
> > admin.py file, and my admin.py file looks like this:
>
> >http://dpaste.com/6643/
>
> > I'm kind of guessing here about the URL I need to visit to trigger
> > this new view. My model lives at admin/gcalendar/event, so I'm
> > guessing I need to visit admin/gcalendar/event/my_view. When I do
> > that, I get this error:
>
> > ValueError at /admin/gcalendar/event/my_view/
>
> > invalid literal for int() with base 10: 'my_view'
>
> > With this traceback:  http://dpaste.com/6649/
>
> > For reference, here is my models.py:  http://dpaste.com/6650/
>
> > Thanks!
>
> I put an assert in my get_urls() function and it was not getting hit.
> I made sure that my Django contrib/admin/options.py file does indeed
> have the get_urls() function.
> I deleted all the *.pyc files under site-packages/django and redid the
> 'sudo python setup.py install' step.
> Still no go. I think it is just trying the last default pattern in the
> base ModelAdmin get_urls() and choking on that.

Well after some thorough review of the Admin docs and some googling, I
think I found my problem. My current urlpatterns looks like this:

urlpatterns = patterns('',
   (r'^admin/(.*)', admin.site.root),
   ...

I think the new way is to do this:

urlpatterns = patterns('',
('^admin/', include(admin.site.urls)),
...

I haven't confirmed this yet but I think this will get my custom admin
view registered correctly now after skimming the django code.


--~--~-~--~~~---~--~~
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: ModelAdmin get_urls w/ invalid literal for int() with base 10

2009-03-04 Thread Brian Neal

On Mar 4, 10:06 pm, Brian Neal  wrote:
> On Mar 4, 9:11 pm, Brian Neal  wrote:
>
>
>
> > I'd like to make my own custom view. In the past I did this by
> > following the django book and added a URL to my main urlpatterns above
> > the '^admin/(.*)' pattern. But I noticed a new get_urls function on
> > the ModelAdmin class in the docs. I'm on trunk, and just did an svn
> > update to 9975 to try this out.
>
> > The docs for get_urls show the view being registered as self.view. Is
> > that possible to register a class method as a view?
>
> > Anyway, just to try things out, I created a view function right in my
> > admin.py file, and my admin.py file looks like this:
>
> >http://dpaste.com/6643/
>
> > I'm kind of guessing here about the URL I need to visit to trigger
> > this new view. My model lives at admin/gcalendar/event, so I'm
> > guessing I need to visit admin/gcalendar/event/my_view. When I do
> > that, I get this error:
>
> > ValueError at /admin/gcalendar/event/my_view/
>
> > invalid literal for int() with base 10: 'my_view'
>
> > With this traceback:  http://dpaste.com/6649/
>
> > For reference, here is my models.py:  http://dpaste.com/6650/
>
> > Thanks!
>
> I put an assert in my get_urls() function and it was not getting hit.
> I made sure that my Django contrib/admin/options.py file does indeed
> have the get_urls() function.
> I deleted all the *.pyc files under site-packages/django and redid the
> 'sudo python setup.py install' step.
> Still no go. I think it is just trying the last default pattern in the
> base ModelAdmin get_urls() and choking on that.

Maybe this ticket is related to what I am seeing?

http://code.djangoproject.com/ticket/10061#comment:4
--~--~-~--~~~---~--~~
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: ModelAdmin get_urls w/ invalid literal for int() with base 10

2009-03-04 Thread Brian Neal

On Mar 4, 9:11 pm, Brian Neal  wrote:
> I'd like to make my own custom view. In the past I did this by
> following the django book and added a URL to my main urlpatterns above
> the '^admin/(.*)' pattern. But I noticed a new get_urls function on
> the ModelAdmin class in the docs. I'm on trunk, and just did an svn
> update to 9975 to try this out.
>
> The docs for get_urls show the view being registered as self.view. Is
> that possible to register a class method as a view?
>
> Anyway, just to try things out, I created a view function right in my
> admin.py file, and my admin.py file looks like this:
>
> http://dpaste.com/6643/
>
> I'm kind of guessing here about the URL I need to visit to trigger
> this new view. My model lives at admin/gcalendar/event, so I'm
> guessing I need to visit admin/gcalendar/event/my_view. When I do
> that, I get this error:
>
> ValueError at /admin/gcalendar/event/my_view/
>
> invalid literal for int() with base 10: 'my_view'
>
> With this traceback:  http://dpaste.com/6649/
>
> For reference, here is my models.py:  http://dpaste.com/6650/
>
> Thanks!

I put an assert in my get_urls() function and it was not getting hit.
I made sure that my Django contrib/admin/options.py file does indeed
have the get_urls() function.
I deleted all the *.pyc files under site-packages/django and redid the
'sudo python setup.py install' step.
Still no go. I think it is just trying the last default pattern in the
base ModelAdmin get_urls() and choking on that.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ModelAdmin get_urls w/ invalid literal for int() with base 10

2009-03-04 Thread Brian Neal

I'd like to make my own custom view. In the past I did this by
following the django book and added a URL to my main urlpatterns above
the '^admin/(.*)' pattern. But I noticed a new get_urls function on
the ModelAdmin class in the docs. I'm on trunk, and just did an svn
update to 9975 to try this out.

The docs for get_urls show the view being registered as self.view. Is
that possible to register a class method as a view?

Anyway, just to try things out, I created a view function right in my
admin.py file, and my admin.py file looks like this:

http://dpaste.com/6643/

I'm kind of guessing here about the URL I need to visit to trigger
this new view. My model lives at admin/gcalendar/event, so I'm
guessing I need to visit admin/gcalendar/event/my_view. When I do
that, I get this error:

ValueError at /admin/gcalendar/event/my_view/

invalid literal for int() with base 10: 'my_view'

With this traceback:  http://dpaste.com/6649/

For reference, here is my models.py:  http://dpaste.com/6650/

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

2009-02-24 Thread Brian Neal

On Feb 23, 10:51 pm, Jacob Kaplan-Moss 
wrote:
> On Mon, Feb 23, 2009 at 7:49 PM, Brian Neal  wrote:
> > Interesting, I've also come across this:
>
> >http://codespeak.net/lxml/lxmlhtml.html#cleaning-up-html
>
> > I've heard it is very fast as it is just a python binding to a C-
> > library...?
>
> Short version: don't use lxml.html.clean, either.
>
> Long version: yes, lxml is built on top of libxml2 so it is indeed
> *very* fast. Probably as much as an order of magnitude faster than
> html5lib.
>
> However, if you look at the source of lxml.html.clean
> (http://codespeak.net/lxml/api/lxml.html.clean-pysrc.html) you'll see
> its implemented in terms of a blacklist. This is almost always a bad
> idea: you only have to miss *one thing* on your blacklist to make your
> site as insecure as if you'd not bothered escaping HTML at all. IOW,
> with a blacklist you'd be on constant defense. Remember how early spam
> protection systems just blocked spammers email addresses? How'd that
> work out, anyway?
>
> Also... the FIXMEs in that code doesn't exactly inspire confidence.
>
> No nock against lxml here -- it's an incredible toolkit, and I use it
> all of the place for general XML and HTML parsing. But security is
> *hard* stuff; it's worth being paranoid about your tools.
>

I did start to use lxml.html.clean on my project. I tested it (very
casually) and it seemed to work just fine. However, in one spot in my
code I needed finer control over what tags to allow. According to the
docs and the options, it looked to me like you could operate it with a
white list. However this didn't work out in practice. The options you
give to the cleaner are confusing and seem to contradict each other. I
couldn't get it to do what I wanted. I asked about this on the mailing
list and it was conceeded that the options didn't work together very
well. I also studied the source code a bit and came to the same
conclusion.

I then turned to using Markdown and recalibrated my opinion on what to
allow as input from the user.

Thanks for the link to html5lib though. I will keep that in my back
pocket.

BN
--~--~-~--~~~---~--~~
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 Brian Neal

On Feb 23, 4:59 pm, Jacob Kaplan-Moss 
wrote:
> On Mon, Feb 23, 2009 at 3:50 PM, Andy Mckay  wrote:
> > You want to use a script to only allow certain HTML tags and enforce a
> > whitelist. Don't be naive and just use string or regular expression to
> > strip only a few, there's lots of hacks that can be done. I use the
> > SGMLParser in Plone, here's an old 
> > one:http://code.activestate.com/recipes/52281/
> >  some googling will probably find you more.
>
> Please don't use this. It's very insecure.
>
> Use html5lib (http://code.google.com/p/html5lib/wiki/UserDocumentation)
> and the sanitizing tokenizer instead.

Interesting, I've also come across this:

http://codespeak.net/lxml/lxmlhtml.html#cleaning-up-html

I've heard it is very fast as it is just a python binding to a C-
library...?

>
> Generally, stripping HTML of anything dangerous is *very*, *very*
> difficult to get right. In fact, it's so hard you shou;d try to avoid
> it if at all possible -- markup languages like markdown, texttile, and
> restructured text are a good choice as a replacement.

I've been using Markdown after seeing it used in many places. There is
a safe mode that instructs it to escape the HTML it would normally
allow. Check the django source for usage.

BN
--~--~-~--~~~---~--~~
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: Add views to admin interface

2009-02-15 Thread Brian Neal

On Feb 15, 1:06 pm, Robert  wrote:
> Hi,
>
> how can I add views to the admin interface that
> 1. they are also so 'well-integrated' in the admin interface like
> models
> 2. I can also define permissions for them like for a model
>
> I know that it's possible to change a template (i.e. index.html) and
> add there the code, but that doesn't satisfy me because neither the
> one nor the other point above is done...
> Best would be if there were a possiblity to register them like models
> (admin.site.register(View, ViewAdmin)...
>
> Greetz Robert

I'd like to hear more about this as well. The Django docs don't say
much about this, but the Django Book still has a section on this that
is still relevant to 1.0. See http://www.djangobook.com/en/1.0/chapter17/
and scroll down to the section titled "Creating Custom Admin Views". I
used the advice in there to create a custom admin view that allowed a
site admin to send a bulk email to all people registered with the site
email list.

I'm not quite sure if this is what you are asking about, but look it
over and see.

Best,
BN
--~--~-~--~~~---~--~~
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: Documentation for Download?

2009-02-12 Thread Brian Neal

On Feb 11, 10:11 pm, Will Hardy  wrote:
> Hi all,
>
> Should the release tarball maybe contain pre-build html and pdf documentation?
> That might be handy for those who don't want to install sphinx/latex etc.
>
> Cheers,
>
> Will

See the recent thread on why this hasn't been done to date.

But after watching all the fuss yesterday I decided to try to generate
the docs myself. It basically went like this:

$ sudo easy_install Sphinx
$ (cd to docs directory)
$ make html

Works for me. :)

After doing some reading about Sphinx I'm not sure why you would not
want to have it installed.

Best,
BN
--~--~-~--~~~---~--~~
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: Serialization

2009-02-05 Thread Brian Neal

Russ said it better than me. You simply return the serialized JSON
string as the HttpResponse. You then deserialize it somehow in the
client's Javascript code (perhaps with an "eval" statement or by the
assistance of a Javascript library like jQuery, etc.). You then have a
nice Javascript object that you can manipulate and use to add points
to the map in Javascript.

I have implemented something like this before with PHP and Javascript.
I am converting it to my Django powered site. My current client code
is straight Javascript. This time I intend to leverage jQuery to make
my code smaller, and hopefully a bit more portable.

If you want to see how I did it in plain old Javascript, my old code
can be found here:
https://sourceforge.net/projects/membermapnuke/

If you drill into the code look for mmap.js for the client side stuff
and ajax.php for the server side. I'm porting this to Django at the
moment, and I'm looking forward to trying out Django's serializer for
this.

Best,
BN

On Feb 4, 11:41 pm, issya  wrote:
> Thanks for the reply Russ. I will check into different things, you
> make it sound easier than it looks. :)
>
> On Feb 4, 11:33 pm, Russell Keith-Magee 
> wrote:
>
>
>
> > On Thu, Feb 5, 2009 at 1:09 PM, issya  wrote:
>
> > > Thanks for the reply. I was aware of that but I guess I don't
> > > understand how to go about using it. I do understand that I can
> > > serialize a queryset. But I cannot just go and use the serialized data
> > > as template context. From the options I've seen, it looks like if I
> > > did something like that I would have to process everything with the
> > > javascript including iterating through the data and making an html
> > > layout. I may be confused though, little sleep and a lack of knowledge
> > > will do that.
>
> > There is no need for templates to be involved at all. Django's
> > serializers will turn a queryset into a serialized string. That string
> > can be provided literally as the content for a HttpResponse (just
> > remember to set the content type for the response to suit the
> > serialization format). You don't need to go through a template
> > rendering process on top of this.
>
> > What you then do on the client side is entirely up to you - jQuery
> > provides some nice deserialization methods for AJAX requests, but
> > there are many other options.
>
> > Yours,
> > Russ Magee %-)- 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: Serialization

2009-02-04 Thread Brian Neal

Hi -

I'm working on a very similar problem (displaying data on a Google
map). I haven't totally implemented this yet, but my way forward is to
use AJAX to request the map data from my Django application, which
will serve it as JSON (by serializing it). You then "deserialize" it
in the Javascript code, turning it into a Javascript datastructure on
the client side. If you are using jQuery for example, jQuery will
deserialize it for you. If you are writing the Javascript by hand, you
deserialize it by doing an "eval" on the received data.

BN

On Feb 4, 10:09 pm, issya  wrote:
> Thanks for the reply. I was aware of that but I guess I don't
> understand how to go about using it. I do understand that I can
> serialize a queryset. But I cannot just go and use the serialized data
> as template context. From the options I've seen, it looks like if I
> did something like that I would have to process everything with the
> javascript including iterating through the data and making an html
> layout. I may be confused though, little sleep and a lack of knowledge
> will do that.
>
> I was just trying to check to see if you could maybe deserialize it
> with a custom template tag or some other easy thing.
>
> On Feb 4, 10:45 pm, Russell Keith-Magee 
> wrote:
>
> > On Thu, Feb 5, 2009 at 8:35 AM,issya wrote:
>
> > > My ideal situation would be to initially load the data through ajax
> > > and update through ajax. But I cannot find an easy way to do this. If
> > > I searialize the data, I don't see an easy way to deserialize it.
>
> > Are you aware of the following:
>
> >http://docs.djangoproject.com/en/dev/topics/serialization/
>
> > ?
>
> > Yours,
> > Russ Magee %-)
--~--~-~--~~~---~--~~
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: Form Data is not saving to database

2009-02-04 Thread Brian Neal

On Feb 3, 11:02 pm, Praveen  wrote:
> Oops... yeah Brian that i forgot to make it as a foriegn key to the
> user table and that might be surprised without making foriegn key i
> did not get any error even though my settings.DEBUG is true. but now i
> made user field in MemberProfile but the same problem my form data is
> not saving to foriegn key.
>
> Please assume the user as foriegn key to the user table on same link
>
> http://dpaste.com/116096/
>
> or may see herehttp://dpaste.com/116432/
>
> Thanks

Well, I'm not sure you are catching the right exception. If you look
at the source code to get_profile() you can see it raises
SiteProfileNotAvailable, not ObjectDoesNotExist (I'm assuming you are
running trunk or something recent). However I would still expect you
to receive a 500 error for the uncaught exception.

Why don't you try running the code interactively in the python shell
and see what happens? Do something like:

$ python manage.py shell
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(pk=xxx)# where xxx is a key you know has a profile
>>> p = u.get_profile()

Just make sure that works first without an exception. That may tell us
something.

It is also strange that you are passing in request.user to the
form.save(), but then you turn around and get another user object
(user_obj). Your profile is calling user.get_profile(), but you are
saving the 2nd user (user_obj.save()). Probably not your problem, but
you might want to clean up that code. I'm not sure why you are saving
user_obj anyway, you don't seem to change it. And finally your form
save() method isn't returning anything explicitly (and thus implicitly
returning None), but your form code is catching the return value
(although you don't do anything with it).

Good luck.
--~--~-~--~~~---~--~~
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: Form Data is not saving to database

2009-02-03 Thread Brian Neal

On Feb 3, 6:36 am, Praveen  wrote:
> http://dpaste.com/116096/

The user field in your MemberProfile is a CharField (I was expecting
it to be a ForeignKey to the User table).

I think the problem is you can't assign request.user to a CharField
(line 31). I'm surprised you don't get an error on line 34. Is
settings.DEBUG True?
--~--~-~--~~~---~--~~
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: media files apache/modpython windows

2009-01-28 Thread Brian Neal


On Jan 28, 3:51 pm, Karen Tracey  wrote:
> On Wed, Jan 28, 2009 at 3:39 PM, May  wrote:
>
> > Hello,
>
> > I have the admin templates with CSS working under local server windows/
> > apache/modpython.  Now I would like to get my site css files to work
> > under apache.
>
> > The settings and http.conf code is here:
> >http://dpaste.com/114010/
>
> > I can place mysite css and images under the apache htdocs, but I can't
> > seem to get apache to read them when I type this into my css link:
>
> > http://127.0.0.1/css/stylesheet.css"; rel="stylesheet"
> > type="text/css" media="screen">
>
> > Thanks for any help.
>
> You've got Apache set up to route everything to mod_python except for a
> Location block that specifies '/media/', where you have specified SetHandler
> None.  So any URL that starts with /media/ will get handled by Apache
> directly.  But your href value above doesn't start with /media/, it starts
> with /css/, so this request gets routed to mod_python.  If you want Apache
> to handle it directly you'll need to change it so that it starts with
> '/media/', not '/css/'.
>
> Karen

You should also review the Django docs on all the settings. Your
MEDIA_ROOT should be a path, not a URL. Your ADMIN_MEDIA_PREFIX should
not be the same as your MEDIA_URL.

Basically you setup a directory somewhere, usually in your httpdocs
directory for your media files. That is your MEDIA_ROOT. Put your
static files there. Your admin files have to go under there too,
somehow. This can be by symlink or by copying the django admin files
in there. This is covered in the django docs on deploying under Apache/
mod_python. Your ADMIN_MEDIA_PREFIX will be put in front of any admin
static file.

Settings docs:
http://docs.djangoproject.com/en/dev/ref/settings/#ref-settings

Deploying on Apache/mod_python docs:
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#howto-deployment-modpython

Good luck!
--~--~-~--~~~---~--~~
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: http links without using URLs.py

2009-01-27 Thread Brian Neal

On Jan 27, 11:06 am, May  wrote:
> Hello,
>
> The tutorial suggests not serving the static pages with this method on
> a permanent basis.  Are you using this method for your production
> server?  I'm using windows/apache/modpython and I've tried using the
> IP address and still run into django url requests.  Do you know of a
> way to get apache to override django?
>
> Thanks,
>
> Ana

You might want to look into using the contributed app Flatpages for
these static pages.

http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/

Alternatively, in an Apache environment, you could use the location
directive to tell Apache not to send requests for certain files in a
certain directory through mod_python. This would be similar to telling
Apache not to send media files through mod_python, as discussed here:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1

Maybe something like:


SetHandler None


Then put all your static html files in that directory.

BN

--~--~-~--~~~---~--~~
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 upload problems (sorry for yet another one)

2009-01-26 Thread Brian Neal

On Jan 26, 11:51 am, PeteDK  wrote:
[...]
> The thing is. Now it still doesn't work through my website, however it
> now works through admin.
> Well it only works with .bmp pictures. Maybe my PIL is broken? could
> that be the reason for my problem from before?

As I recall, PIL out of the box only handles a very small number of
file formats. When I installed it, I had to ensure several pre-
requisites were met before PIL would handle jpegs and even gifs (maybe
- my memory is fuzzy on that one). Once I had the prerequisite
packages, I recompiled PIL and all was fine: I could then handle
jpegs.

Try this. Just get into the Python shell and try to manipulate some
images interactively. I would expect that you would be getting error
messages from Django however. But try that just to see what happens.

BN
--~--~-~--~~~---~--~~
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 upload problems (sorry for yet another one)

2009-01-26 Thread Brian Neal

On Jan 26, 9:16 am, PeteDK  wrote:
> Hi there :)
>
> first the code:
>
> forms:
> class ProfileForm(forms.Form):
>         ...
>         image = forms.ImageField(required = False)
>
> models:
> class Profile(models.Model):
>         user = models.ForeignKey(User, unique=True)
>         
>         image = models.ImageField(upload_to="images/", blank=True, null=True)
>
> views:
>                         formP = ProfileForm(request.POST,request.FILES)
>                         if formP.is_valid():
>
>                                 profile = user.get_profile()
>                                 image = formP.cleaned_data['image']
>                                 if image:
>                                         print "image test"
>                                         
> profile.save_image_file(image.filename, image.content,save=False)
>                                 profile.save()
>
> I have installed PIL and i don't get any error messages of any sort.
> however if i try to print image it just prints "None". and "image
> test" never gets printed.
> I have also set media root and URL and all that in my settings file.
>
> I could really use some help here :-(
>
> Maybe i have to import something, but somehow i think that i'm not
> just not getting my image file back.
> Oh and i have tried .png aswell as .jpeg

HmmYou haven't shown your template. Do you have the correct
enctype attribute set on your  tag?

http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form

If you forgot this, the form would still validate because your image
field has required=False.

BN


--~--~-~--~~~---~--~~
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 and WMD editor

2009-01-26 Thread Brian Neal

On Jan 26, 7:40 am, Gath  wrote:
> Good people!
>
> How can i hook up WMD editor on my django form?
>
> http://wmd-editor.com
>
> Paul

You just have to get your page to include the correct CSS and
Javascript files, just like any other editor like this. If this is a
public facing form, check out the docs on form media:

http://docs.djangoproject.com/en/dev/topics/forms/media/

If it is for the admin area, you can do something similar:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-media-definitions

Best,
BN

PS. You may also like the markitup! editor: http://markitup.jaysalvat.com/home/
--~--~-~--~~~---~--~~
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: Where can i get a wiki formatting widget?

2009-01-24 Thread Brian Neal

On Jan 24, 10:23 am, Brian Neal  wrote:
> On Jan 24, 9:44 am, Gath  wrote:
>
> > Guys
>
> > Where can i get a wiki formatting widget for django?
>
> > I have enough notes fields in my models and i would want a nice wiki
> > widget for entering data!
>
> > Paul
>
> I'm using the markItUp! javascript editor to enter Markdown syntax, it
> is very nice and it can also be configured to do wiki syntax:
>
> http://markitup.jaysalvat.com/home/
>
> Best,
> BN

Of course you'll need some software on the server side that translates
the wiki markup to HTML. I'm not familiar with that part. But there is
great Textile and Markdown support in Django. See:

http://docs.djangoproject.com/en/dev/ref/contrib/#markup

Best,
BN
--~--~-~--~~~---~--~~
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: Where can i get a wiki formatting widget?

2009-01-24 Thread Brian Neal

On Jan 24, 9:44 am, Gath  wrote:
> Guys
>
> Where can i get a wiki formatting widget for django?
>
> I have enough notes fields in my models and i would want a nice wiki
> widget for entering data!
>
> Paul

I'm using the markItUp! javascript editor to enter Markdown syntax, it
is very nice and it can also be configured to do wiki syntax:

http://markitup.jaysalvat.com/home/

Best,
BN
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Style Question: Template tag or include?

2009-01-23 Thread Brian Neal

I have an object that I display on multiple pages. Initially I created
a little template .html file for it, and I simply

{% include 'my_object.hml' %}

every where I need it.

I have since discovered inclusion tags. Would it be better, worse, or
just different to do this instead?

{% load my_tags %}
..
..
{% display_my_object obj %}


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: JavaScript Slider in Django Form

2009-01-23 Thread Brian Neal

On Jan 23, 2:43 pm, oboedude  wrote:
[...]
> How do I create a custom widget and what do I have to do to use my
> custom widget in a form?

Read the documentation on forms, then checkout the section on form
media:

http://docs.djangoproject.com/en/dev/topics/forms/media/#topics-forms-media

I've integrated several jQuery plugins using both Widget and Form
media hooks that Django provides.

Best,
BN
--~--~-~--~~~---~--~~
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 tag not rendered - why not?

2009-01-17 Thread Brian Neal

I ran into this also.

I need to do a {% get_comment_form for story as form %} early on in
the template so I can do {{ form.media }} inside a block. I found that
I had to call get_comment_form twice, once in a block for CSS and once
in the block for content.

{% extends 'base.html' %}
{% block custom_js %}
{% get_comment_form for story as form %}
{{ form.media }}
{% endblock %}
.. a bunch of stuff omitted
{% block content %}
..
{% get_comment_form for story as form %}
{{ form.as_p }}
...
{% endblock %}

If I put the get_comment_form tag outside of these blocks, the render
method is never called.

Thanks.
BN

On Jan 12, 11:49 am, "Rachel Willmer"  wrote:
> Answering my own question...
>
> It seems that I can fix the problem by moving the call to inside the block.
>
> So my template needs to look like
> {% extends "base.html" %}
>
> {% load mytaglibrary %}
>
> {% block content %}
> {% get_mytag as mytag %}
> {{ mytag.name }}
> {% endblock %}
>
> whereas before the line with get_mytag was outside the block.
>
> Rachel
>
> 2009/1/12 Rachel Willmer :
>
> > I'm debugging a template tag which used to work under V0.96 and now
> > doesn't under V1.
>
> > Using logging, I can see that its __init__ function iscalled, 
> > butrenderisn't.
>
> > Any pointers as to why or how I debug this would be very gratefully received
>
> > Rachel
--~--~-~--~~~---~--~~
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: How to add tinyMCE to django 1.0.2 admin

2009-01-13 Thread Brian Neal

On Jan 13, 3:43 pm, "Oleg Oltar"  wrote:
> Hi!
>
> I want to add tinyMCE to my project's admin site.

You didn't list any admin.py code. Check out the docs on the admin
interface:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django.contrib.admin

After you read through that, pay attention to the ModelAdmin media
definitions:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-media-definitions

It is there you specify the tinymce javascript files. When the admin
displays the form for your models it will generate the appropriate
script tags to the javascript files.

Good luck!
BN
--~--~-~--~~~---~--~~
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: Extending Admin Interface - Image Manipulation After Upload

2009-01-13 Thread Brian Neal

On Jan 13, 12:06 pm, Ty  wrote:
> I've started creating a photo blog project to get familiar with Python
> and Django. I'm using Python 2.6.1 and Django 1.0.2. I'm working on
> the models and the administration first, before I tackle the front end
> side of the site. I have everything working fine, for the exception of
> an image upload field in the administration.
>
> I assume I'm just going to have to add an "ImageField" in the model.
> That I get, however, every time a new image is uploaded I want to
> resize and save a few copies of the images for thumbnail use, and I
> don't know how to go about extending an administration form like that.
>
> I've been looking around and I've seen the save method in the model
> class. For example I'm using this to come up with the post title slug:
>
>     def save(self):
>         self.name_slug = re.sub('[^a-zA-Z0-9]', '_', self.name).strip
> ('_').lower()
>         self.name_slug = re.sub('[-]+', '_', self.name_slug)
>         super(Entry, self).save()
>
> Should I add the image manipulation code in the save method? What is
> the best way to go about this issue?

Yeah I would (and have) done that type of stuff there. See also the
documentation for the admin interface and overriding the save_model
method on admin.ModelAdmin. You can hang custom behavior there also,
if you only want that behavior when you save a model from the admin
interface.

>
> On another note, is there a good resource for image manipulation in
> Python?

I've used the PIL (Python Imaging Library) to manipulate images. Be
aware that there are other django pluggable applications that you
could use also: search for django Photologue, django-thumbs, and
django-sorl. It is fairly easy to manipulate images with PIL so I just
rolled my own. I used Photologue in a previous project, it is a
fantastic full-blown gallery app for django.

Have fun!
BN
--~--~-~--~~~---~--~~
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: new django user - no images appear on my site :(

2009-01-12 Thread Brian Neal

On Jan 12, 6:45 pm, Brian Neal  wrote:
> On Jan 12, 4:58 pm, jazztpt  wrote:
> [...]
>
> > Brian, you understood me perfectly -- when I was asking about a tag, I
> > was simply asking if django used a shortcut the way rails does, and
> > {{MEDIA_URL}} is what I was looking for.  Duh.  :P
>
> > However, {{MEDIA_URL}} currently returns nothing.  I can't seem to
> > access any of my settings.py vars from my views; I get no errors but
> > no var either, it's just blank.  I've tried both relative and absolute
> > paths; my current code is this:
>
> [...]
>
> From the docs:
>
> "If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every
> RequestContext will contain a variable MEDIA_URL, providing the value
> of the MEDIA_URL setting."
>
> So, does your TEMPLATE_CONTEXT_PROCESSORS in your settings.py file
> contain django.core.context_processors.media?
>
> Regards,
> BN

Sorry, posted too soon. Also, you have to send an instance of
RequestContext to your templates.

I quote from the docs again:

"
def some_view(request):
# ...
return render_to_response('my_template.html',
  my_data_dictionary,
  context_instance=RequestContext
(request))
"

So, 1) ensure your TEMPLATE_CONTEXT_PROCESSORS contains the media
processor, and then 2) pass a RequestContext to your templates.

Hope that helps,
BN
--~--~-~--~~~---~--~~
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: new django user - no images appear on my site :(

2009-01-12 Thread Brian Neal

On Jan 12, 4:58 pm, jazztpt  wrote:
[...]
>
> Brian, you understood me perfectly -- when I was asking about a tag, I
> was simply asking if django used a shortcut the way rails does, and
> {{MEDIA_URL}} is what I was looking for.  Duh.  :P
>
> However, {{MEDIA_URL}} currently returns nothing.  I can't seem to
> access any of my settings.py vars from my views; I get no errors but
> no var either, it's just blank.  I've tried both relative and absolute
> paths; my current code is this:
>
[...]

>From the docs:

"If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every
RequestContext will contain a variable MEDIA_URL, providing the value
of the MEDIA_URL setting."

So, does your TEMPLATE_CONTEXT_PROCESSORS in your settings.py file
contain django.core.context_processors.media?

Regards,
BN
--~--~-~--~~~---~--~~
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: new django user - no images appear on my site :(

2009-01-12 Thread Brian Neal

On Jan 12, 2:59 pm, jazztpt  wrote:
>
> That page in the docs doesn't say anything about how to call this from
> the view.  Are these files automatically accessed by an  tag?  I
> didn't see any special image tag (like the image_tag in rails) in the
> template tags or in my search of the docs.
> Thanks
>
>
Look at this:
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media

Using that makes {{ MEDIA_URL }} available in your templates. Then you
can write stuff like 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Markdown filter piped into custom filter

2009-01-11 Thread Brian Neal

On Jan 11, 11:27 am, Brian Neal  wrote:
> I wrote a filter that searches for patterns in text and replaces them
> with  tags:
>
> {{ comment.text|smilify }}
>
> It does various silly things like replace :-) with an actual smiley
> face image. Seems to work great.
>
> When I combine it with the markdown filter, like this:
>
> {{ comment.text|markdown:"safe"|smilify }}
>
> It seems to escape the HTML that the markdown filter produces. In
> other words if my comment text is ":-)" then the output I get (when
> viewing the raw HTML source of the document) is <p> src="..." ... /></p>
>
> Is it not possible to use the markdown filter like this? Or is the
> markdown filter supposed to mark its output as safe and my filter is
> incorrectly escaping it?
>
> The source for my filter is here:
>
> http://dpaste.com/107803/
>
> Thanks!

Okay I think I figured it out. I studied the existing filters a bit.
You can test the input value to your filter function with "isinstance
(value, SafeData)". If so, you don't need to escape 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Markdown filter piped into custom filter

2009-01-11 Thread Brian Neal

I wrote a filter that searches for patterns in text and replaces them
with  tags:

{{ comment.text|smilify }}

It does various silly things like replace :-) with an actual smiley
face image. Seems to work great.

When I combine it with the markdown filter, like this:

{{ comment.text|markdown:"safe"|smilify }}

It seems to escape the HTML that the markdown filter produces. In
other words if my comment text is ":-)" then the output I get (when
viewing the raw HTML source of the document) is 

Is it not possible to use the markdown filter like this? Or is the markdown filter supposed to mark its output as safe and my filter is incorrectly escaping it? The source for my filter is here: http://dpaste.com/107803/ 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: What is Django/python equivalent of this - Display textarea content with line breaks in html page?

2009-01-10 Thread Brian Neal

On Jan 10, 8:13 pm, zweb  wrote:
> Javascript:
> document.getElemnetById(’textareacontent’).value.replace(/\n/
> g,’’);
> PHP:
> preg_replace(”/\n/”,””,$_REQUEST['t1']);
> Ruby:
> (teaxtareacontent).gsub(/\n/,””)
>
> ( reference 
> -http://rkutti.wordpress.com/2008/01/31/display-textarea-content-with-...)

I'm not exactly sure what you mean, as you don't want to put a 
inside a text area without escaping it.

If you are talking about displaying text that you got from a text
area, then the PHP idiom is nl2br().

In Django templates, see the linebreaks and linebreaksbr filters:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
--~--~-~--~~~---~--~~
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: How does django.contrib.auth.views.login work?

2009-01-09 Thread Brian Neal

On Jan 9, 11:06 am, scelerat  wrote:
> Hi, I'm new to Django and am trying to figure out how to make
> authentication work in any view.
>
> First off, I have a base template which has a conditional like this:
>
> {% if user.is_authenticated %}
> Yay!
> {% else %}
> Boo.
> {% endif %]
>
> In an accounts/urls.py, I add a line like this:
>
> urlpatterns = patterns('',
>     (r'^login/$', 'django.contrib.auth.views.login'),
>     (r'^logout/$', 'django.contrib.auth.views.logout'),
> )
>
> I copied the form from the Djangoprojects page on user authentication
> into a registration/login.html template.
>
> When visiting accounts/login for the first time, I get 'Boo.' but if I
> login and return to this login page, I get 'Yay.'
>
> If I go to any other view (all of them use the same base template), I
> only get 'Boo.'
>
> I looked through django.contrib.auth.views.login, and couldn't find a
> 'user' variable actually being set. Is this magic? How do I get the
> magic to work for all my views?

If you use RequestContext and have the settings in your
TEMPLATE_CONTEXT_PROCESSORS, then the user variable will be available
for use in your templates. Check out:

http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext
--~--~-~--~~~---~--~~
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: Process file after upload

2009-01-07 Thread Brian Neal

On Jan 7, 7:32 am, dmishe  wrote:
> Hey.
>
> I have FielField in my model for user to upload ZIP-archives. I want
> to unpack that zip, place some files in some dirs and delete it just
> after user uploaded it in admin.
>
> How can i do this? Model's save won't work because it gets called
> everytime model is saved regardless of were the file uploaded again or
> not. Custom storage/upload handler seems too complicated for this.

Check out the save_model() method that you can override in your
ModelAdmin class. You can add custom logic there.

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change

Best,
BN
--~--~-~--~~~---~--~~
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: Pagination Suggestions

2008-12-24 Thread Brian Neal

On Dec 24, 3:54 pm, kev  wrote:
> Hello,
> Im trying to create a digg type pagination. Is there a decent
> pagination app already out there that works for 1.0? I tried looking
> but havent succeeded.
>
> Thanks,
> Kev

I'm using this. Works great!

http://www.djangosnippets.org/snippets/773/
--~--~-~--~~~---~--~~
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: setting the proper file permisions chmod

2008-12-15 Thread Brian Neal

On Dec 15, 10:53 am, garagefan  wrote:
> how would i make the group include apache?
>
Not sure what you are asking. I look in /etc/group to see what groups
apache belongs to. On my system, apache belongs to a group called
apache. So I did something like:

# chgrp apache uploads
# chmod 775 uploads

--~--~-~--~~~---~--~~
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: setting the proper file permisions chmod

2008-12-15 Thread Brian Neal

On Dec 15, 9:51 am, garagefan  wrote:
> Just wondering if anyone else has experience with setting the write
> permissions for apache using mod_python w/ django.
>

Instead of 0777 I use 0775. I chgrp on the uploads directory, making
the group be a group that includes the apache user.
--~--~-~--~~~---~--~~
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 uploading via admin, and an error...

2008-12-10 Thread Brian Neal

On Dec 10, 2:20 pm, garagefan <[EMAIL PROTECTED]> wrote:
> getting this error:
>
> "Upload a valid image. The file you uploaded was either not an image
> or a corrupted image."
>
> tried with a gif and with a jpg. I've got PIL installed..."

You may not have the correct libraries installed for PIL to work with
gif's and jpegs. I think I ran into this. I believe there is something
in the PIL docs that notes this and tells you what other packages you
need to install to support those formats.

Best,
BN
--~--~-~--~~~---~--~~
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: Generate a simple news archive list?

2008-12-10 Thread Brian Neal

On Dec 10, 2:31 pm, David Lindquist <[EMAIL PROTECTED]> wrote:
> Hello,
> I am building a simple news app for my employer's website. I am using
> Django's date-based generic views for the various pages. I want to
> have a sidebar listing the archive by year and month like this:
>
> 2008
>
> - November
> - December
>
> 2009
>
> - January
>
> with each item linking to its view (year, month)
>
> I have seen this a thousand times on websites, and it seems like it
> should be a fairly easy thing to accomplish. But I can't figure out
> how to craft a QuerySet to give me what I want. I suspect I need to
> use {% regroup %} in the template as well. I just can't put it all
> together.
>
> Can someone point me in the right direction?

Just what the doctor ordered:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#dates-field-kind-order-asc

Regards,
BN
--~--~-~--~~~---~--~~
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: Index page using flatpages

2008-12-10 Thread Brian Neal

On Dec 10, 1:58 pm, Nuno Machado <[EMAIL PROTECTED]> wrote:
> Hi Brian. Thank you.
>
> I've read the documents you pointed out. But the issue is not on
> 404/500 html templates, but in the DEBUG setting.

No, it isn't.

>
> I've started a project from scratch to reproduce my error. I used the
> instructions provided in the latest documentation to add FlatPages and
> an Admin application.
>
> When I add a FlatPage for my site index page (URL = /) it works fine.
>
> Then, if I change the DEBUG flag to False in my settings.py, the index
> page is replaced by a 500 error.

That's because you don't have a 404.html or 500.html template.

> I think this is a bug. If someone has the same behaviour it should be
> reported.

It isn't a bug. Read the docs. Create yourself an empty 404.html and
500.html file in your templates directory and your flatpage will work
with DEBUG=False.
--~--~-~--~~~---~--~~
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: Index page using flatpages

2008-12-10 Thread Brian Neal

On Dec 10, 11:48 am, Nuno Machado <[EMAIL PROTECTED]> wrote:
>
> My urls.py WAS like this:
>
> urlpatterns = patterns('',
>     (r'^admin/(.*)', admin.site.root),
>     (r'', include('django.contrib.flatpages.urls')),
> )

This is your problem. Did you read this:

http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#ref-contrib-flatpages

Note the 4 step installation. The docs don't say to add anything to
your URLs.

> If I hit, localhost:8000 it __works fine__ BUT if I set DEBUG = False
> in settings.py I get a 500 error TemplateDoesNotExist. With DEBUG =
> False, if I type localhost:8000/about it doesn't work either.
>
> This is getting worse.

No, not really. You are now running into another issue when you have
DEBUG=False. Please see this:

http://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views

You need to define your own 404.html and 500.html templates. When
DEBUG=True, django let's you off the hook on this (because it will
display its own error page for you).

>
> But I'm really thinking in give up from Flat Pages... it's static
> content, why do I want them in a database? Databases are for raw
> content, not html tags.

Well no, not necessarily. Sometimes you have content that you may want
to edit from time to time without messing with the code and possibly
restarting the server. Or you may have someone who works on the site
who doesn't know HTML and you've given him TinyMCE or another WYSIWYG
editor installed on the flatpages admin.

>
> There are some fancy options in Flat Pages, like "Enable comments" and
> "Registration Required" but I think I will easily add these features
> in my static pages later, am I wrong?

Sure you can do it either way.

BN
--~--~-~--~~~---~--~~
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: More User/Profile troubles

2008-12-04 Thread Brian Neal

On Dec 4, 11:08 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I apologise for spamming everyone, here i stuck it up at dpaste with
> the comments which makes it a bit clearer-http://dpaste.com/96128/
>
You are almost there. You are assigning a form instance to your custom
profile's user foreign key. That is not what you want. You want to
assign the appropriate user instance to that foreign key field.

Instead of:
extraformedit.user = userformInstance

Try this:
extraformedit.user = request.user
or
extraformedit.user = userforminstance.user

Another suggestion: you probably need to check to see if both forms
are valid before going ahead with the saving.

if form.is_valid() and extraform.is_valid():

I recently did something similiar, I found my code and dpasted it. In
my case I am showing the view for a user to edit her existing profile.
I hope it helps:
http://dpaste.com/96150/
--~--~-~--~~~---~--~~
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: No module named MySQLdb

2008-12-03 Thread Brian Neal

On Dec 3, 5:54 pm, Udbhav <[EMAIL PROTECTED]> wrote:
>
> Whenever I point my browser at twinsistermusic.com/mysite/ I get the
> following error:
>
> ImproperlyConfigured: Error loading MySQLdb module: No module named
> MySQLdb
>
> Now, I'm pretty sure I installed MySQLdb correctly, as I was able to
> use syncdb with no problems and am able to import MySQLdb from within
> the Python interpreter.  So, what gives?

Perhaps apache (or whatever user apache runs under in your system)
doesn't have permission to read/execute wherever you installed
MySQLdb?

I think I had this issue. I also ran into the "egg" issue for MySQLdb,
which is documented in the FAQ.
--~--~-~--~~~---~--~~
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: More User/Profile troubles

2008-12-03 Thread Brian Neal

On Dec 3, 12:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> ...
> And here is my view for my signup page -
>
> def signup(request):
>     if request.method == 'POST':
>         form = UserCreationForm(request.POST)
>         extraform =  CustomProfileForm(request.POST)
>         if form.is_valid():
>             form.save()
>             extraform.save()
>             return HttpResponseRedirect("/")
>     else:
>         form = UserCreationForm()
>         extraform =  CustomProfileForm()
>
>     return render_to_response('signup.html', {
>         'form': form,
>         'extraform': extraform
>     })
>
> This view doesnt work because it is not saving 'user' in
> CustomProfileForm.
>
> Ok now the problem I am having is with the foreignkey in the custom
> profile model, and successfully linking that to the User.

Yes. You need to set the user foreign key inside the extraform before
you save it. See the discussion here about ModelForms save() with
commit=False:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method



--~--~-~--~~~---~--~~
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 1.0 no longer prints higher ASCII?

2008-11-30 Thread Brian Neal

On Nov 30, 9:56 am, Log0 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> This string :
>
> data = ''.join( [ chr(i) for i in xrange(256) ] )
>
> In Django 0.96, this string prints well.
> In Django 1.0, this string simply disappears before going to Apache,
> and the data is never transmitted to the client or even apache.
>
> Why?
> Any fix?
>
> Thanks a lot.

Technically speaking, ASCII is only a 7-bit code.

However, what is your DOCTYPE and charset on the page you are serving?
How are you displaying 'data'?
--~--~-~--~~~---~--~~
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: hidden fields in forms

2008-11-25 Thread Brian Neal

On Nov 25, 6:24 pm, ChrisK <[EMAIL PROTECTED]> wrote:
> > Well..you aren't passing auth_id to the template, you are passing
> > form. auth_id is a field inside your template. Can you post your
> > template?
>
> Oh, sorry - my oversight. Template is
>
> 
>  id="id_auth_id" />
> Reminder String:
>      p>
> URL of document:
>     
> Address of interest:
>     
> Range (in meters):
>     
> 
> 
>
> I guess I'm not clear how to access stuff from inside the form!

Check this out: 
http://docs.djangoproject.com/en/dev/topics/forms/#displaying-a-form-using-a-template

Try using the form.as_p or form.as_table methods. If that doesn't work
for you, you can render each field yourself.

--~--~-~--~~~---~--~~
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: hidden fields in forms

2008-11-25 Thread Brian Neal

On Nov 25, 5:06 pm, ChrisK <[EMAIL PROTECTED]> wrote:
> I'm just not getting this. I've looked at many examples and can't seem
> to pass a hidden value into a form.
>
> The problem is that I initially get to the form with GET, and then
> instantiate the form with PUT. The key that I need is part of the
> original URL, and I'm trying to push it down into the PUT data as
> well, but failing.
>
> I have
>
>  (r'^fences/newFence/(?P.*)$', 'newFence'),
>
> class newFenceForm(forms.Form):
>     teaser = forms.CharField(max_length=40)
>     url = forms.CharField()
>     address = forms.CharField()
>     range = forms.IntegerField()
>     auth_id = forms.CharField(widget=forms.HiddenInput)
>
> def newFence(request, auth_id):
>     if request.method == 'POST':        # if the form has been submitted
>         form = newFenceForm(request.POST)
>         if form.is_valid():
>             # do the geocoding
>             print form.cleaned_data['auth_id']
>             print form.cleaned_data['teaser']
>             print form.cleaned_data['url']
>             print form.cleaned_data['address']
>             print form.cleaned_data['range']
>             # save the object
>             u = User.objects.filter(auth_id = id)
>             # show them the new map
>             return HttpResponseRedirect('../../fences/fenceMap/
> %s'%auth_id)
>     else:
>         print auth_id
>         form = newFenceForm({'auth_id' : auth_id})
>
>     return render_to_response("map/newfence.html", {'form': form, })
>
> I call this with, say, '.../newFence/chris' and the first time through
> it prints 'chris' and instantiates the empty form. But where my
> template says
>
>  id="id_auth_id" />
>
> the string between curlies is always empty.

Well..you aren't passing auth_id to the template, you are passing
form. auth_id is a field inside your template. Can you post your
template?


--~--~-~--~~~---~--~~
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 documentation

2008-11-25 Thread Brian Neal

On Nov 25, 8:44 am, ReneMarxis <[EMAIL PROTECTED]> wrote:
> Hello Brian
>
> i allready saw those hints on the djangoproject/djangobook homepage
> and that was the reason i was writing this post.
> Imagine i am new to django, i read "i have to add those lines to my
> model and do some stuff on the setting.py file and run syncdb" then
> everything is ok and i can use get_profile to load the profile .
> I did that but running get_profile raises exceptions. I took quite a
> bit to realize that the profile does not get generated automaticly
> (checked in db table) but you have to create it by yourself.
> I mean its just one sentense more but it would save many searching on
> the web.
>

Well, if you worked through the tutorial you should know that you need
to run syncdb after creating a new model. Your user profile is a model
after all and it needs to reside in your database for get_profile to
work. To be honest, it seemed to me your post was a thinly disguised
jab at the docs. We all feel the way you do at first, that everything
is hard to find. But if you keep reading the docs and studying other
people's source code (check out all the django apps on
code.google.com), you'll get the hang of this.

I realize we all learn differently and at our own pace. I think that
the django docs are some of the most well written and comprehensive
docs I have seen for an open source web framework. Seriously. Have you
ever looked at another frameworks docs? If you find the docs lacking
on some point, write a Trac ticket. The developers are very responsive
to documentation requests in my one single experience. They understand
the value of good docs.

I also encourage you to get on the IRC channel. You can get fast
pointers from experts that way if you are stuck.

And finally, don't forget the actual django source code. Learning how
to navigate it and find things in it is very useful. If you are
confused about the docs, take a peek at the code. You will also learn
something about python that way.

Enjoy your experience with django!
--~--~-~--~~~---~--~~
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 documentation

2008-11-24 Thread Brian Neal

On Nov 24, 5:18 pm, ReneMarxis <[EMAIL PROTECTED]> wrote:
> hi
>
> as mentioned earlyer today i am very new to django and againe have
> some question, this time reguarding the documentation.
>
> I started django by duing the tutorial, and now i started building my
> own little project from ground up :) but i am lacking of information.
> I am missing some documentation, some good organised api.
>
> E.g. i want to implement AUTH_PROFILE_MODULE to store additional infos
> on the user. The documentation fromhttp://docs.djangoproject.comsays
> "define that in settings.py and in your model and use it via
> get_profile" But no one tells you that you have to create it by
> yourself and save it also. Ok this is something you can try out but
> the information would be placed good on the doc side.

http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
http://www.djangobook.com/en/1.0/chapter12/#cn222

>
> Can anyone give me some link to one good documentation or do there
> exist good books which cover issue's completly so you don't have to
> search most time while learning?

Searching is part of the process of learning.


--~--~-~--~~~---~--~~
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Brian Neal

On Nov 20, 4:50 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> And I do that. Here is my template:
>
No, you are not. Check the dictionary you are passing into your
render_to_response() calls again.
--~--~-~--~~~---~--~~
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 development approach

2008-11-20 Thread Brian Neal

On Nov 20, 3:54 pm, eldonp2 <[EMAIL PROTECTED]> wrote:
> I've spent some time getting comfortable with Django. I would like to
> try writing my first real app. I'd like to know whether I should go
> ahead to write everything from scratch, or whether...
> 1. Using pluggables can be easily integrated into an existing app

Just depends on whether these 3rd party apps fit your use-cases or
not.

> 2. Whether it will be easy to change the look and feel (with CSS)
> afterwards. I want to concentrate on functionality right now.

Well...yes, in my experience it is easy to add CSS later to change the
site. Just sprinkle in some classes and ids in your HTML templates so
you can easily style things later.

> 3. Models, urls, views, forms and templates should be created as
> needed manually - and whether using a CMS would make this task easier.

Not sure what you mean here.

--~--~-~--~~~---~--~~
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: Is it possible to display multiple forms in a single template file?

2008-11-20 Thread Brian Neal

On Nov 20, 4:03 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> VIEW:
>
> def add_product(request):
>     if not request.method == 'POST':
>         form1 = ProductForm()
>         return render_to_response('index.html', {'form1' : form1})
>     else:
>         form1 = ProductForm(request.POST)
>         if form1.is_valid():
>             form1.save()
>             return HttpResponseRedirect('/thanks.html')
>
> def add_product_details(request):
>     if not request.method == 'POST':
>         form2 = ProductDetailForm()
>         return render_to_response('index.html', {'form2' : form2})
>     else:
>         if form2.is_valid():
>             form2.save()
>             return HttpResponseRedirect('/thanks.html')
>
> URLS
> urlpatterns = patterns('',
>
>     (r'^product/$', views.add_product),
>     (r'^product/$', views.add_product_details),
>
> Is this possible? For some reason the 2nd form never shows up

Well you need to pass both forms to the template to get them both to
show up.
--~--~-~--~~~---~--~~
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: admin's media on apache

2008-11-12 Thread Brian Neal

On Nov 12, 3:32 pm, prem1er <[EMAIL PROTECTED]> wrote:
> Still having a problem from the other day.  I can't get the media (css
> + images) to show up on my admin pages after I moved it over to
> Apache.  I tried a sym link from /home/dev/Django-1.0/django/contrib/
> admin/media/ to /home/dev/djprojects/xxx/media (my site root) and
> still no luck.  I have also tried to add an Alias in my Apache
> config.  Here is my Apache config as of now.  Anyone else have
> suggestions I would appreciate it.
>
> 
>     ServerNamewww.dev.xxx.us
>     ServerAlias dev.xxx.us
>     DocumentRoot /home/dev/djprojects/xxx/
>         
>                 Options Indexes FollowSymLinks MultiViews
>                 AllowOverride None
>                 Order allow,deny
>                 allow from all
>                 AddHandler mod_python .py
>                 PythonDebug On
>         
>         
>                 SetHandler python-program
>                 PythonHandler django.core.handlers.modpython
>                 SetEnv DJANGO_SETTINGS_MODULE xxx.settings
>                 PythonDebug On
>                 PythonPath "['/home/dev/djprojects'] + sys.path"
>         
> 

You still don't have a SetHandler None on your media directory. You
need to let Apache serve your media, not django. See
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1
--~--~-~--~~~---~--~~
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 newbie observation

2008-11-12 Thread Brian Neal

On Nov 12, 1:12 pm, ayayalar <[EMAIL PROTECTED]> wrote:
> I've been using Django for about 1-2 weeks now. I must say it is one
> of the most exciting
> web frameworks I ever worked with. It is clean, elegant, easy, and
> most importantly makes sense.
> I've tried to use many other MVC frameworks but Django is by far
> better. However I am also disappointed on a few things about Django
> that I hope it'll get improved with its large community support.
>
> 1) Django is not easy to start for a newbie:
> One of the main reasons is, because of the limited resources. Such as
> books (they get out dated as soon as they're published, due to
> Django's fast changes). Online resources mostly out dated and are not
> kept up to date. (e.g.www.djangobook.com)
>
> 2) Django has drastic changes between releases:
> Oh boy, try to follow the Django book to create an admin site. Turns
> out that with the release 1.x. this has significantly changed from the
> prior release.
>
> 3) There are other minor issues and gotchas blocks you from
> development and requires exhausting googling in order to move forward
> due to lack of up to date documentation, limited resources, and again
> Django's fast changes.
>
> I know Django is new and improving. I just wanted to point out these
> issues a newbie is might be facing.
>

I disagree with "Django is not easy to start for a newbie". The online
docs and tutorial at http://docs.djangoproject.com/en/dev/ are
excellent and are current. The book is out of date, just use it as a
back up to the docs. Also you will get many answers in the IRC channel
and on this group.
--~--~-~--~~~---~--~~
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 not reading css after switch to apache

2008-11-11 Thread Brian Neal

On Nov 11, 1:15 pm, prem1er <[EMAIL PROTECTED]> wrote:
> This is the location of my css files.  /home/dev//Django-1.0/django/
> contrib/...
>
> On Nov 11, 1:49 pm, prem1er <[EMAIL PROTECTED]> wrote:
>
>
>
> > Just got django to work on apache thanks to everyone on this group.
> > After I switched, I can no longer get the CSS to work with the admin
> > page or the 'polls' from the tutorial.  Here is my apache config.
> > When I run the same site from my localhost on django's server
> > everything is fine.
>
> > 
> >     ServerNamewww.dev.xxx.us
> >     ServerAlias dev.xxx.us
> >     DocumentRoot /home/dev/djprojects/xxx
> >         
> >                 Options Indexes FollowSymLinks MultiViews
> >                 AllowOverride None
> >                 Order allow,deny
> >                 allow from all
> >                 AddHandler mod_python .py
> >                 PythonDebug On
> >         
> >         
> >                 SetHandler python-program
> >                 PythonHandler django.core.handlers.modpython
> >                 SetEnv DJANGO_SETTINGS_MODULE xxx.settings
> >                 PythonDebug On
> >                 PythonPath "['/home/dev/djprojects'] + sys.path"
> >         
> > - Hide quoted text -
>

Did you read this?

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

In particular look at the section on serving media files.

--~--~-~--~~~---~--~~
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: In Django 1.0, is there a settings that filters out characters from dynamically generated string?

2008-11-11 Thread Brian Neal

On Nov 11, 10:14 am, Log0 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> So I am using a Django 0.97 for local testing, and shipped a django
> script to a production server on WebFaction with Django 1.0. It spits
> html that consists of random characters from ascii value 0 to 256.
> Works great locally.
>
> To my surprise, it fails in Django 1.0 on WebFaction. If higher order
> ascii is present in the string ( I used chr(184) ), the string did not
> get passed even to Apache, which means I get an empty string instead.
>
> My question is :
> 1. Is Django 1.0 has some kind of internal filter that strips strings
> containing weird ascii value ( 184, 185, etc ) by default? How do I
> turn it off?
> 2. Directly writing the 184 ascii in HTML results in "Unicode Error".
> Unicode? I thought I am using just ASCII?
>
> Thanks a lot!

ASCII is a 7-bit code. There is no character with the value 184 in
ASCII.

--~--~-~--~~~---~--~~
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: An interesting URL dispatcher problem

2008-11-04 Thread Brian Neal

On Nov 4, 10:50 am, redmonkey <[EMAIL PROTECTED]> wrote:
>
> My problem is with the URL writing. I first wrote some unit tests to
> find the regular expressions that worked but Django doesn't seem to
> like the '?' in URL configurations.

? is a special character in regular expressions, just like $, ^, etc.
You must escape it if you want to use it literally, e.g. \?. However,
I don't think the ? as part of any GET arguments in a URL are going to
be available to you, from what I remember about django works.

I'm not really following what you are trying to do however.
--~--~-~--~~~---~--~~
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: How to setup django-apache-mod_wsgi without killing existing php site?

2008-10-30 Thread Brian Neal

On Oct 30, 6:14 pm, Håkan Waara <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I'm in the process of for the first time deploying a django site that  
> (unfortunately) needs to share its Apache with an existing PHP site.
>
> I've been reading a bunch about mod_wsgi and in many places there are  
> mentions that setting up apache with mpm-worker (basically  
> multithreaded mode) will not work if you're also hosting a PHP site on  
> the same Apache; Apache will crash, and the world will collapse...
>
> What I haven't been able to find out is if it's possible/worth it to  
> use mod_wsgi (efficiently) in this situation at all, and if so how to  
> do it?
>
> Does anyone have other suggestions on how to avoid mod_python in this  
> situation? Should I have a look at nginx for example?
>
> Any hints appreciated!
> /Håkan

Well it might also just work. I am running a site with PHP, django via
mod_python, and MySQL without any problems on Fedora Core 6.
--~--~-~--~~~---~--~~
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: Donation Application

2008-10-28 Thread Brian Neal

On Oct 27, 8:03 pm, unklbeemer <[EMAIL PROTECTED]> wrote:
> I did some searching and found nothing. I was wondering if anyone knew
> of any django applications out there for receiving donations and/or
> tracking those donations (capital campaign progress, pledges donated,
> etc.)
>
> Thanks

I'll be porting, well that may be too strong a word...creating a
django app based on the functionality of the (don't laugh) PHP-Nuke
Donations module/block soon. I'm going to use the IPN code that Paul
Kenjora kindly posted here: http://blog.awarelabs.com/?p=74.
--~--~-~--~~~---~--~~
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: tinymce help

2008-10-26 Thread Brian Neal

On Oct 25, 8:47 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> hi.  I'm using django 1.0 over at webfaction.  I have the following
> setup
>
> /static   (serves js, css, flash, images etc)
> /www   (my django app)
>
> I have tiny_mce loaded to /static/js/tiny_mce/
>
> I have followed the steps at this page:  
> http://code.djangoproject.com/wiki/AddWYSIWYGEditor
> in this order:
>
> 1.  Install tiny_mce on your server some where
> 2.  create a textareas.js file  (placed in /static/js/tiny_mce/)
> 3.  created an admin.py file  in my website located at www/learn/ as
> follows:
>
> from django.contrib.flatpages.models import FlatPage
> from django.contrib.flatpages.admin import FlatPageAdmin as
> FlatPageAdminOld
>
> class FlatPageAdmin(FlatPageAdminOld):
>     class Media:
>         js = ('js/tiny_mce/tiny_mce.js',
>               'js/tiny_mce/textareas.js',)
>
> # We have to unregister it, and then reregister
> admin.site.unregister(FlatPage)
> admin.site.register(FlatPage, FlatPageAdmin)
>
> step3 i'm confused on.  This is for newforms with flatpages per the
> documentation.  It is my  understanding that django 1 uses newforms.
> Why won't the admin show the tinymce in place of text areas?

I take it you mean the flat pages part of step 3? I am using TinyMCE
for admin text areas, and it works great. I've never tried it with
flat pages yet. But the reason you have to do that unregister and
register step (for flat pages only), is that because flat pages are a
contributed app, and existing code is already registering a model
admin class for it. If you want to use TinyMCE for flat pages, you
have to create your own model admin for it with the appropriate media
class, undo what the flat pages app already did by unregistering it,
then replacing it with your own.

You don't have to do all that unregister/register stuff for the models
you write.

--~--~-~--~~~---~--~~
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: Cannot get user profile working.

2008-10-24 Thread Brian Neal

On Oct 24, 3:01 pm, kylewild <[EMAIL PROTECTED]> wrote:
> thanks brian, good call
>
> I had read that and somehow not parsed it!
>
> However, I'm still having the issue after changing it to:
>
> AUTH_PROFILE_MODULE = 'chat.userprofile'
>
> (i tried myproject.userprofile as well)
>
> 'NoneType' object has no attribute '_default_manager'
> /home/mochat/webapps/django/lib/python2.5/django/contrib/auth/
> models.py in get_profile, line 293
>

We really need more info before anyone can even guess. Try posting
some code, including your model code and the call site where you are
calling .get_profile().

--~--~-~--~~~---~--~~
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: Cannot get user profile working.

2008-10-24 Thread Brian Neal

On Oct 24, 2:23 pm, kylewild <[EMAIL PROTECTED]> wrote:
> I'm having this same issue and the fix here, as best I can attempt to
> apply it, didn't work for me
>
> I had AUTH_PROFILE_MODULE set to "myproject.UserProfile"
>
> After reading this thread, I changed it to "chat.UserProfile" -- to no
> avail
>
> In my "chat" directory, I have the model "UserProfile" defined in
> models.py -- doesn't that mean "chat" is the name of the app?
>

Read this:
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

I think you want all lower case.
--~--~-~--~~~---~--~~
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: Making queries guide, incomplete code.

2008-10-14 Thread Brian Neal

On Oct 14, 11:35 am, KillaBee <[EMAIL PROTECTED]>
wrote:
> I was reading the Making queries guide on the the 
> website.http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-que...
> It said:
>
> >>> Blog.objects
>
> >>> b = Blog(name='Foo', 
> tagline='Bar')
> >>> b.objects
>
> Traceback:
>     ...
> AttributeError: "Manager isn't accessible via Blog instances."
>
> 
> What is this ... what is it, and why can't the page just say it.
> Please no secrets.
>
> I to do this, in this view all the time.
>
> Blog.objects 
> t = time(user=user, fedtime=fedtime, worked=worked, date=date)
> t.objects
> time.objects.filter( user=username ).filter( PP=44 )

I'm not really sure what you mean. The docs are showing you an example
of interactive Python using the shell. You don't type the above into
your program. You do know about Python's interactive shell, right?

The  Blog.objects 
business is the shell printing out the __unicode__ representation of
an object.
--~--~-~--~~~---~--~~
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: Intensive Computations

2008-10-06 Thread Brian Neal

On Oct 6, 5:53 pm, puzzler <[EMAIL PROTECTED]> wrote:
> That's why I'm asking now, ahead of programming, for more info about
> how hard it is to incorporate an intensive computation into the Django
> framework.  It could very well affect my choice of language.

It is just python, really. So yes, you could do lots of things. You
could have a server running in C++ that your python app hands the
calculations off to. The C++ app could even send the results back to
your python code to store in the database. You have lots of options.
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-06 Thread Brian Neal

On Oct 5, 10:12 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> > So you did this 
> > part?http://code.djangoproject.com/wiki/AddWYSIWYGEditor#UsingTinyMCEwithf...
>
> > Do you have MEDIA_URL and MEDIA_ROOT setup correctly in settings.py?
> > Are you using the development server? Do you have that setup to server
> > static content?
>
> yeah see my previous post.  This is on a live server not a dev.  I've
> got an admin.py file setup per the django doc and have /static setup
> as an application to serve static content.  MEDIA_URL is setup
> correctly and is serving static content.

Okay. I am using TinyMCE with many textareas on my site, however I
have not tried it with flatpages yet, so I can't vouch for those
instructions on the wiki. Can you activate it on a "normal" model in
the admin area? That might narrow it down.
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-05 Thread Brian Neal

On Oct 5, 9:35 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> > Did you see this:
>
> >http://code.djangoproject.com/wiki/AddWYSIWYGEditor
>
> yeah i saw that and tried to follow it.  Here's what i did:
>
> 1.  d/l tinymce
> 2.  uploaded to /static/admin/js/tiny_mce   (i have static setup as an
> app to serve static files)
> 3.  I created a textarea.js file as instructed an put it in that dir
> 4.  I created the admin.py file in /www/myproject
>
> i'm using newforms in the admin

So you did this part?
http://code.djangoproject.com/wiki/AddWYSIWYGEditor#UsingTinyMCEwithflatpagesnewforms

Do you have MEDIA_URL and MEDIA_ROOT setup correctly in settings.py?
Are you using the development server? Do you have that setup to server
static content?
--~--~-~--~~~---~--~~
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: installing tiny mce for flatpages

2008-10-05 Thread Brian Neal

On Oct 4, 3:34 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> hi group.  I need some help getting tinymce installed for flatpages in
> admin.  I'm serving static content from an application called /static/
> with tinymce located in /static/js/tiny_mce/.  I have read the docs on
> creating an admin.py file and have done that as well but it's not
> showing the richtext box... just the textarea.  Is there anyone out
> there that can help?

Did you see this:

http://code.djangoproject.com/wiki/AddWYSIWYGEditor

?

Regards,
BN
--~--~-~--~~~---~--~~
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: recommended method for administrative scripts?

2008-09-26 Thread Brian Neal

On Sep 26, 2:50 pm, ssam <[EMAIL PROTECTED]> wrote:
> Hello
>
> I have just made my first django site for my uncles wedding photos. It
> is very simple, just photos and tags, with a ManyToMany relationship.
> I have only made views for viewing the photos and am using the django
> admin system for uploading and tagging.
>
> I am wondering what is the best way to add scripts to do
> administrative tasks, that dont need to be triggerable by a URL.
>
> For example, a decided that the settings i had used to make the
> thumbnails where to low, and wanted to rerun the thumbnailing on each
> photo. I did this by making a function in views.py that did the
> looping through and resizing. Then adding a URL, and visiting it.
>
> This seemed like a rather kludgy method.
>
> I have a few other tasks that i might want to do. extract the date
> from the photos EXIF data, and put it in a field in the database (i
> already have the field).
>
> also i think i could save some time if it could scp a bunch of photos
> to a folder on my server, and add them into the database with a single
> command.
>
> So is there a recommended method of doing this soft of thing?
>
> Thanks
>
> Sam

Check out the django Photologue application. It's really slick. You
can upload through the admin interface a zip file of photos and it
will create a gallery for you from that. It also automatically resizes
photos according to a set of sizes you specify, and creates them only
on demand.

As for your question about how to make your own admin apps, check out
the online Django book, which has a chapter on how to do that
(suprisingly this isn't really covered in the online Django docs).

BN
--~--~-~--~~~---~--~~
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: Concept Q: Extra model fields for clean templates sake

2008-09-25 Thread Brian Neal

On Sep 25, 4:33 am, Gerard Petersen <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm finding myself creating more and more fields in a model to keep my 
> templates clean. Since it's merely temporary calculated data, and not data to 
> store permanently it feels like the wrong place. An example:
>
> I have a product model (child object of an order model). The product has a 
> 'per_price' and 'amount' field that get filled by the user. I gave the 
> product an extra field called 'total_price' where I store 'amount * 
> per_price' just before my view and my template come together. This way all 
> that's needed to display an invoice is in the objects list.
>
> Calculating this in the template also doesn't seem the way. For MVC's sake I 
> belief this belongs in the view, but then it's to late (read: there's no 
> field on the object) to store temporary stuff.
>
> The Q: How does one relate temporary data to objects in a list, before it's 
> rendered in a template?

In addition to what has already been mentioned, it is also handy to
define convenience functions on your model classes that return
information like this. So your model could be given a total_price()
member function that calculates it based upon member data. These
convenience functions are easily accessed in the template.
--~--~-~--~~~---~--~~
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: A question about spaces and passing variables...

2008-09-24 Thread Brian Neal

On Sep 24, 7:23 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Sep 24, 2008 at 6:37 PM, djandrow <[EMAIL PROTECTED]> wrote:
>
> > So after messing around a for a couple of minutes I discovered the
> > urlencode changes About Me to About%20Me, (if you are using firefox 3
> > or above it will still display "About Me" in the address bar, that
> > confused me for a while).
>
> > But now if i put in:
>
> > url.net/blog/About%20Me/,
>
> > it doesn't match this url pattern:
>
> > ^blog/(?P\w+)/$
>
> > So how can i get this to match the patter?
>
> I think rather you need to make the pattern match all possible values of
> category.  Since you want to take the value from the url and look it up in
> the database, and since you allow spaces in category, your pattern has to
> allow spaces.  (Note that the percent-encoding in the url is automatically
> undone before url mathicng is attempted.  Similarly your view code will get
> the variable passed in with spaces, not '%20' in place of spaces.)  So, if
> your category field can contain any character, then your urlpattern to match
> it should be something like:
>
> ^blog/(?P.+)/$
>
> instead of the \w which disallows spaces (among other characters).
>
> Karen

djandrow, you may also consider using a "slug field" instead of the
category name for your urls if you don't like the url encoding. Many
people do not like spaces in URL's. A slug is a unique key for each
category that is made up of letters, digits, and the dash (-)
character.
--~--~-~--~~~---~--~~
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: Anti-spam suggestions (strange case)

2008-09-24 Thread Brian Neal

On Sep 24, 9:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> We have a simple form that allows site visitors to request a free
> issue of the magazines we publish. The form simply writes to the
> database, and the info is later pulled by the circulation people so
> they can send the issues out. The info does not appear anywhere on the
> site, and is only used to fulfill the request.
>
> My problem is that for some reason spammers have latched onto this
> form, creating a lot of grief when our circulation people are trying
> to send out the requests.
>
> Nearly all of the spammers follow a pattern, giving random strings for
> their address, city and email, like this:
> City: bbaOWiatlF  and email: [EMAIL PROTECTED]
>
> Does anyone have any suggestions on how to weed these goons out?

Maybe use a honeypot field in the form like the comments app does. You
can even label it with a label that says "do not fill in this form or
we will think you are spamming us". Hide this field on the form with
CSS (display: none) so most users with modern browsers won't even see
it. Spammers using automated tools typically fill in random garbage
into all fields on a form. Reject any form submission that has that
field filled in.
--~--~-~--~~~---~--~~
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: ModelChoiceField - remove empty-value

2008-09-22 Thread Brian Neal

On Sep 5, 11:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-09-05 at 03:11 -0700, mwebs wrote:
> > Hello,
>
> > I use amodelchoicefieldand want to remove the entry that represents
> > "no item selected"(--), because in my
> > scenario I will only allow to select between existing entries.
>
> Specify adefaultvalue for the field (one of the choices). Then that
> will be shown as the initially selected option.

I could not find a way to specify a default value.

> The empty choice isn't there because it's a valid option. It's actually
> a useful user-interface feature. If somebody submitted a form without
> making a choice, it would be invalid because the empty "" choice is
> not valid. It's there because you didn't specify adefaultvalue and
> Django doesn't make a choice ofdefaultinitial value for you. The user
> has not yet made a selection, so they must choose one of the options
> explicitly. If they just hit "submit" without making a choice, Django is
> careful to ensure they don't accidentally end up selecting whichever
> option Django displayed first.
>
> Regards,
> Malcolm

Sounds reasonable. However I am using a RadioSelect widget in my "rite-
of-passage" first Django poll app. It looks very weird to see this on
a form (please forgive the crude ASCII art):

Vote Now:
* 
* Yes
* No
[Submit]

However I looked at the django source code and found that you can set
empty_label to None to get rid of that first choice. Here is how I did
it in my form class:

from django import forms
from gpp.polls.models import Choice

class VoteForm(forms.Form):
   """Form for voting in a poll."""
   options = forms.ModelChoiceField(queryset = Choice.objects.none(),
widget = forms.RadioSelect)

   def __init__(self, poll_id):
  super(VoteForm, self).__init__()
  self.fields['options'].queryset =
Choice.objects.filter(poll=poll_id)
  self.fields['options'].empty_label = None

I hope this helps someone!

Best,
BN
--~--~-~--~~~---~--~~
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: Just a note: django web app in django-non-friendly hosting environment

2008-09-20 Thread Brian Neal

On Sep 19, 3:04 pm, "n00m" <[EMAIL PROTECTED]> wrote:
> @Brian Neal
>
> But I think that all your points are not specific to
> django per se. Sorta this.

Huh? They were just as specific to django as yours were.

> +
> Does not "my note" make a question like:
> "Where can I see a list of Django-friendly hosts?"
> pretty meaningless?

No, I was pointing out there may be other issues beyond the ones you
encountered.
--~--~-~--~~~---~--~~
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: Just a note: django web app in django-non-friendly hosting environment

2008-09-19 Thread Brian Neal



On Sep 19, 1:40 pm, "n00m" <[EMAIL PROTECTED]> wrote:
> You need no at all to ask the hoster to install Django
> on his machine.
> Apache (etc) + installed mod_python is quite enough to
> get your django app running.
>
> The django package (and e.g. PIL) can be copied to there
> along with your django web dirs, as if it's a part of your
> web site/app.
>
> Example:
>
> htdocs/
>     my_dirs/
>         django/
>             ...
>         my_django_app/
>             ...
>             settings.py
>             urls.py
>         PIL/
>             ...
>         ...
>
> LoadModule python_module modules/mod_python.so
> 
>     SetHandler mod_python
>     PythonPath "['htdocs/my_dirs'] + sys.path"
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE my_django_app.settings
>     PythonDebug On
> 

That's great that you got it working, but that isn't always the case.
Some hosts will not allow you to edit/have your own .htaccess files or
edit the main httpd.conf file. In addition, I found that I needed a
PYTHON_EGG_CACHE, a directory where apache could write to to extract
eggs. Some hosts aren't going to let you have shell access to chmod a
directory to allow this. Yes it can be done but you may have to work
with your host or purchase your own dedicated hosting.
--~--~-~--~~~---~--~~
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 with url tag (Caught an exception while rendering: Reverse ...)

2008-09-19 Thread Brian Neal



On Sep 19, 12:45 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> That's annoying: now *I* have a (named) pattern that won't reverse with
> the URL tag: specifically, the edit profile URL from the Google code
> profiles app:
>
>                        url(r'^edit/$',
>                            views.edit_profile,
>                            name='profiles_edit_profile'),
>
> When I use
>
>  http://{{ host }}{% url profiles_edit_profile %}">
>
> in my template Django tells me
>
>   File "/home/sholden/Django-1.0/django/core/urlresolvers.py", line 252,
> in reverse
>     *args, **kwargs)))
>   File "/home/sholden/Django-1.0/django/core/urlresolvers.py", line 241,
> in reverse
>     "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for 'PyTeach.'profiles_edit_profile'' with
> arguments '()' and keyword arguments '{}' not found.
>

Does that profiles_edit_profile function exist somewhere? Is that
urls.py in an application that is listed in your INSTALLED_APPS
setting?

--~--~-~--~~~---~--~~
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: How do I set up a python web server on Windows XP?

2008-09-19 Thread Brian Neal

On Sep 19, 10:45 am, Jason <[EMAIL PROTECTED]> wrote:
> I have read through that. It has taken me around and around in
> circles. I have spent a day on this and haven't typed a line of code.
> The guide seems to be written for OSX or Linux. As a Windows user I
> feel lost, confused and frustrated.
>
> I even went out to my library and rented a copy of their Django
> book... yet that doesn't cover how to get going on XP...
>


What exactly are you having problems with? The tutorial covers the
usage of the development server quite well. Are you having problems
getting the package, unpacking it, what? What step in the tutorial has
you stumped? Really, I don't want to seem patronizing, but the
tutorial does tell you what you need to do.

I am developing on Windows using the development server. I have also
setup Apache and mod_python on Windows with the XAMPP package using
the instructions on the django doc site. And finally I have setup
Apache and mod_python on a linux server using the same instructions.
The docs don't give every last detail for an apache setup, but if you
are familiar with apache it is not hard at all. But, as Karen said,
for learning and development, the development server is the best and
easiest option.
--~--~-~--~~~---~--~~
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 with url tag (Caught an exception while rendering: Reverse ...)

2008-09-16 Thread Brian Neal



On Sep 16, 4:09 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Brian Neal wrote:
> > I might have found my answer. I was looking at the list of
> > incompatible changes and found this:
>
> >http://code.djangoproject.com/changeset/8760
>
> > Which led me to this:
>
> >http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse
>
> > I quote from the docs:
>
> > "The reverse() function can reverse a large variety of regular
> > expression patterns for URLs, but not every possible one. The main
> > restriction at the moment is that the pattern cannot contain
> > alternative choices using the vertical bar ("|") character. You can
> > quite happily use such patterns for matching against incoming URLs and
> > sending them off to views, but you cannot reverse such patterns."
>
> > This is exactly what I am trying to do. My pattern is using the |
> > alternation. So apparently the url tag eventually calls reverse and it
> > is failing to find my pattern.
>
> In which case a solution would appear to be to replace each alternate
> with a separate pattern. It might seem distatsteful, but it should work ...
>
> regards
>  Steve

That was my fallback. In my case that would mean 8 URLs or so. Not too
bad.

However I just tried naming my pattern and referencing that from the
template, and it worked!
--~--~-~--~~~---~--~~
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 with url tag (Caught an exception while rendering: Reverse ...)

2008-09-16 Thread Brian Neal

I might have found my answer. I was looking at the list of
incompatible changes and found this:

http://code.djangoproject.com/changeset/8760

Which led me to this:

http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse

I quote from the docs:

"The reverse() function can reverse a large variety of regular
expression patterns for URLs, but not every possible one. The main
restriction at the moment is that the pattern cannot contain
alternative choices using the vertical bar ("|") character. You can
quite happily use such patterns for matching against incoming URLs and
sending them off to views, but you cannot reverse such patterns."

This is exactly what I am trying to do. My pattern is using the |
alternation. So apparently the url tag eventually calls reverse and it
is failing to find my pattern.
--~--~-~--~~~---~--~~
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 with url tag (Caught an exception while rendering: Reverse ...)

2008-09-16 Thread Brian Neal

On Sep 15, 10:44 pm, Ross <[EMAIL PROTECTED]> wrote:
> Check out the description of the {% url %} tag in the Django
> documentation:
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
>
> It does not expect the project name to be in the URL. Try dropping
> "gpp" and just use "weblinks.views.view_links".

Hmmm, it isn't crystal clear (to me anyway) that you are supposed to
drop the application name. It says "The first argument is a path to a
view function in the format package.package.module.function.". That is
what I am doing: gpp.weblinks.views.view_links. Futhermore, this is
how I have been doing it since I started using django a few months
ago. Is there fallback logic in the url resolver logic that undoes
what I am doing?

Anyway, I will try it, but I believe I did already.

I am also seeing strange things if I change the order of the URLs in
my URL patterns list.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem with url tag (Caught an exception while rendering: Reverse ...)

2008-09-15 Thread Brian Neal

This is my urls.py for an app (notice the two that start with
^category/, they both vector to my function view_links):

from django.conf.urls.defaults import *

urlpatterns = patterns('gpp.weblinks.views',
   (r'^$', 'link_index'),
   (r'^add/$', 'add_link'),
   (r'^category/(?P\d+)/$', 'view_links'),
   (r'^category/(?P\d+)/(?Ptitle|date|rating|hits)/(?
Pup|down)/(?P\d+)/$', 'view_links'),
   (r'^new/$', 'new_links'),
   (r'^popular/$', 'popular_links'),
   (r'^random/$', 'random_link'),
   (r'^top_rated/$', 'top_rated_links'),
   (r'^visit/(\d+)/$', 'visit'),
)

This is my signature for my function view_links in gpp.weblinks.views:

def view_links(request, category, sort = 'title', dir = 'up', page =
'1'):

If I type these links manually into my browser, they both work. Each
exercises one of my urlpatterns that start with category: (note that I
have a parent urls.py that looks for "^links/" and then includes the
above urls.py)

http://localhost:8000/links/category/1/
http://localhost:8000/links/category/1/title/up/2/

However when I try to then add the following bit of stuff to my
template, then visit http://localhost:8000/links/category/1/, I get an
error.

   {% if page.has_next %}
   
  Next Page
   {% endif %}

Here is Traceback for the error that I get. Notice that in the error
message it says this: "Reverse for
'gpp.gpp.weblinks.views.view_links' ... ".  Why is gpp on there twice?
It should just be gpp.weblinks.views.view_links. Anyway, here it is:

Environment:

Request Method: GET
Request URL: http://localhost:8000/links/category/1/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.5.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'gpp.core',
 'gpp.accounts',
 'gpp.legal',
 'gpp.contact',
 'gpp.weblinks']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template d:\documents\brian\coding\python\django\gremmies_portal\gpp
\templates\gpp\weblinks\view_links.html, error at line 8
   Caught an exception while rendering: Reverse for
'gpp.gpp.weblinks.views.view_links' with arguments '()' and keyword
arguments '{'category': 1L, 'sort': 'title', 'page': 2, 'dir': 'up'}'
not found.
   1 : {% extends 'gpp/weblinks/base.html' %}


   2 : {% block title %}Web Links: {{ category.title }}{% endblock %}


   3 : {% block weblinks_content %}


   4 :Category: {{ category.title }}


   5 :{% if page.object_list %}


   6 :


   7 :{% if page.has_next %}


   8 :


   9 :   Next Page


   10 :{% endif %}


   11 :


   12 :


   13 :{% for link in page.object_list %}


   14 :


   15 :{{ link.title }}


   16 :


   17 :


   18 :{{ link.description }}


Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "D:\Documents\Brian\Coding\Python\django\gremmies_portal\gpp\..
\gpp\weblinks\views.py" in view_links
  86.   context_instance = RequestContext(request))
File "C:\Python25\lib\site-packages\django\shortcuts\__init__.py" in
render_to_response
  18. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "C:\Python25\lib\site-packages\django\template\loader.py" in
render_to_string
  107. return t.render(context_instance)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  176. return self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  768. bits.append(self.render_node(node, context))
File "C:\Python25\lib\site-packages\django\template\debug.py" in
render_node
  71. result = node.render(context)
File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in
render
  97. return compiled_parent.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  176. return self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  768. bits.append(self.render_node(node, context))
File "C:\Python25\lib\site-packages\django\template\debug.py" in
render_node
  71. result = node.render(context)
File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in
render
  97. return compiled_parent.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  176. return self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in
render
  768. bits.append(self.render_node(node, context))
File "C:\Python25\lib\site-packages\django\template\debug.py" in
render_node
  71.  

<    1   2