Re: IntComma without RequestContext

2015-10-28 Thread Michael Newman
Thank you. Knew I was missing something easy.



On Tuesday, October 27, 2015 at 8:54:08 PM UTC-4, foobar wrote:
>
> Your language string is backwards: 
>
> >>> activate("en-us") 
> >>> intcomma(1000) 
> '1,000' 
>
> >>> activate("en") 
> >>> intcomma(1000) 
> '1,000' 
>
>
> use_l10n=False in a template is: 
>
> {% load l10n %} 
>
> {% localize off %} 
> {{ value }} 
> {% endlocalize %} 
>
> https://docs.djangoproject.com/en/1.8/topics/i18n/formatting/#localize 
>
> 2015-10-28 1:37 GMT+02:00 Michael Newman <newma...@gmail.com >: 
>
> > I am feeling a little lost, a project that I have used intcomma in 
> reliably 
> > on an update suddenly stopped getting the commas inserted. This is for 
> an 
> > out of request cycle email. 
> > 
> > Attempting activate the language doesn't seem to change anything. Am I 
> > missing something simple here? 
> > 
> >>>> from django.contrib.humanize.templatetags.humanize import intcomma 
> >>>> intcomma(1000) 
> > u'1000' 
> >>>> intcomma("1000", use_l10n=False) #not sure how to do this in 
> templates 
> > u'1,000' 
> >>>> from django.utils.translation import activate, get_language 
> >>>> get_language() 
> > u'us-en' 
> >>>> activate("us-en") 
> >>>> intcomma("1000") 
> > u'1000' 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/30892a71-1a41-488e-b9f9-3d71cfc6abcb%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23d9828c-f1ab-425a-9fe3-49e0703a542c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


IntComma without RequestContext

2015-10-27 Thread Michael Newman
I am feeling a little lost, a project that I have used intcomma in reliably 
on an update suddenly stopped getting the commas inserted. This is for an 
out of request cycle email.

Attempting activate the language doesn't seem to change anything. Am I 
missing something simple here?

>>> from django.contrib.humanize.templatetags.humanize import intcomma
>>> intcomma(1000)
u'1000'
>>> intcomma("1000", use_l10n=False) #not sure how to do this in templates
u'1,000'
>>> from django.utils.translation import activate, get_language
>>> get_language()
u'us-en'
>>> activate("us-en")
>>> intcomma("1000")
u'1000'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/30892a71-1a41-488e-b9f9-3d71cfc6abcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: cannot save in the admin site

2009-05-05 Thread Michael Newman

On May 5, 2009, at 6:07 AM, Lame Spirale  wrote:

>
> I'm glad nobody is too upset about this :/
> I can't even use the framework, and i spent 2 weeks on it
> Why isn't there any error message ?
> Why doesn't it even DO something ? It's just un putain de submit
> button ! (i feel more confortable swearing in my own language ^^)
> Should I file a bug report ?
>
>>
>>
>>
I have the exact same setup on my system and it is working just fine.  
There is something missing here, because if anything was like this  
there would be more complaints. Do you have any javascript being  
loaded on the admin pages? Are your admin urls  properly set up in  
your urlconf? Open up firebug and see what is happening when you click  
on a button. Is a request being made? Is it going to the right place  
and does it contain the right information?

That would be where I would start. Because other people aren't  
reporting anything along these lines, we will need more information to  
help you out.

Good luck,

Michael

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 beginner again: templatetags.

2009-05-02 Thread Michael Newman


On May 2, 2009, at 1:58 PM, zayatzz  wrote:

>
> No matter. i figured out the cause, but now i have different how...
> not one suitable for this thread
>>
>>
>>
>>
>>
>>

Alan;

Glad you got it figured out. It would be helpful to the people who  
might be of will be following this thread to hear what the ultimate  
solution was or how you got there no matter how silly it might be.  
Also to clear up some of your comments about magic and caching, which  
were not the case.

Good to hear you got it worked out,

Michael 
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Trying to dynamically control FLV video

2009-04-09 Thread Michael Newman

On Apr 9, 4:59 pm, "saved...@gmail.com"  wrote:
> I have been working on an question/answer app that embeds a video
> along with the question.  If the user answers the question correctly,
> then the app redirects to the next question/video.  Would the best
> practice be to embed the video using a template tag (videoplayer.py,
> for example), or to use a view ?  Thank you in advance!
> Lars

Hi Lars;

The best place to start is definately in the template itself. Get the
video plced there and use the database to help you out there. After
that if you find yourself writing the same boiler plate flash embed
code all the time, I would look into a template tag or even adding a
method to your model to place that code.

If you are writing your own template tag make sure to check out the
inclusion tag it will make your life much easier.

Hope that helps, Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: urlpatterns helper

2009-04-08 Thread Michael Newman

On Apr 8, 2:31 pm, Rit  wrote:
> I'm working on url pattern helper app; design to eliminate the need to
> edit the "urls.py" file more only once. I need inputs and pointers on
> what is best to approach this.
>
> here is the detail:
>
> http://code.google.com/p/django-durl/

This is an interesting idea, but before you get too far into it, take
a look at how the admin does urls in the latest build of django 1.1.
You have the ability to pass objects into an include statement, which
will make your life that much easier.

You can then have in urls include(durl.urls), which would be similar
to the way the admin.site does it's urls:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/sites.py#L187

All you would need then is a method to register views to the durl
module and then make sure the the views get imported before the
urlpattern is matched. Should be pretty fun. Good luck!

Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Click-wrap license (seeking django application)

2009-04-08 Thread Michael Newman

Hello;

On Apr 7, 4:55 pm, Social Network in DJango 
wrote:
> I'm interested in activating a click-wrap license, similar to what you
> get when you install a new program or package, on a pc or osx.

So to get this straight, you want to greet a user with a pr0n style
'enter here only if you agree' on your Web site? That would be pretty
easy to accomplish. All you need to do is wrap your views in a
decorator that checks the session of the user and then displays the
content, otherwise it will display the license and agree button, which
would then set a key in that user's session.

> The core issues I've identified so far:
> * Acceptance to move on
Look at django sessions: 
http://docs.djangoproject.com/en/dev/topics/http/sessions/
and for DRYness look at python decorators or django middleware to
check and handle those sessions.

> * Pagenation for convenient viewing
Django has pagenation: 
http://www.djangoproject.com/documentation/models/pagination/

> * A reasonable default formatting for what was a word document
This is all done with HTML formatting. Not really in the realm of
Django. Templates can be written as user friendly (or unfriendly) as
you want with regular HTML. Look into a decent CSS framework like YUI
or Blueprint CSS to give you a leg up there.

> * Handling unusual characters such as " and '
You will need to handle the switch from ACSII to Unicode and HTML
escaping. This can be a touch tricky if you don't understand it. Best
bet, don't paste from Word. Look into HTML escaped entities:
http://www.w3schools.com/HTML/html_entities.asp

> * Minimal changes to the text to be able to update it from word as the
> original changes
This is all done on the templating side. You can update the database
easily enough, but the formatting should all be done in HTML somehow
or another. If you don't understand this, you might want to look into
a WYSIWYG editor like the one YUI has or TinyMCE.

> * Using it at registration or while already using the site
You can look at how django-registration handles Terms and Agreements
in it's form: http://bitbucket.org/ubernostrum/django-registration/wiki/Home
That's a great example of some good reusable django code that James
Bennett has offered the community to use.

> I look forward to you input.


Hope that helps,

Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Joining the Django Sprint in Ann Arbor on Wednesday

2009-03-31 Thread Michael Newman

Brian Kerr, http://xca2.com/, and myself have been sitting in Michigan
upset that we aren't joining the sprinters in Chicago working on
Django. We decided that we would do something about that and connect
remotely in Ann Arbor for a day. We also wanted to give an open
invitation to anyone in the area to come on out and join us.

We'll start around 9 a.m. at Primo Coffee [1] and depending on the
number of people might move to another location, feel free to call or
text Brian at 734-846-8397 if you want to join later in the day.

I hear rumors there might be cookies and other treats. So come on out
for a day of bug fixing, documentation writing, coffee drinking and
awesome hacking.

If anyone in Chicago (or otherwise sprinting) and has a project that
won't get to, let us know. I am looking forward to contributing as
much as I can in good long day.

Thanks and looking forward to seeing you tomorrow,

Michael Newman

1) http://www.yelp.com/biz/primo-coffee-house-ann-arbor
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Context processor or make custom tag

2009-02-11 Thread Michael Newman

> Hi all,
>
> I'm new in this group and I have to say that my English is very poor
> so sorry.

Welcome to the group!

> I've the follow problem, I want to put in one of my base templates
> (that it's include in main base template) a list of one model, for
> example a Category model that has a relationship with other model like
> Post (this has a ForeignKey with Category).
>
> I can do it by two ways. I can create a context processor where I can
> retrive all category's objects and put them in the context so I could
> access them through all templates, or I can make a new tag where I can
> do the same and use it in that template.

As a general rule context processors are great when you need the
information on any page at any given time. Template tags are good when
you need information in certain places.

> I don't know which is better and why, and if you've other ideas to do
> it I'm very interested in know them.

In reality they both do the same thing and it is up to you how they
work. Think of it as over head. Without any caching in place a context
processor will make a call to the database (or multiple calls) for
every page that is loaded. A template tag will only be loaded on the
pages you load it on and only call the database when you call the tag.
it up to you if you need it that much.

I recommend you use django-logging and view your SQL queries. It is
always a good thing to see if your page loads are much heavier than
you expect. Then you can decide on how you want to hit your db,
whether it be with a selectively chosen template tag or a brute force
context processor.

> Thanks and sorry about my english.

No problem and don't be sorry, your English is great,

Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 invalid

2009-02-09 Thread Michael Newman



On Feb 9, 3:54 am, Praveen  wrote:
> hi i have one form inside the form
>
>  method="POST" onSubmit="javascript:self.close();">
> {% for name in eventname %}
> 
> {{ name.title }}
> 
> {{ name.address }}
> {{ name.summary }}
>  style='display:none'>
> {{ name.title }}
>                                  style="width:
> 25%;height:25%"/>
>                                 
>                                 
>                                         {{ name.summary }}
>                                         {{ name.start_date }} to {{ 
> name.end_date }}
>                                         {{ name.start_time }} to {{ 
> name.end_time }}
>                                         {{ name.venue }}
>                                         {{ name.contact }}
>                                         {{ name.description }}
>                                 
>                                 
>                                         {{ forms.name }} Friend's 
> Name
>                                         {{ forms.email }} Friend's 
> Email
>                                         {{ 
> forms.comment}}
>                                         
>                                          onClick="javascript:self.close();">Submit a>
>                                           class="submit-post"
> value="Send" />
>                                         
>                                 
>                         
>                 {% endfor %}
> 
>
> forms.py
> -
> class MailForm(forms.Form):
>     #topic = forms.ChoiceField(choices=TOPIC_CHOICES)
>     name  = forms.CharField(label=_("Name"), max_length=50)
>     email = forms.EmailField(label=_("Email address"))
>     comment = forms.CharField(label=_("Comment"),
> widget=forms.Textarea)
>
> eventview.py
> 
> def event(request):
>         difference1 = datetime.timedelta(days=-3)
>         today=datetime.date.today()
>         print "Today date : ", today
>         l=range(1,5)
>         forms = MailForm(request.POST)# Creating MAIL FORM interface in side
> event template
>         print "Mail Form : ", forms
>         eventobj=events.objects.all().filter
> (start_date__lte=today,end_date__gte=today)
>         eventname=events.objects.all().filter
> (start_date__lte=today,end_date__gte=today)
>         #eventobj=events.objects.all().filter(start_date__gte=today-
> datetime.timedelta(days=3), end_date__lte=today+datetime.timedelta
> (days=10), highlighted='true',visibility='true')
>         paginator = Paginator(eventobj, 2)
>         try:
>             page = int(request.GET.get('page','1'))
>             print "page : ", page
>         except ValueError:
>             page = 1
>         try:
>             eventobj = paginator.page(page)
>             print " Event object : ", eventobj
>         except(EmptyPage, InvalidPage):
>                 eventobj = paginator.page(paginator.num_pages)
>         return render_to_response("event.html",
> {'eventobj':eventobj,'l':l,'eventname':eventname,'today':today.strftime
> ("%B %d %Y %A"),'forms':forms})
>
> #View for send mail#
> ---
> def mail(request):
>     if request.method == 'POST': # If the form has been submitted...
>         form = MailForm(request.POST) # A form bound to the POST data
>         if form.is_valid():
>                 print "Form valid"
>                 comment = form.cleaned_data['comment']
>                 email = ['i...@example.com']
>                 from django.core.mail import send_mail
>                 send_mail(comment, email)
>                 print "Send mail : ", send_mail(comment, email)
>                 return HttpResponseRedirect('/pro/Thanks/')
>     else:
>         print "Invalid form"
>         form = MailForm() # An unbound form
>     return render_to_response('contact.html', {'form': form})
>
> urls.py
> --
>
>     (r'^foodies/events/$', 'foodies.foodapp.eventview.event'),
>     (r'^foodies/sendmail/$','foodies.foodapp.eventview.mail'),
>
> i am displaying eventdetails in light box where i have one submit and
> name and email field. if some one click on submit then mail should
> send page should closed. but when i am clicking on submit button form
> is closing but it shows me "Invalid Form" which i wrote in else part
> of mail view. i think some thing wrong in get or post.

This is really difficult to read like this. Next time if you post
post, please put it on a pastebin site like dpaste.com . This will
make my life a lot easier.

My bet is when you look at the post information coming across the wire
you aren't going to see any of the information you expect. First off,
where does the 'forms' variable come from? The best way to check the
post/get requests is with a product like Firebug or Fiddler. You can
see what is going with your post and make sure that it matches what
you think it should be.

Take a look at that information, hopefully it will become clear what
is wrong when you look 

Re: Several browser windows, one session object - should I be locking django session objects?

2009-01-27 Thread Michael Newman



On Jan 27, 4:52 pm, Matthias Julius  wrote:
> mvtango  writes:
> > my users keep several browser windows open in my application, I need
> > to keep session information for all these windows separate. But I have
> > only one session object - modifying it while the user works in window
> > A and window B in parallel might get me in trouble if Request A and
> > Request B are under way in parallel.
>
> > So I thought about locking the session, modifiying it, saving it
> > during the request. I thought about locking the session at the
> > database level.
>
> > Questions: Anybody run into this? Would locking be the right way to do
> > it? Or are there any other ways of solving this?

Session data is stored in the database and the ORM. These transactions
are are threadsafe, so you won't run into conditions where browser A
overwrites the newly submitted data from browser B.

If you need to know know however whether browser A finished before
browser B and browser B had access to the complete transaction in
browser A, you are going to need to set up some logic that checks for
browser A's transaction being done before you allow browser B (i
recommend doing this in validation and not looping or waiting for some
condition).

Yet another way you can just be super sure is to set up only one
thread and process on your server. This will force the tranactions to
excute in order, but the trade off is speed and flexiblity. Your best
bet is just to program without needing context from browser A's
session to be completed before browser B's.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Memcache, errors logged to apache

2009-01-27 Thread Michael Newman

Using cmemcache .95 I am getting the following errors in the apache
logs:

[fa...@1233073307.022758] mcm_fetch_cmd():1156: memcache(4) protocol
error: protocol, expected a response
[fa...@1233073307.030416] mcm_get_line():1544: memcache(4) protocol
error: no \r before \n

It seems to be occurring quite frequently (server is under quite a bit
of load). I have seen a couple other instances of this in user groups
which point people to a older version of cmemcache. It seems,
logically, that when these errors are most frequent, the server load
average spikes.

I am interested if any one else has been experiencing this seen this
and has fixed it somehow. Thanks, Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Email for Username

2008-11-20 Thread Michael Newman



On Nov 20, 1:30 pm, Justin <[EMAIL PROTECTED]> wrote:
> We want to use email addresses as our site's login username, not just
> as an alternative authentication method. I figured a quick way to do
> this would be just changing the auth user model's username field to an
> EmailField instead of a CharField (I know this isn't the most robust
> solution). Nonetheless, the change is reflected in the manage.py
> sqlall output, and I took the appropriate steps to update the sql
> table. However, the changes are not reflected in the admin interface.
> When I try to Add User, it still won't accept an email string and
> displays the old help_text.
>
> How to make my change to the auth user model take effect?
>
> Thanks!

No need to reinvent the wheel and create a whole auth framework just
to enable e-mail. This is an extension of Django Registration that I
wrote that allows a user to just register entering in a email address.
The username is then auto created. Teamed up with authentication
backend from this comment: http://www.djangosnippets.org/snippets/74/#c195
you have a full user system without needing usernames at all. Easy as
pie.

Let me know if you have any questions,
Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Models - getting specific attributes question

2008-10-02 Thread Michael Newman

It's even easier than that: try user_profile.name

if you need a specific variable field, remember it is just python so:
>> from Model.models import Profile
>> user_profile = Profile.objects.get(pk=1)
>> attribute = 'name'
>> getattr(user_profile, attribute)
John

Hope that helps, Mn


On Oct 2, 10:47 am, WillF <[EMAIL PROTECTED]> wrote:
> Hi I'm new to django. Is there way to get a specific column from a specific
> table in a database when using Models. Say for instance I wanted just a list
> of user's firstnames or something.
>
> Also, with a instance of a Model, say for instance, UserProfile, is there a
> way to get an arbitrary attribute. Soemthing along the lines of
>
> user_profile.get('name') or user_profile.get(attribute)
>
> ??
>
> Thanks!
> --
> View this message in 
> context:http://www.nabble.com/Models---getting-specific-attributes-question-t...
> Sent from the django-users mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Catching Exceptions thrown in .save() - django 1.0

2008-10-02 Thread Michael Newman

Kurczak;

Short of this is, catching specific errors in the save method and
displaying them to the user are hard and you might be regurgitating
items back to the user that they really don't have any business seeing
(SQL errors, programming errors, etc.). The best way to check for the
proper values is to do it at the form level. If you are in the admin
you have the ability to define a custom form; the admin docs explain
this pretty well: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form
. If this is a custom input of your form, you save one step and do it
in the clean methods on your form.

In this way you are avoiding the model validation on the save method
and you have clean modular and specific errors that can be displayed
to the user.

Hope that helps,

Michael

On Oct 2, 4:22 am, Kurczak <[EMAIL PROTECTED]> wrote:
> Hello there,
> I'm in  need of some kind of validation at model level (and don't have
> time to wait till 1.1 lands). Now I'm doing it by raising exceptions
> in save method (I know how ugly it sounds).
> What can I do to propagate those exceptions to forms or handle them at
> some user-friendly level (so at least i can show some nice error
> page).
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many to Many field Assignment

2008-08-31 Thread Michael Newman

On Aug 31, 11:14 am, "Vadivel Kumar" <[EMAIL PROTECTED]> wrote:
> I know this might sound very newbie .. its true
>
> How can i assign an exising record of the child table to an parent record.
> For example I have two models,
>
>     class User (models.Model):
>          ... all other fields ...
>         Tags  = models.ManyToManyField(Tag)
>
>      class Tag (models.Mode):
>          .. all fields ..
>
> The problem i am facing is whenever i create a new user and add an existing
> tag object to User.Tags.add() method it creates a new record in Tag table
> instead i need to just map the record with the new user.
>
> I know am missing a paramount thing .. what is that ?

The methods you are using, if I understand you correctly, should work.
I would need to take a look at the exact code that is creating a new
object to help you out. But one thing you can look at is
http://www.djangoproject.com/documentation/models/many_to_many/  . It
is very helpful at showing how the manytomanyfields work. If you are
still having an issue, post the offending code to dpaste.com and we
can take a look.

Thanks,
Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 and Textmate

2008-08-31 Thread Michael Newman

A few people including myself are working on:
http://www.bitbucket.org/bkerr/django-textmate-bundles/

I really hope to get some time to really get it going in the next week
so we can officially announce it. We are definitely looking for more
eyes and recommendations on the project. If you want to contribute,
just let me know and I can get you signed up as a pusher.

Thanks, Michael

On Aug 31, 12:58 am, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> Has anybody taken a crack at updating the Textmate Django bundles
> (python and template) for version 1.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Popups?

2008-06-24 Thread Michael Newman

Hi Ross;

The key here is to realize that there is a difference between server
side and client side code. Django is server side meaning that it
handles requests and returns them as a HTTPresponse object (generally
HTML). HTML and javascript are client side, meaning that it is
rendered by the client's browser. User interaction is all handled but
these client side code because the server is not aware of the user's
interactions (in fact the entire process closes right after the
HttpResponse is given). This is where AJAX comes in, trying to connect
the two sides, but that is getting really complicated.

So long and short of it. Django has no idea that a user has clicked on
something until it receives a request and therefore cannot open a new
browser window. Javascript is what all the cool people use to open new
windows.

To be honest, the only way that django views could open a new window
is to pass javascript through the view in a new HTTPresponse, but that
would be blocked by popup blockers and silly because you are writing
javascript anyways.

You might want to look into moving your javascript away from your
markup (external stylesheets or into script tags), then it would look
similar to how you want it to look and it degrades better and is
better in general.

Good luck hope that helps,

Michael

On Jun 24, 9:51 am, RossGK <[EMAIL PROTECTED]> wrote:
> I'm a recent Python/Django inductee and trying to get a small project
> going.
> Is there a good way to do a pop-up window from Django or should I use
> java-script.  Right now, I can call an
>
>  
>
> and pop up mypage.html with some appropriate content and return code.
> I can imagine one path which would be to instead use the same onClick
> code above, with
>
>  
>
> and in my urls.py pick it up with a regular expression which then
> initiates the views.py call to put in some nice things from my
> postgresql database.
> I was kind of hoping that I could just do a simple
>
>    Click me
>
> and have the views.py do some Django magic that indicates a pop-up.
> Is that possible?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: click download, click install, go! no....

2008-06-01 Thread Michael Newman

Just as I was writing this up someone brought to my attention:
http://bitnami.org/stack/djangostack

I have never tried it, but if you are feeling adventurous, it might
but just what you are looking for.

On Jun 1, 12:54 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> The reality is that Django does require a certain curve to get things
> up and running. When I first started with Django, it was my first time
> working with the server side and it took me a few months to really get
> what I am doing. That being said the django community has really been
> booming this last year or so and there are a lot of tutorials out
> there on how to set up the 'perfect' server with django.
>
> I have been working on similar Ubuntu computers now for some time
> (slicehost, development and large scale production) and I could
> probably write up command by command steps on how to get django set
> up, but chances are that you don't have an Ubuntu machine and you
> might not want the MySql, modpython, memcache set up that I have, much
> less the directory structure that I have.
>
> Part of the great flexibility of django is that 'it just works(tm).'
> Sadly this means that you have lay down the bedrock before you get
> started. That means you have to have python 2.3 or greater, a database
> and the python extension of that db (mysqldb), and some sort of
> serverside http script handler (mod_python).
>
> Maybe one day we will see some one click install, in fact I think
> Media Temple is working on the ability to have a on click django
> installation on there shared host, but I don't believe django will
> ever have an installation feature for every system out there. There
> are just way too many variables and as I said before one of the great
> features about django is it's flexibility to just work in so many
> different configurations.
>
> I might be able to give you a hand and help you out with package
> management systems that you might already have on the computers you
> are working on that might make the process less painful. I will need
> some information about the systems you are running (what OS, version)
> and what type of stack you wish to build, looks like you want mysql
> and mod_python.
>
> I hope to help you out. It might be frustrating to start, but I
> promise once it all clicks you will feel enlightened,
>
> Michael
>
> On Jun 1, 7:04 am, slix <[EMAIL PROTECTED]> wrote:
>
> > looking at:http://www.djangoproject.com/documentation/install/
>
> > it just seems a little to complicated to get started.
>
> > i eventually want to run my app on a big server but right now i just
> > want to launch a small html-site that can do some calculations based
> > on input and then do some output.
>
> > ive tried before to get mysql and then you need mysqldb etc and then
> > you have to make it all work together.
>
> > isnt there one download this lick installö and go package?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: click download, click install, go! no....

2008-06-01 Thread Michael Newman

The reality is that Django does require a certain curve to get things
up and running. When I first started with Django, it was my first time
working with the server side and it took me a few months to really get
what I am doing. That being said the django community has really been
booming this last year or so and there are a lot of tutorials out
there on how to set up the 'perfect' server with django.

I have been working on similar Ubuntu computers now for some time
(slicehost, development and large scale production) and I could
probably write up command by command steps on how to get django set
up, but chances are that you don't have an Ubuntu machine and you
might not want the MySql, modpython, memcache set up that I have, much
less the directory structure that I have.

Part of the great flexibility of django is that 'it just works(tm).'
Sadly this means that you have lay down the bedrock before you get
started. That means you have to have python 2.3 or greater, a database
and the python extension of that db (mysqldb), and some sort of
serverside http script handler (mod_python).

Maybe one day we will see some one click install, in fact I think
Media Temple is working on the ability to have a on click django
installation on there shared host, but I don't believe django will
ever have an installation feature for every system out there. There
are just way too many variables and as I said before one of the great
features about django is it's flexibility to just work in so many
different configurations.

I might be able to give you a hand and help you out with package
management systems that you might already have on the computers you
are working on that might make the process less painful. I will need
some information about the systems you are running (what OS, version)
and what type of stack you wish to build, looks like you want mysql
and mod_python.

I hope to help you out. It might be frustrating to start, but I
promise once it all clicks you will feel enlightened,

Michael


On Jun 1, 7:04 am, slix <[EMAIL PROTECTED]> wrote:
> looking at:http://www.djangoproject.com/documentation/install/
>
> it just seems a little to complicated to get started.
>
> i eventually want to run my app on a big server but right now i just
> want to launch a small html-site that can do some calculations based
> on input and then do some output.
>
> ive tried before to get mysql and then you need mysqldb etc and then
> you have to make it all work together.
>
> isnt there one download this lick installö and go package?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 for B C as D in templates

2008-06-01 Thread Michael Newman

As is written into templatetags directly. It is a fairly easy process
and it helps with context variables (otherwise how would you access
comment_count in the template).

Look here for how to write a custom tag:
http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags

I just added a snippet to django snippets that puts a context variable
in the context using the as format: http://www.djangosnippets.org/snippets/779/

Hope that helps,

Michael


On Jun 1, 10:14 am, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> I see. Is "as" used outside of this tag? I think I've seen it in other
> contexts.
>
> Thanks,
>
> Rodrigo
>
> On Jun 1, 12:38 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > This is not a standard syntax but the particular syntax for the tag
> > get_free_comment_count. Check its code in
> > django.contrib.comments.templatetags.DoCommentCount
>
> > In your example, 'blog' is the application name, 'entry' the model
> > name to which comments are attached, 'object.id' is the id of the
> > particular object you're retrieving the comments for.
>
> > What it does is it retrieves the comments and stores the number of
> > comments in the variable 'comment_count', which you can then use as
> > follows:
>
> > There are {{ comment_count }} comment{{ comment_count|pluralize }} for
> > this entry.
>
> > On Jun 1, 12:02 pm, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
>
> > > Looking through documentation for the FreeComment app, I came across
> > > this template syntax:
>
> > > {% get_free_comment_count for blog.entry object.id as comment_count %}
>
> > > Where can I find documentation for use of the "A for B C as D"  syntax
> > > in Django templates?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Newbie

2008-05-05 Thread Michael Newman


> - Is it possible to create WML files (or for that matter any customised
> output that is not out there) easily? Especially by way of XML/XSLT.

Django is really flexible with it's template and HttpResponse system.
You can specify headers, types and serializations on the fly. Granted
these types of systems aren't as popular as JSON or other types, but I
believe that for an all encompassing framework, Django provides you
with the greatest flexibility on this aspect. Also because it is all
python, you can do anything python can do.

> - If so, are there many standard templates that can be downloaded and 
> customised?

Believe it or not, no, and I wouldn't want it any other way. Templates
are written in pure html with variables punched in. So if there is an
HTML template that you like you can take that and adapt it to fit your
new Django site. Or, as I prefer, you can design your site however you
like, but I am an (x)HTML/CSS guy.

> - Is there an IDEs that can be used for development?

Django is python so all python IDEs, Komodo, Wingware, vim, emacs,
etc., work with django modules. There are plugins throughout the web
for specific django-only python (models) and for django templates for
just about any IDE. As i said before the templates are just HTML, so
any HTML IDE will work with Django templates. I, personally, am a big
fan of Textmate and VIM, both with django plugins.

> - Given my basic needs, do you think Django is good, or some other tech is 
> better?

I might be a bit biased, but Django is great and very flexible. Don't
really know precisely what your needs are, and i am really not that
familiar with these really in depth cell phone file types. Out of the
box Django is really powerful and the more you learn python and the
django internals, you can really do some spectacular things really
quickly. IMHO for content management, I can't imagine a better
system.

Enjoy diving in!

Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Default Pluralize logic

2008-05-04 Thread Michael Newman

I think you are assuming too much here. The verbose name and verbose  
name plurals are default pulled from a class name that might not  
necessarily make sense to my editors in the admin. I need to have some  
control to how it is actually displayed to the end user; no program is  
going to be able to make my life easier by referencing a translation  
block to make my class names read better. Also you assume some  
standard in which class names are being written. It is my experience  
that people name classes by whatever makes sense at that moment and  
starfards are frequently developer/project based.

Michael Newman

On May 4, 2008, at 1:16 PM, "[EMAIL PROTECTED]"  
<[EMAIL PROTECTED]> wrote:

>
>> Is it?  Maybe.  I don't know if anyone has proposed smartening-up  
>> Django's
>> pluralization rules in the past
>
> I had a look through the mailing-list archive and couldn't spot
> anything directly related.
>
>> (I'm not even sure if you are proposing it
>> here?).
>
> I pretty much am proposing it here. I wanted to confirm my
> understanding of how the pluralize logic currently works in Django.
>
>> My gut feeling is it's probably something that has lots of
>> exceptions/special cases that would make it hard to get entirely  
>> right,
>> particularly for all languages, but maybe I'm unduly pessimistic.
>>
>
> Example of some exceptions/special cases are irregular plural nouns.
> However, as default pluralize function, I believe we can handle a lot
> more cases compared to the current functionality.
> Also, by looking at having language specific rules files (maybe
> linking this into the internationalization logic), we can quite easily
> train the pluralize function to handle more exceptions/special cases
> too without needing to modify the source code (decoupling the rules
> from the source code, pluralize function).
>
> The code to enhance the pluralize function is pretty straightforward.
> I have already implemented this functionality in my own code base that
> I would be happy to share. (I can create a patch/diff if there would
> be interest.)
>
>
> Regards,
> -Alen
>
> On May 3, 9:52 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>> On Sat, May 3, 2008 at 5:39 AM, [EMAIL PROTECTED]  
>> <[EMAIL PROTECTED]>
>> wrote:
>>
>>> Could someone please be kind to explain to me how the pluralize  
>>> logic
>>> works in django?
>>> a.) pluralize template filter
>>
>> Doc for this is 
>> here:http://www.djangoproject.com/documentation/templates/#pluralize
>>
>>> b.) Meta.verbose_name_plural
>>
>> Doc for this is 
>> here:http://www.djangoproject.com/documentation/model-api/#verbose-name-pl 
>> ...
>>
>>> As default, I am expecting the pluralize to convert "country" to
>>> "countries". For exapmle, this doesn't happen in admin so I define  
>>> the
>>> verbose_name_plural in the Meta inner class.
>>
>> Per the doc, the default pluralize (filter) behavior is to simply  
>> add an s.
>> If that is not correct for the word in question, then you have to  
>> tell the
>> filter what the correct suffix is.  The doc also has an example of  
>> how to
>> specify that pluralize should change a -y to an -ies.
>>
>> For the model's verbose plural name, again the doc states the default
>> behavior is to add an s.  If that isn't correct, then you need to  
>> specify
>> verbose_name_plural, as you have.
>>
>>> Its straightforward to implement a function that can seemlessly  
>>> handle
>>> this correctly as default, even if it was to read the pluralization
>>> rules from a rules. files or something equivalent.
>>
>> Is it?  Maybe.  I don't know if anyone has proposed smartening-up  
>> Django's
>> pluralization rules in the past (I'm not even sure if you are  
>> proposing it
>> here?).  My gut feeling is it's probably something that has lots of
>> exceptions/special cases that would make it hard to get entirely  
>> right,
>> particularly for all languages, but maybe I'm unduly pessimistic.
>>
>> Karen
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 abstract base class in QS-RF

2008-04-14 Thread Michael Newman

Imagine:

from django.db import models

class Mtmfield(models.Model):
afield = models.TextField()

class Place(models.Model):
somefield = models.ManyToManyField(Mtmfield,
related_name='a_name_that_cant_have_conflicts')

class Meta:
abstract = True

class Restaurant(Place):
someotherfield = models.TextField()

class Bar(Place):
somethirdfield = models.TextField()


Running a manage.py syncdb throws:

Creating table inheritance_mtmfield
Creating table inheritance_bar
Creating table inheritance_restaurant
Traceback (most recent call last):
  File "./manage.py", line 11, in 
execute_manager(settings)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/core/management/__init__.py", line 272, in execute_manager
utility.execute()
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/core/management/__init__.py", line 219, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/core/management/base.py", line 72, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/core/management/base.py", line 86, in execute
output = self.handle(*args, **options)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/core/management/base.py", line 168, in handle
return self.handle_noargs(**options)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/core/management/commands/syncdb.py", line 91, in handle_noargs
cursor.execute(statement)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/db/backends/util.py", line 18, in execute
return self.cursor.execute(sql, params)
  File "/Users/mnewman/Documents/resources/django/queryset-refactor/
django/db/backends/sqlite3/base.py", line 136, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: table "inheritance_bar_somefield" already
exists

This only seems to occur when there is a ManyToManyField in the
abstract base class and there are 2 items that extend that base class.
This does not seem to be a problem when the base class is not
abstract. This also occurs in MySQL.

I would like to open a ticket, but wanted to just make sure that I am
implementing the abstract base classes in the way that they were
designed. I would also like to help out with a patch, but can't even
begin to figure out where the issue is coming from.

Thanks,

Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



extra arguments in generic views

2008-03-27 Thread Michael Newman

I was just messing around with my sites urlconf to keep it organized
and manage clean things up a bit. I make use of generic views quite a
bit and they really save me a lot of time. One of the things that I
noticed however as I was trying to combine a lot of "info_dicts" was
that the generic views (except archive_day) don't accept extra key
word arguments.

I realize that passing extra arguments to a function is less than
ideal, but sometimes it is nice to have one "info_dict" that defines
paginate, date_field, slug, etc. for model views. Obviously this
caused problems with a lot of the generic view functions, but that
easily rectified by adding **kwargs as an extra argument.

I don't know if this is something that would be right to have in the
default views, but I was interested in starting a conversation to the
pros and cons to this approach.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Looking for Django Programmer in Chicago this week

2008-03-10 Thread Michael Newman

Hey All;

I am getting really excited about PyCon this week and especially the
Django talks and tutorial. It should be a real learning experience for
me.

That being said my company is looking for someone who will take up the
programming side of Django as we expand our online presence, start
building databases and improving user interaction with our Web sites.
Working here is really a unique experience to not only push the
envelope, but also set things up looking toward future success. I have
been here for the last half of year, and it is about time to get a
dedicated programmer.

Anyway long and short is that I will be in Chicago this week for the
conference and would love to meet programmers looking for a great job
in the news media industry who love Django as much as I do.

Anyone who is interested you can find me around, I will be at all the
Django talks and tutorial, or feel free to give my cell a call I will
love to meet with you,

Michael Newman
cell - (717) 332-7758


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Checking exceptions

2008-03-10 Thread Michael Newman

Depends on the error...

Not to be flippant but there are a lot of exceptions that have to do
with the database, in genernal though I trust django enough not to
really worry about catching exceptions in my database models because
it already takes care of it for you.

If you are getting a specific exception do a try: ... except, e: print
e and that should tell you what exception is being raised.

Michael

On Mar 10, 7:43 am, "Monica Leko" <[EMAIL PROTECTED]> wrote:
> Hi!
>
> What type of exception do you usually check when developing with
> Django?  When you deleting, adding or updating database?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Newbie here, needs help with ImageField

2008-03-10 Thread Michael Newman

Passing your error along would be helpful because it will help us
pinpoint exactly what part of your code is having issues. Python
traceback is amazing helpful in that if you follow its path, even
though it might not look like anything initially, it will lead you to
what the problem is. This is why I would swear by python over most
other programming languages.

t.save should be t.save() as it is a function call.
Also it might be dpaste but it looks like you are having issues with
tabs. In python that whitespace is really important and if your error
has anything to do with unexpected indent it's because of that.

Anyway change the t.save() call and post your error and we can figure
out exactly what the error is.

Michael

On Mar 10, 8:54 am, foxbunny <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've read the tutorial, and bits of docs here and there. I would like
> to thank the great Django community for making this a splendid
> learning experience!
>
> So, I felt confident enough to start writing a simple image gallery
> app.
>
> Here's the code for the main app's models.py.
>
> http://dpaste.com/38695/
>
> I've enabled the admin app, syncdb'd and created a user. So I log in,
> but the image upload doesn't work.
>
> When I pick an image and click on Save, the form complains that there
> is an error I need to fix, but it doesn't pinpoint the erroneous
> field.
>
> After a while, I tried to remove the lines 59 and 60, and also the
> width_field, and height_field from line 58. I also removed the
> matching columns from the MySQL database manually, because syncdb
> doesn't do that for me. Then I restarted the app, but then I had a
> different situation. The image and its record get saved, but the
> post_save signal is not emitted (aparently, because there is nothing
> in the admin's history view for the item, not even its creation) and
> instead of the admin page, I get an error page which says 'width'
> field doesn't have a default value.
>
> Can anyone please take a look at dpaste and tell me if I did something
> wrong there? (I'm almost sure I did.)
>
> Thanks,
>
> Branko
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: File Upload with newforms

2008-03-10 Thread Michael Newman

Everything looks right in your code, on a brief glance. In your
template, do you have your form prepared for multipart data; Does your
form tag look like  ?

Might be something else, but that is the first thing that jumps out to
me.

Michael

On Mar 10, 6:09 am, Paolo Ferretti <[EMAIL PROTECTED]> wrote:
> I've got a problem with file upload in django. I found some generic
> documentation like this:
>
> http://www.djangoproject.com/documentation/model-api/#filefieldhttp://www.djangoproject.com/documentation/faq/#how-do-i-use-image-an...
>
> Reading that pages, I suppose that the file uploading copy into my
> MEDIA_ROOT happens automatically when I save my record.
> The problem is that the file name is saved into my database table, but
> the file isn't saved into the MEDIA_ROOT directory in the filesystem.
> Where am I wrong? Here is the code (I use django SVN version under
> Windows XP):
>
> # models.py
>
> class Auto(models.Model):
> [...others field...]
> foto = models.ImageField(upload_to="images/auto/", blank=True,
> null=True)
>
> # forms.py
>
> class AddImageForm(forms.Form):
> immagine = forms.ImageField(label='Immagine:', required=True)
>
> # views.py
>
> def addphotoauto(request, id):
> if request.method == 'GET':
> form = AddImageForm()
> return render_to_response('auto/aggiungi_foto.html', {'form':
> form})
> if request.method == 'POST':
> form = AddImageForm(request.POST, request.FILES)
> if form.is_valid():
> try:
> a = Auto.objects.get(id__exact = id)
> a.foto = form.cleaned_data.get('immagine')
> a.save()
> # TODO: save file
> return HttpResponseRedirect('/')
> except Exception, e:
> # exception handling
> else:
> return render_to_response('auto/aggiungi_foto.html',
> {'form': form})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding variables to context only in one block?

2008-03-07 Thread Michael Newman

I have a template tag that returns a list of objects in a category in
a context variable. I was wondering if it was normal and expected that
the context variable only works within the content block in which the
item was called?

Also I noticed the must_be_first variable and was wondering if any of
my template tags could benefit from that and how.

Thanks,
Mn
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: IDE

2008-03-06 Thread Michael Newman

I would second vim for quick editing of django and python files, it is  
great once you get over a bit of a curve.

Recently I needed an editor that let me work on a large Ajax file that  
I knew I would probably need a GUI for and am still in the 30 day  
trial for textmate( mac only). I am very impressed, although the 60$  
price tag might be hard to swallow when the trial runs out.

For right now I seem to be most productive by having a terminal open  
to djangos shell, a second for editing models and views quickly and  
textmate open with my CSS, settings, longer HTML templates and  
javascript. But that's just crazy me...

Michael Newman


On Mar 6, 2008, at 3:24 AM, Jarek Zgoda <[EMAIL PROTECTED]>  
wrote:

>
> gabriel napisał(a):
>
>> I am at the point of changing IDE before my next project ( a huge  
>> one ).
>> So far I've used Geany for python but now I am supposed to use  
>> django.
>> Is it anythong with special support for Django??
>>
>> I know that recommendations include SPE and Eclipse but I wonder if  
>> you
>> happened to work with IDE with a nice django support - does anything
>> alike exist??
>
> I use PIDA (http://pida.co.uk/). While it has no explicit Django
> support, embedded Vim pleases me enough (Vim syntax coloring for  
> Django
> templates is enough for me -- see
> http://www.vim.org/scripts/script.php?script_id=1487).
>
> Other options I tried was Komodo Edit (nice project management) and  
> Kate
> (overall good editor, but project management plugin is a PITA), but
> neither one appealed to me.
>
> -- 
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Iteration not working inside template

2008-03-05 Thread Michael Newman

You don't need the .all after the lunch entry list in the template.  
You already did that.

Michael Newman

On Mar 5, 2008, at 10:47 PM, "M.Ganesh" <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I've pasted a minimalist code here: http://dpaste.com/hold/38198/
>
> Only the table caption and the table headers show-up in the web page.
> The LunchEnrty_list.count also shows up correctly, but there are no
> table rows.
>
> What am I missing
>
> TIA
> Regards Ganesh
>
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: issues with conversion in templates

2008-02-23 Thread Michael Newman

Seems .decode('cp1252') fixed everything.

http://effbot.org/zone/unicode-gremlins.htm

Explains some if it.


On Feb 23, 10:36 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> I have a strange error that I was hoping someone could help with. I
> have a large project that I have incorporated a search functionality
> using swish-e. Everything works great until I go to render it to a
> template. On some debugging I get a variable that says it has a
> length, but no word count and it won't print to the template. If I put
> the variable directly through httpresponse it displays fine. I figure
> that it is some sort of unicode conversion error as Swish-e doesn't
> seem to output unicode. If I use python's unicode or django's
> force_unicode before the render_to_response, nothing displays and no
> HTML renders. I am confused and would really be interested at any
> ideas anyone might have. I am totally rasping at straws right now.
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



issues with conversion in templates

2008-02-23 Thread Michael Newman

I have a strange error that I was hoping someone could help with. I
have a large project that I have incorporated a search functionality
using swish-e. Everything works great until I go to render it to a
template. On some debugging I get a variable that says it has a
length, but no word count and it won't print to the template. If I put
the variable directly through httpresponse it displays fine. I figure
that it is some sort of unicode conversion error as Swish-e doesn't
seem to output unicode. If I use python's unicode or django's
force_unicode before the render_to_response, nothing displays and no
HTML renders. I am confused and would really be interested at any
ideas anyone might have. I am totally rasping at straws right now.
Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: self referential manytomany

2008-02-22 Thread Michael Newman

I was afraid of that. Thanks Malcolm.

On Feb 22, 4:10 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-02-21 at 08:44 -0800, Michael Newman wrote:
> > I am a bit confused as to why it is that this gives me an error. I
> > hope someone could explain it to me.
>
> > Let's say I have users with Profiles that can be connected to the one
> > Web page that they can author. The other Users can bookmark that page.
> > So my models look like this:
>
> > profiles.models.py
>
> > from bookmarks.models import Bookmark
>
> > class Profile(models.Model):
> > ...bookmarks = models.ManyToManyField(Webpage)
>
> > 
> > bookmarks.models.py
>
> > from profiles.models import Profile
> > ...author = models.ForeignKey(Profile)
>
> These two models look too tightly coupled to be able to exist in
> separate applications. What your code is saying is that before it can
> construct the Profile model, it needs the Webpage model, because it
> needs to create a foreign key. However, before it can create that model,
> it needs the Profile model because of the foreign key in
> bookmarks.models.
>
> If A depends directly on B *and* B depends directly on A, then they
> aren't orthogonal models and trying to put them in separate applications
> isn't really gaining you anything (it's not like one can ever exist
> without the other).
>
> Django supports forward reference within the same file (via "string"
> names ,rather than object references), however we don't support such
> references across files because (a) it's a lot harder to implement
> correctly because you need to track when to resolve the forward
> references and (b) it's not really needed at the moment for the above
> reason (two tightly coupled models in separate applications isn't
> particularly good design).
>
> Now, I could see myself arguing in favour of string/forward references
> for models within the same application (but in different models files)
> one day, because it makes splitting things up a bit cleaner. But not in
> separate applications. However, that's also not a change that's
> particularly high priority at the moment, given all the other stuff
> we've got going on.
>
> For now, if you've got this type of very tight coupling, put them in the
> same file.
>
> Malcolm
>
> --
> The hardness of butter is directly proportional to the softness of the
> bread.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Newforms-admin Imagefield issues

2008-02-22 Thread Michael Newman

How are you getting the URL for the image? I am not having this same
issue using get_image_url in the templates.

On Feb 20, 1:23 pm, Aaron Fay <[EMAIL PROTECTED]> wrote:
> Hey List,In newforms-admin, when I use an ImageField and specify 
> (upload_to="myfolder") or (upload_to="myfolder/") the value that gets stored 
> in the data base is "myfolder\img.jpg", and then the "\" (backslash) 
> translates into "%5C" in the url (which fails to load). replacing the 
> backslash with a forward slash manually loads the image in the browser, so, 
> am I doing something wrong, or is this a bug you think?
> I fixed it (for now) by overriding the save method and replacing \ with /, 
> but I'm thinking this is a bug...
> Thanks,
> Aaron
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: self referential manytomany

2008-02-22 Thread Michael Newman

I am still having this problem. The simple solution is to put all of
the Models together, but I would prefer not to do this. I am pretty
sure that I have done this before. Is this something that has broken
recently in Django?



On Feb 21, 12:53 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> validation meaning python manage.py validate and python manage.py
> syncdb. I really don't know what is messing up other than the fact
> that module has a circular load. I have no idea to fix this one.
> Thanks Evert for your help. Anyone else?
>
> On Feb 21, 12:44 pm, Evert Rol <[EMAIL PROTECTED]> wrote:
>
> > > That would be true if I defined both models in the same models.py, and
> > > Profile was trying to use Bookmark before it was loaded in the file.
> > > Because this is an import the quotes won't work. That being said this
> > > in one model works when I don't need to put a import statement in it.
> > > So:
>
> > > profiles/models.py
> > > ###
>
> > > class Profile(models.Model):
> > > ...bookmarks = models.ManyToManyField(Webpage,
> > > related_name='bookmarks')
>
> > > from profiles.models import Profile
> > > ...author = models.ForeignKey(Profile)
>
> > > ###
> > > This validates, but it's not as modular as I would like. Any other
> > > ideas?
>
> > Sorry, my bad: I wasn't reading your previous mail properly.
>
> > Actually, I do this myself, but I don't apply validation.
> > In fact, what kind of validation do you mean? Just trying to run the
> > development server (providing everything is synced to the database),
> > ie, 'Python' validation; or something along the lines of form
> > validation? If the latter, perhaps importing Profile into the views.py?
> > It must be similar to using contrib.auth.user and extending the user
> > profile with your own class.
> > Otherwise, I'm currently out of suggestions...
>
> >Evert
>
> > >>> I am a bit confused as to why it is that this gives me an error. I
> > >>> hope someone could explain it to me.
>
> > >>> Let's say I have users with Profiles that can be connected to the
> > >>> one
> > >>> Web page that they can author. The other Users can bookmark that
> > >>> page.
> > >>> So my models look like this:
>
> > >>> profiles.models.py
>
> > >>> from bookmarks.models import Bookmark
>
> > >>> class Profile(models.Model):
> > >>> ...bookmarks = models.ManyToManyField(Webpage)
>
> > >>> 
> > >>> bookmarks.models.py
>
> > >>> from profiles.models import Profile
> > >>> ...author = models.ForeignKey(Profile)
>
> > >> Michael, could this have to do with the note in this section:
> > >>http://www.djangoproject.com/documentation/model-api/#many-to-one-
> > >> relationships
> > >> "Note, however, that you can only use strings to refer to models in
> > >> the same models.py file -- you cannot use a string to reference a
> > >> model in a different application, or to reference a model that has
> > >> been imported from elsewhere."
> > >> So try to quote 'Profile', instead of importing it.
>
> > >>> I get an import error when I try to validate this. I realize that
> > >>> there is a little of cross referencing occurring, but I really
> > >>> cannot
> > >>> think of a better way to accomplish this. Any ideas?
>
> > >>> Thanks, Michael Newman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: __init.py__ executed more than once?

2008-02-22 Thread Michael Newman

I have been having this issue with newforms admin a lot recently
including in a patch for the Auth code. I really think that this is a
problem with newforms admin. I think that the Already Registered error
should be called silently to fix this issue or admin.py should be
imported when the apps are intialized, and not placed in __init__ or
another module so it doesn't accidentally get called. I posted a
thread on Django devs 
https://groups.google.com/group/django-developers/browse_thread/thread/ba8b115b74d6e502
but no one has gotten back to me. I am glad someone else has been
getting this problem. The worse part about this problem is when it
occurs it happens so deeply that the error comes back as a failure to
import a module that works fine in every other circumstance. I wasted
a good part of a morning trying to figure out why auth would import
20% of the time and not the rest of the times.

My temporary solution for this problem is importing deeper in the
module or by placing the import project.app.admin in another app's
init that was more simple and not called as frequently. This is not a
permanent fix by any stretch of the imagination and I hope that if we
keep making noises someone will talk about this fairly major design
flaw.

On Feb 22, 3:54 am, "Almir Karic" <[EMAIL PROTECTED]> wrote:
> http://dpaste.com/36380/here is my code as well as the error, it
> seems that __init__.py is executed more than once, any ideas why? any
> ideas how to fix it?
>
> (i am trying to follow the reccommandations 
> fromhttp://code.djangoproject.com/wiki/NewformsAdminBranch)
>
> --
> error: one bad user found in front of screen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Javascript, Access Radio Button Elements

2008-02-21 Thread Michael Newman

Your right, I looked too quickly and saw the for instead of the id.
Thanks for the correction.

On Feb 21, 3:54 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On 21 Feb, 18:57, Little_Grungy <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I have a form definition for two radio buttons named choices. I want
> > to loop through the radio buttons to perform a check with javascript
> > in the rendered html page, however due to the radio button _id's that
> > are rendered by the template, I cannot access them with javascript
> > using getElementById(). Wondering if anyone can suggest how to solve
> > this?
>
> > My form definition contains:
>
> > choices = forms.ChoiceField(label='Choices', required=True,
> > widget=forms.RadioSelect, choices=options)
> > options = (('good', 'Good'), ('bad', 'Bad'))
>
> > The rendered html is as follows:
>
> > 
> >   Choices:
> > 
> > 
> > 
> >   
> > 
> >> value="good"/>
> > Good
> >  
> >   
> >   
> > 
> >   
> > Bad
> > 
> >   
> > 
>
> > My Javascript function is passed an object obj which contains a
> > choices paramater. obj.choices will be either "good" or "bad" so I
> > would normally be able to set it based on what is passed. My normal
> > approach would be to check the current setting by using
> > getElementById, then comparing to what is passed from obj.choices and
> > if equal, setting the relevant radio.
>
> > As I have two id's id_choices_0 and id_choices_1 I'm guessing that I
> > can't use id_choices_0 in getElementById as in previous worlds. Before
> > Django my radio buttons would only have one id which I would use to
> > reference.
>
> >  for (var i=0; i < document.getElementById('id_choices_0').length; i++)
> > {
> >   if (document.getElementById(id_choices_[i]).value == obj.choices)
> > document.getElementById(id_choices_[i]).checked = true;
> >  }
>
> > Can anyone help?
>
> It's not Django that's the problem, it's the javascript. Why not try
> something like this (untested):
>
> var choice;
> var choice_length = 2;
> for (var i=0; i < choice_length; i++)
> {
>   choice = document.getElementById('id_choices_' + i);
>   if (choice.value == obj.choices)
>   {
>  choice.checked = true;
>   }
>
> }
>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need to change newform label from within view

2008-02-21 Thread Michael Newman

not in the views per se, but you can certainly take care of this in
the templates, just manually define each of the fields.

On Feb 21, 1:23 pm, csmith87 <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Newbie django user 
>
> Is it possible to change a newform label (from the one in the model)
> to one
> set in the view ?   (i.e. I want the tags lefttag, righttag) in the
> view below to
> appear in the generated form as the label, not the model label.
>
> Thanks in advance ...
>
> Here is my model ...
>
> class Response( models.Model ):
>
> type = models.IntegerField()
> left = models.TextField()
> right = models.TextField()
> login_id = models.CharField( maxlength=32 )
> entry_date = models.DateTimeField()
>
> class Admin:
> pass
>
> Here is my view ...
>
> def getif( request ):
> lefttag = 'if'
> righttag = 'then'
> AddResponseForm = forms.form_for_model( Response )
>
> if request.method == 'POST':
> form = AddResponseForm( request.POST )
> if form.is_valid():
> form.save()
> return HttpResponseRedirect( '/if' )
> else:
> form = AddResponseForm()
>
> return render_to_response( 'AddResponseForm.html', {'form': form } )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Javascript, Access Radio Button Elements

2008-02-21 Thread Michael Newman

Hmm this is interesting because django is rendering out poor html if
your example is correct. IDs in the DOM should be unique. I don't
imagine that this would validate the way you want it to either. Why
not just have 2 form.BooleanField objects and in the def clean make
sure that one is taken care of. I hope that helps.

On Feb 21, 1:57 pm, Little_Grungy <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a form definition for two radio buttons named choices. I want
> to loop through the radio buttons to perform a check with javascript
> in the rendered html page, however due to the radio button _id's that
> are rendered by the template, I cannot access them with javascript
> using getElementById(). Wondering if anyone can suggest how to solve
> this?
>
> My form definition contains:
>
> choices = forms.ChoiceField(label='Choices', required=True,
> widget=forms.RadioSelect, choices=options)
> options = (('good', 'Good'), ('bad', 'Bad'))
>
> The rendered html is as follows:
>
> 
>   Choices:
> 
> 
> 
>   
> 
>value="good"/>
> Good
>  
>   
>   
> 
>   
> Bad
> 
>   
> 
>
> My Javascript function is passed an object obj which contains a
> choices paramater. obj.choices will be either "good" or "bad" so I
> would normally be able to set it based on what is passed. My normal
> approach would be to check the current setting by using
> getElementById, then comparing to what is passed from obj.choices and
> if equal, setting the relevant radio.
>
> As I have two id's id_choices_0 and id_choices_1 I'm guessing that I
> can't use id_choices_0 in getElementById as in previous worlds. Before
> Django my radio buttons would only have one id which I would use to
> reference.
>
>  for (var i=0; i < document.getElementById('id_choices_0').length; i++)
> {
>   if (document.getElementById(id_choices_[i]).value == obj.choices)
> document.getElementById(id_choices_[i]).checked = true;
>  }
>
> Can anyone 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inline editing?

2008-02-21 Thread Michael Newman

As Karen said, You didn't set up the inline right. Read through the
docs she pointed you to and fix your errors and the big error will go
away.

On Feb 21, 1:31 pm, "Almir Karic" <[EMAIL PROTECTED]> wrote:
> On Thu, Feb 21, 2008 at 3:02 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> > On Thu, Feb 21, 2008 at 3:55 AM, Almir Karic <[EMAIL PROTECTED]> wrote:
>
> > > from django.db import models
> > > from django.contrib import admin
>
> > > # Create your models here.
>
> > > class Category(models.Model):
> > >name = models.CharField(max_length=50)
>
> > >def __str__(self):
> > >return self.name
>
> > > class Forum(models.Model):
> > >cat = models.ForeignKey(Category)
> > >name = models.CharField(max_length=50)
>
> > >def __str__(self):
> > >return self.name
>
> > > class Category_admin(admin.ModelAdmin):
> > >model = Category
> > >inlines = [Forum]
>
> > You don't list your Model classes directly in inlines, but rather create a
> > class based off of admin.StackedInline or admin.TabularInline (which is
> > where you specify the actual Model), and list that class in inlines.
>
> > See:
> >http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIsetupedit_in...
> > and the last part of:http://code.djangoproject.com/wiki/NewformsAdminBranch
> > for examples.
>
> thanks :)
>
> what about that error? any ideas how to 'fix' it?
>
> --
> error: one bad user found in front of screen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: self referential manytomany

2008-02-21 Thread Michael Newman

validation meaning python manage.py validate and python manage.py
syncdb. I really don't know what is messing up other than the fact
that module has a circular load. I have no idea to fix this one.
Thanks Evert for your help. Anyone else?

On Feb 21, 12:44 pm, Evert Rol <[EMAIL PROTECTED]> wrote:
> > That would be true if I defined both models in the same models.py, and
> > Profile was trying to use Bookmark before it was loaded in the file.
> > Because this is an import the quotes won't work. That being said this
> > in one model works when I don't need to put a import statement in it.
> > So:
>
> > profiles/models.py
> > ###
>
> > class Profile(models.Model):
> > ...bookmarks = models.ManyToManyField(Webpage,
> > related_name='bookmarks')
>
> > from profiles.models import Profile
> > ...author = models.ForeignKey(Profile)
>
> > ###
> > This validates, but it's not as modular as I would like. Any other
> > ideas?
>
> Sorry, my bad: I wasn't reading your previous mail properly.
>
> Actually, I do this myself, but I don't apply validation.
> In fact, what kind of validation do you mean? Just trying to run the
> development server (providing everything is synced to the database),
> ie, 'Python' validation; or something along the lines of form
> validation? If the latter, perhaps importing Profile into the views.py?
> It must be similar to using contrib.auth.user and extending the user
> profile with your own class.
> Otherwise, I'm currently out of suggestions...
>
>Evert
>
>
>
> >>> I am a bit confused as to why it is that this gives me an error. I
> >>> hope someone could explain it to me.
>
> >>> Let's say I have users with Profiles that can be connected to the
> >>> one
> >>> Web page that they can author. The other Users can bookmark that
> >>> page.
> >>> So my models look like this:
>
> >>> profiles.models.py
>
> >>> from bookmarks.models import Bookmark
>
> >>> class Profile(models.Model):
> >>> ...bookmarks = models.ManyToManyField(Webpage)
>
> >>> 
> >>> bookmarks.models.py
>
> >>> from profiles.models import Profile
> >>> ...author = models.ForeignKey(Profile)
>
> >> Michael, could this have to do with the note in this section:
> >>http://www.djangoproject.com/documentation/model-api/#many-to-one-
> >> relationships
> >> "Note, however, that you can only use strings to refer to models in
> >> the same models.py file -- you cannot use a string to reference a
> >> model in a different application, or to reference a model that has
> >> been imported from elsewhere."
> >> So try to quote 'Profile', instead of importing it.
>
> >>> I get an import error when I try to validate this. I realize that
> >>> there is a little of cross referencing occurring, but I really
> >>> cannot
> >>> think of a better way to accomplish this. Any ideas?
>
> >>> Thanks, Michael Newman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: self referential manytomany

2008-02-21 Thread Michael Newman

That would be true if I defined both models in the same models.py, and
Profile was trying to use Bookmark before it was loaded in the file.
Because this is an import the quotes won't work. That being said this
in one model works when I don't need to put a import statement in it.
So:

profiles/models.py
###

class Profile(models.Model):
...bookmarks = models.ManyToManyField(Webpage,
related_name='bookmarks')

from profiles.models import Profile
...author = models.ForeignKey(Profile)


###
This validates, but it's not as modular as I would like. Any other
ideas?

Thanks for tip anyway.

On Feb 21, 11:58 am, Evert Rol <[EMAIL PROTECTED]> wrote:
> On 21 Feb 2008, at 16:44 , Michael Newman wrote:
>
>
>
>
>
> > I am a bit confused as to why it is that this gives me an error. I
> > hope someone could explain it to me.
>
> > Let's say I have users with Profiles that can be connected to the one
> > Web page that they can author. The other Users can bookmark that page.
> > So my models look like this:
>
> > profiles.models.py
>
> > from bookmarks.models import Bookmark
>
> > class Profile(models.Model):
> > ...bookmarks = models.ManyToManyField(Webpage)
>
> > 
> > bookmarks.models.py
>
> > from profiles.models import Profile
> > ...author = models.ForeignKey(Profile)
>
> Michael, could this have to do with the note in this section: 
> http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships
> "Note, however, that you can only use strings to refer to models in
> the same models.py file -- you cannot use a string to reference a
> model in a different application, or to reference a model that has
> been imported from elsewhere."
> So try to quote 'Profile', instead of importing it.
>
>
>
> > I get an import error when I try to validate this. I realize that
> > there is a little of cross referencing occurring, but I really cannot
> > think of a better way to accomplish this. Any ideas?
>
> > Thanks, Michael Newman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



self referential manytomany

2008-02-21 Thread Michael Newman

I am a bit confused as to why it is that this gives me an error. I
hope someone could explain it to me.

Let's say I have users with Profiles that can be connected to the one
Web page that they can author. The other Users can bookmark that page.
So my models look like this:

profiles.models.py

from bookmarks.models import Bookmark

class Profile(models.Model):
...bookmarks = models.ManyToManyField(Webpage)


bookmarks.models.py

from profiles.models import Profile
...author = models.ForeignKey(Profile)



I get an import error when I try to validate this. I realize that
there is a little of cross referencing occurring, but I really cannot
think of a better way to accomplish this. Any ideas?

Thanks, Michael Newman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Multiple ForeignKey Relationship

2008-02-21 Thread Michael Newman

http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships

look at the edit inline option. The blogosphere is also nice enough to
have posted hundreds of examples and test cases that might meet your
purposes. Google django edit inline for these examples.

On Feb 21, 9:56 am, [EMAIL PROTECTED] wrote:
> I'm trying to work out how I'm going to setup a model structure a
> video section of my website. Say I have this scenario.
>
> - Each video belongs to a set of 4-5 videos.
> - Depending on the set the video belongs too, certain information will
> need to be attached to that video (ie> recipe/chef information, wines
> to drink with this recipe. Etc.)
> - Videos need to be able to be independent as well, in case the set is
> removed but the video is still wanted on the site. Same goes for
> Recipes as they will exist independently on the site.
> - In the future Videos will reside within different sets and require
> different information then these.
>
> So, my situation is this:
>
> I have a Video model setup as a ForeignKey to my VideoSet model. I
> then have Recipe and Chef information each setup as a ForeignKey to
> Video. This is great for adding Recipe and Chef info to a video
> directly through the admin, however the Recipe and Chef information do
> not get attached to the Video within the VideoSet admin interface.
>
> Is there a way to nest ForeignKey relationships?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Issues with IE7 and {% for %} {% endfor %} tag

2008-02-21 Thread Michael Newman

If that isn't the issue make sure to look at the source HTML. If it is
rendering the code then there is something wrong with your styles that
IE is hiding your content (Most likely a position:relative float
thing). Or you might want to kick apache, sometimes it loads old
settings. Last thing that I think it could be is a cache issue. If you
are loading the file into the html IE holds onto non-timestamped files
longer. Clear it and see if that fixes it.

On Feb 21, 9:52 am, David Marquis <[EMAIL PROTECTED]> wrote:
> Malcom is right, this has absolutely nothing to do with the {% for %}
> tag.
>
> My guess is that your IE7 might be more restrictive on cookies and not
> allowing the server to create a session cookie.
> If your view code assumes that there is a session and you fetch
> "prize" from the session, then "prize" might simply be empty in IE.
>
> --
> David
>
> On 21-Feb-08, at 8:26 AM, merric wrote:
>
>
>
> > I have a template that uses  {% for i in prize %}  {{ i.description }}
> > {% endfor %}
>
> > This iterates fine in Firefox, but in IE7 it keeps coming up blank.
> > I can't see any html issues.  I am working off my localhost.   Is this
> > a IE7 security issue or something else I have not thought of?
>
> > Cheers
>
> > MerMer
> > >
>
>
>  smime.p7s
> 5KDownload

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Bound form showing image default

2008-02-18 Thread Michael Newman

I have a newform that I am binding to a model and allowing a user to
edit it. Problem is the images don't show up. I know I have seen some
blog or post that discusses this, but I can't find them anywhere. I
assume the best way to do this is to create a custom widget with a
render function that includes the image. I can't find documentation
anywhere on how to create a custom widget render right. Any help would
be very appreciated!!! 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: forms question

2008-02-14 Thread Michael Newman

This one has been debated over and over. It has been decided that
there will be no more as_...() because it is simple enough to hook
into the class and make your own. Here is the discussion over at
django-devs: 
https://groups.google.com/group/django-developers/browse_thread/thread/e3bcd07da81c3275/6337f9a93167c212

On Feb 14, 4:47 pm, Chris <[EMAIL PROTECTED]> wrote:
> will there ever be an forms.as_div method? tables seems kinda old
> school.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Annoying little bug that just won't stop -- new forms admin

2008-02-14 Thread Michael Newman

As I continue to test this, it appears that inline image fields don't
work at all in newforms Admin. Yikes!!! Can someone confirm?

My code:

from django.db import models

class TestObject(models.Model):
somefield = models.CharField(max_length=100)

class TestObjectImageInline(models.Model):
test_object = models.ForeignKey(TestObject)
image = models.ImageField(upload_to='images')
anotherfield = models.BooleanField(default=True)

from django.contrib import admin

class TestObjectInline(admin.TabularInline):
model = TestObjectImageInline

class TestObjectAdmin(admin.ModelAdmin):
model = TestObject
inlines = [TestObjectInline]

admin.site.register(TestObject, TestObjectAdmin)


On Feb 14, 4:34 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> I get an 'Upload a valid image. The file you uploaded was either not
> an image or a corrupted image.' When I try to save a model in the
> admin. I had this issue in the oldforms admin as well. I was passed to
> this 
> article:http://scottbarnham.com/blog/2007/08/22/edit-inline-with-imagefield-o...
> . The ticket was thrown out because of the anticipation of newforms
> admin. Odd thing is FileField does not throw the same error.
>
> Here is my code:
>
> from django.db import models
>
> class TestObject(models.Model):
> somefield = models.CharField(max_length=100)
>
> class TestObjectImageInline(models.Model):
> test_object = models.ForeignKey(TestObject)
> image = models.ImageField(upload_to='images')
>
> from django.contrib import admin
>
> class TestObjectInline(admin.TabularInline):
> model = TestObjectImageInline
>
> class TestObjectAdmin(admin.ModelAdmin):
> model = TestObject
> inlines = [TestObjectInline]
>
> admin.site.register(TestObject, TestObjectAdmin)
>
> Can others duplicate? I am planning on filing a ticket but I would
> like to figure out where it is that the error is being thrown. Any
> insight on that would be great as well.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Annoying little bug that just won't stop -- new forms admin

2008-02-14 Thread Michael Newman

I get an 'Upload a valid image. The file you uploaded was either not
an image or a corrupted image.' When I try to save a model in the
admin. I had this issue in the oldforms admin as well. I was passed to
this article: 
http://scottbarnham.com/blog/2007/08/22/edit-inline-with-imagefield-or-filefield-in-django-admin/
. The ticket was thrown out because of the anticipation of newforms
admin. Odd thing is FileField does not throw the same error.

Here is my code:

from django.db import models

class TestObject(models.Model):
somefield = models.CharField(max_length=100)

class TestObjectImageInline(models.Model):
test_object = models.ForeignKey(TestObject)
image = models.ImageField(upload_to='images')

from django.contrib import admin

class TestObjectInline(admin.TabularInline):
model = TestObjectImageInline

class TestObjectAdmin(admin.ModelAdmin):
model = TestObject
inlines = [TestObjectInline]

admin.site.register(TestObject, TestObjectAdmin)

Can others duplicate? I am planning on filing a ticket but I would
like to figure out where it is that the error is being thrown. Any
insight on that would be great as well.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Deploying django app

2008-02-14 Thread Michael Newman

You can put Django where ever as long as you add it to your python
path then. The problem with a lot of these shared hosts is the fact
that they don't have mod_python and other requirements that are needed
to let django run. Read through this install documentation
http://www.djangoproject.com/documentation/install/ and make sure that
you have access to all the dependencies with your Web host. You should
try using the trunk and not running setup.py because it might break
with limited access to other directories.

To be perfectly honest, however, I doubt a host that doesn't give you
shell access will have all the dependencies to run a python framework.
This is a great resource for hosts that have the abilities to run
django: http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

On Feb 14, 7:23 am, "Mr.Carra" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm wondering if it's possible to deploy custom django application
> with django embedded? ie that user have to only run install script on
> they web server and it would "locally" install webaplication.
> Most users don't have shell access to their webserver and have only
> one directory to use.
>
> Regards
> mr. Carra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: create user, using generic.auth

2008-02-13 Thread Michael Newman

Before saving the user you can add all your information after you call
the function. So:
new_user = User.objects.create_user(user name, email, password)
new_user.first_name = 'john'
new_user.last_name = 'doe'
new_user.save()

Note the user isn't actually created until you make the save call. If
you want birthday you should look into the get_profile() function and
a great article by James Bennett on Extending the user model:
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

Here is a link to the docs that can be helpful:
http://www.djangoproject.com/documentation/authentication/

Hope that helps, Michael Newman

On Feb 13, 3:17 pm, dall <[EMAIL PROTECTED]> wrote:
> Why in User.objects.create_user(user name, email, password)
>
> I can`t add more data, like birthday, last name, first name ?
>
> Or how to do it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: static content permissions

2008-02-13 Thread Michael Newman

Hey Jonathan;

You are going to love that setup (I know I do).

Django actually is never aware of media files. It just lets apache
serve them. To set this up in your apache site configuration you
should have DocumentRoot set and then for the path of you media file
have a Location entry with SetHandler None in there. Then put all your
media in the media directory and apache serves it just like normal.

For example on my ubuntu box I have /etc/apache2/sites-enabled/site
looking like this:


ServerName foo
ServerAlias foo.com
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /var/www/vhosts/foo.com/


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE bar.settings
PythonDebug On
PythonInterpreter bar
PythonPath "['/opt/django']+sys.path"



SetHandler None



SetHandler None




On Feb 13, 2:31 pm, [EMAIL PROTECTED] wrote:
> Forgive my idiocy,
>
> I have just installed Ubuntu + Apache 2.2 + MySQL + mod_python +
> django on an old machine and am using it for development.  I am having
> difficulty getting my stylesheets to render.  If I'm not using the
> *bad* way of serving the static content, do I still need a view to
> process the url?  If so, what should it look like?
>
> Thank you,
> Jonathan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newforms admin and Django registration

2008-02-13 Thread Michael Newman

I am exploring this further in the morning and I am wondering if the
issue is the fact that django.contrib.auth.views uses the oldform
methods. Could this be what is throwing this error? Is there or are
there plans for converting django.contrib.auth.forms to new forms? If
I spent time doing that would it be time well spent?

On Feb 12, 11:41 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> It took a couple of days, but I finally got all my projects switched
> to new forms admin. It is so powerful. I cannot wait to see wait to
> see what kinds of things I will be ablt to accomplish.
>
> That being said, of course, I need to switch some of the snippets of
> code that I barrowed from people smarter than me. One such person is
> Jame Bennett and django-registration has been an invaluable tool. One
> of the sites I switched uses that code, and I went into models and
> tried my hardest to find and replace all the code that has changed.
>
> The admin works fine database looks good and the shell seems to be in
> order too on the simple tests that I run. I am just having one error
> that I just can't figure out (thus I am still at work at 11:30). Here
> is the error I am getting on any registration page:
> URI:'/registration/registration'
> Location:   '/'
> Directory:  None
> Filename:   '/var/www/vhosts/development/registration'
> PathInfo:   '/registration'
>
> Phase:  'PythonHandler'
> Handler:'django.core.handlers.modpython'
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1537, in HandlerDispatch
> default=default_handler, arg=req, silent=hlist.silent)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1229, in _process_target
> result = _execute_target(config, req, object, arg)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1128, in _execute_target
> result = object(arg)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 188, in handler
> return ModPythonHandler()(req)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 161, in __call__
> response = self.get_response(request)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 64, in get_response
> response = middleware_method(request)
>
>   File "/usr/lib/python2.5/site-packages/django/middleware/common.py",
> line 57, in process_request
> urlresolvers.resolve(request.path)
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 292, in resolve
> return get_resolver(urlconf).resolve(path)
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 233, in resolve
> sub_match = pattern.resolve(new_path)
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 231, in resolve
> for pattern in self.urlconf_module.urlpatterns:
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 255, in _get_urlconf_module
> raise ImproperlyConfigured, "Error while importing URLconf %r: %s"
> % (self.urlconf_name, e)
>
> ImproperlyConfigured: Error while importing URLconf
> 'registration.urls': cannot import name UserCreationForm
>
> Any one who has any insight as to what this error means or experience
> with django-registration in newforms admin and would care to share it,
> I would be very grateful. I found this 
> tickethttp://code.djangoproject.com/ticket/6572
> , but I assume it is my code and not a bug. Thanks in advance.
>
> Michael Newman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: filter fields that have a value

2008-02-13 Thread Michael Newman

The problem is you are filtering the video attribute of your articles
and thus returning 3. Try Article.objects.filter(video=True) I think
that should work.

On Feb 13, 7:04 am, Martin <[EMAIL PROTECTED]> wrote:
> hello,
>
> i'm struggling with ManyToMany fields (Rajesh helped me a lot;) and
> have another question. My model Article, has ManyToMany relation with
> Video model (for storing only youtube videos).
>
> class Article(models.Model):
> video = models.ManyToManyField(Video, blank=True, null=True)
>
> class Video(models.Model):
> url = models.CharField(max_length=300)
> name = models.CharField(max_length=300)
>
> Then i add 3 videos to an Article. Since not all articles have videos,
> i want to filter out those that have it.
> Filter looks like this:
>
> Article.objects.filter(video__isnull=False)
>
> So here is the problem.. let's say i have 5 articles in my DB and only
> one has 3 videos.. this filter doesn't return an article that has
> videos, but rather returns 3x the same article name.. probably,
> because of 3 added videos to it.
> so my question here is: is this the right way to check, if article has
> videos (Article.objects.filter(video__isnull=False))? if this the
> right way, what is (should i add costum method in my model)?
>
> I would appreciate any help,
>
> Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Links to images in Blog posts

2008-02-13 Thread Michael Newman

Hi Florian;

You might want to look into a separate object for your images and add
them as either a manytomanyfield in you story object or have them
edited inline as foreign key objects. Look at the relationships here:
http://www.djangoproject.com/documentation/model-api/#relationships .
You would use manytomany if you would like to reuse images in multiple
stories and foreign key if you want the authors to upload their images
on the same page as the story or the images should always be tied to
one and only one story.

I recently had a similar issue with how to give the author the ability
to place the images in an exact place of a story. Here you have a few
options. You can have a set place for images like a slideshow, you
could somehow change an admin field to show the absolute url of the
image in the display, or you could create a custom form field for you
story object that uses ajax or just javascript to dynamically place
text that would be replaced by a manager or while the data is cleaned
on the admin side to put the image into the story. You could probably
have a middle class also help with that last option, which would be
the most flexible and simple, but also the most difficult.

Another way that doesn't involve putting the image in the database is
by using a textedit kit like YUI's or TinyMCE, which uploads images to
a directory and puts the code in. Of course you won't get the django
management features with those images.

Hope that helps get you on your way, This was one of the hardest parts
for me switching from blog applications like wordpress to Django, but
once you develop a system it will last forever and be considerably
more flexible.

Michael Newman

On Feb 13, 4:31 am, Florian Lindner <[EMAIL PROTECTED]> wrote:
> Hello,
> this is a repost of an mail I sent some days ago. Since no one replied
> and I don't think that noone has an opinion about that I dare to post
> again.
>
> I have some problems about my blog which I would like to hear your
> opinion about.
>
> A user should have the possibility to upload image files in an post
> (which is represented by a Model). Images can be displayed either
> seperately from the text or can be embedded in the text.
> If embedded in the text [1] the user does not know the real URL when
> uploading an image (because he does not necessarily know the value of
> MEDIA_ROOT) he can't give the real URL. Therefore I somehow need to
> preprocess the text and replace the relative URL (which could be just
> the name of the image) with the complete URL.
> Is this thought correct so far? Or is there a smarter way to achieve
> it? How would you do it?
>
> The place where images are stored is determined by the value of
> MEDIA_ROOT and upload_to of the FileField. If I want to upload the
> pictures to "MEDIA_ROOT/blog/p_id" where p_id is the ID of the blog
> entry containing the FileField. How would I do that?
>
> If I user wants to upload n pictures (n > 1): How can I provide him
> with multiple FileFields. Just creating a dozens of FileField in my
> model just in case does not seem the way to go for me. Is there a
> Django solution for a variable number of fields of the same type?
> Well, I could make just the FileField a seperat model and use a 1:n
> relationship. Any other ways?
>
> Thanks for all your ideas and comments,
>
> Florian
>
> [1] like that:
> ![Alt text here](Image URL here "Image title 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
-~--~~~~--~~--~--~---



newforms admin and Django registration

2008-02-12 Thread Michael Newman

It took a couple of days, but I finally got all my projects switched
to new forms admin. It is so powerful. I cannot wait to see wait to
see what kinds of things I will be ablt to accomplish.

That being said, of course, I need to switch some of the snippets of
code that I barrowed from people smarter than me. One such person is
Jame Bennett and django-registration has been an invaluable tool. One
of the sites I switched uses that code, and I went into models and
tried my hardest to find and replace all the code that has changed.

The admin works fine database looks good and the shell seems to be in
order too on the simple tests that I run. I am just having one error
that I just can't figure out (thus I am still at work at 11:30). Here
is the error I am getting on any registration page:
URI:'/registration/registration'
Location:   '/'
Directory:  None
Filename:   '/var/www/vhosts/development/registration'
PathInfo:   '/registration'

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 188, in handler
return ModPythonHandler()(req)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 161, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 64, in get_response
response = middleware_method(request)

  File "/usr/lib/python2.5/site-packages/django/middleware/common.py",
line 57, in process_request
urlresolvers.resolve(request.path)

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 292, in resolve
return get_resolver(urlconf).resolve(path)

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 233, in resolve
sub_match = pattern.resolve(new_path)

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 231, in resolve
for pattern in self.urlconf_module.urlpatterns:

  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 255, in _get_urlconf_module
raise ImproperlyConfigured, "Error while importing URLconf %r: %s"
% (self.urlconf_name, e)

ImproperlyConfigured: Error while importing URLconf
'registration.urls': cannot import name UserCreationForm

Any one who has any insight as to what this error means or experience
with django-registration in newforms admin and would care to share it,
I would be very grateful. I found this ticket 
http://code.djangoproject.com/ticket/6572
, but I assume it is my code and not a bug. Thanks in advance.

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



Re: Strange issue with too many Foriegn Keys

2008-02-06 Thread Michael Newman

THANK YOU so much. That was exactly what I was looking for. A bit of a
hack fix. Maybe I can look into writing a patch for it since I am
going to need to work on a fix that I feel comfortable with anyways.

I started looking at new forms the last couple of hours thinking that
would be a fix. It looks really promising. Problem is I need this for
a production site. Anyone recommend moving to a branch if I am
interested in switching? Is it stable and will the code be forwards
compatible as it merges? Once this site goes live (in the next few
weeks) I won't really be able to revisit it for a while.

On Feb 6, 10:17 pm, Aaron Fay <[EMAIL PROTECTED]> wrote:
> Hey Michael,
>
> I ran across this article a couple days ago that seems to have a
> workaround to your problem:
>
> http://scottbarnham.com/blog/2007/08/22/edit-inline-with-imagefield-o...
>
> Hope that helps,
> Aaron
>
> Michael Newman wrote:
> > I am trying this new way of inheriting a lot of information for a
> > project I am working on. This site I need to extend the user profile,
> > then certain people can have their own sites and then those sites can
> > have 10 photographs to add to a slide show.
>
> > so I have:
>
> > exampleapp.py
> > -- models.py
>
> > class Profile(models.Model):
> >models.ForeignKey(User, unique=True)
> >...
>
> > class WebSite(models.Model):
> >models.ForeignKey(Profile)
> >...
>
> > class WebsiteImage(models.Model):
> >models.ImageField(upload_to='myimagedir', core=True)
> >models.ForiegnKey(WebSite, edit_inline=models.TABULAR,
> > num_in_admin=10,max_num_in_admin=10)
> >...
>
> > I create a Website and save a bunch of images. I click back on the
> > WebSite to edit it. I click save without editing anything. Go back to
> > look at the item and the Images are no longer there. Nor are the
> > database tables.
>
> > This is really confusing. Does anyone have any ideas? Is this a known
> > issue or something dumb that I am doing? Thanks in advance for any
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Performance problem. Server overloading with a lot of apache processes

2008-02-06 Thread Michael Newman

Reality is 19 apache processes isn't that much. That means there are
only about 19 requests on your server at one time. So what that means
is that either your server is whoafully unprepared for the real world,
or what is being done with your processes is really heavy, like file
uploading or processing. CGI might actually increase the memory usage
by your system if you are uploading files and lighttp only will help
marginally with your static media files.

If it is file processing and heavy scripts is all you are doing,
caching will really help your server load because it will limit the
time each request takes on the server. If it is file uploading it's
time to think of a more powerful server or server array, because you
need a persistent connection with a relatively large amount of memory
being used.

All my research and trials with lighttp and nginx have come up with
the same conclusion: the savings in server load isn't worth the
effort. They are more of a tweaking thing. Clean code and the smallest
requests possible make for an easy server load that ultimately scales
well and is well worth the effort.

By all means feel free to try other solutions. There are tons of
tutorials out there and Django is so portable that you won't need to
spend too much time rewriting code just configuring the web server.
But from my experience you might want to revisit your code or ask
exactly you are trying to do and decide if your server is capible.

Anyways, iyi sanslar ve kolay gelsin!!!


On Feb 6, 6:52 pm, Eren Türkay <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I have a project that has a lot of models and database relationship is little
> complex. I run my code with apache2 and mod_python. My problem is that there
> is a lot of apache processes and these eat too much memory.
>
> Yesterday, 10 minutes after I announced the site's new design, the server was
> overloaded and I wasn't able to login into it via ssh for 6 hours. When I
> logged, I realized that there was ~19 apache processes and the consume of
> memory was %99! I rebooted the machine and everything looked well, but still
> there were lots of apaches. I checked logs, there wasn't DDOS attack or
> something else, it was just regular visiting of users.
>
> Is it normal? I don't think so. Now I'm thinking of using lighttpd and cgi. I
> hope, this will reduce CPU and MEM usage but I don't know if it will work.
>
> Using cache mechanism can be suggested but I don't think it's related with
> apache's mem/cpu usage.
>
> Has someone faced this problem before? Any ideas?
>
> Regards,
> Eren
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Strange issue with too many Foriegn Keys

2008-02-06 Thread Michael Newman

I am trying this new way of inheriting a lot of information for a
project I am working on. This site I need to extend the user profile,
then certain people can have their own sites and then those sites can
have 10 photographs to add to a slide show.

so I have:

exampleapp.py
-- models.py

class Profile(models.Model):
   models.ForeignKey(User, unique=True)
   ...

class WebSite(models.Model):
   models.ForeignKey(Profile)
   ...

class WebsiteImage(models.Model):
   models.ImageField(upload_to='myimagedir', core=True)
   models.ForiegnKey(WebSite, edit_inline=models.TABULAR,
num_in_admin=10,max_num_in_admin=10)
   ...

I create a Website and save a bunch of images. I click back on the
WebSite to edit it. I click save without editing anything. Go back to
look at the item and the Images are no longer there. Nor are the
database tables.

This is really confusing. Does anyone have any ideas? Is this a known
issue or something dumb that I am doing? Thanks in advance for any
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Serving flatpages before other urls

2008-01-28 Thread Michael Newman

Is there anyway to change the order that the urls are checked? For
example I have an about us page that is generated by a url conf. I
want my designer to make his own about us page with flatpages and
therefore 'overwrite' the url that is autogenerated. I know right now
flatpages checks the url after a 404 is received, but I want it to
work the other way around. Any ideas?

Thanks in advance, Mn
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Pros and cons of include URLs

2008-01-23 Thread Michael Newman

Just a quick question that might be an easy answer but I am curious.
Why is it that in the URL dispatcher all the direct to views use the
first argument in urlpatterns but when we use include it doesn't
matter? Example:

urlpatterns = patterns('myapp.views',
(r'^foo', include('myapp.foo.urls')),
url(r'^$', 'home'),
)

as opposed to:
urlpatterns = patterns('myapp',
(r'^foo', include('foo.urls')),
url(r'^$', 'views.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Python Egg issues

2007-12-03 Thread Michael Newman

tried it fresh, tried it with stuff in it (for kicks). Either way
nothing shows up, changes etc. That whole issue with mod_python might
be the issue. For the meanwhile, so I can get to bed tonight I just
ran easy_install. I will try without the absolute paths tomorrow.
Thanks

On Dec 3, 7:55 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Dec 4, 11:22 am, Michael Newman <[EMAIL PROTECTED]> wrote:
>
>
>
> > This isn't strictly a problem with Django, but for some reason I am
> > having problems extracting my python eggs. Mod_python comes back with:
>
> > ExtractionError: Can't extract file(s) to egg cache
>
> > The following error occurred while trying to extract file(s) to the
> > Python egg
> > cache:
>
> >   [Errno 13] Permission denied: '/opt/django/eggdump/
> > MySQL_python-1.2.2-py2.5-linux-i686.egg-tmp'
>
> > The Python egg cache directory is currently set to:
>
> >   /opt/django/eggdump
>
> > Perhaps your account does not have write access to this directory?
> > You can
> > change the cache directory by setting the PYTHON_EGG_CACHE environment
> > variable to point to an accessible directory.
> > 
> > I read these 
> > docshttp://www.djangoproject.com/documentation/modpython/#using-eggs-with...
> > and created the proper file and tried to put the files in my django
> > directory. I also tried tmp and site-packages and no luck. This is a
> > development box so I set the permissions of opt to fully executable. I
> > also did sudo -u apache touch /opt/django/eggdump/file.txt and that
> > worked.
>
> > I am completely confounded, a bit tired and really annoyed. Anyone
> > else encounter this issue before? What can I do?
>
> FWIW, in relation to use of the PythonImport directive, Django
> documentation says:
>
> """Note that you can use an absolute path here (or a normal dotted
> import path), as described in the mod_python manual. We use an
> absolute path in the above example because if any Python path
> modifications are required to access your project, they will not have
> been done at the time the PythonImport line is processed."""
>
> What the documentation doesn't say is that an absolute path can only
> be used if you are using mod_python 3.3. If you are using an older
> version of mod_python it will not work with an absolute path.
>
> Anyway, did you completely remove the contents of your eggdump
> directory before running it under mod_python, or are you allowing it
> to try and unpack stuff on top of old stuff put there when run as a
> different user and therefore with conflicting permissions. If you
> ensure that eggdump directory is empty first, does it still fail?
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Python Egg issues

2007-12-03 Thread Michael Newman

This isn't strictly a problem with Django, but for some reason I am
having problems extracting my python eggs. Mod_python comes back with:

ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the
Python egg
cache:

  [Errno 13] Permission denied: '/opt/django/eggdump/
MySQL_python-1.2.2-py2.5-linux-i686.egg-tmp'

The Python egg cache directory is currently set to:

  /opt/django/eggdump

Perhaps your account does not have write access to this directory?
You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

I read these docs 
http://www.djangoproject.com/documentation/modpython/#using-eggs-with-mod-python
and created the proper file and tried to put the files in my django
directory. I also tried tmp and site-packages and no luck. This is a
development box so I set the permissions of opt to fully executable. I
also did sudo -u apache touch /opt/django/eggdump/file.txt and that
worked.

I am completely confounded, a bit tired and really annoyed. Anyone
else encounter this issue before? What can I do?

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



Re: Custom Validator inside of a Custom Manipulator

2007-10-20 Thread Michael Newman

Now that I am moving forward, I am beginning to wonder about the
automatic (Free) validation that is supplied in those docs I mentioned
above. The profanity filter for example is a great tool. Will that
stay in the 1+ versions of Django? I could use them in a BaseForm as:
clean_textfield(self):
 
django.core.validators.hasNoProfanities(self.clean_data['textfield'],
null)

but I wouldn't want to do this if those validators won't be there any
longer.

On Oct 20, 2:25 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> Thanks for the help. I finally put two and two together. I was
> following this tutorialhttp://www.djangoproject.com/documentation/forms/
> and somehow got myself all messed up. Thanks for the reply and back to
> the code.
>
> On Oct 20, 4:02 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Well... Your code looks like a crazy mixture of newforms and
> > oldforms :)
> > Now it is much wiser to use newforms. They don't have validators, nor
> > manipulators.
> > The information on newforms can be found in django documentation.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Custom Validator inside of a Custom Manipulator

2007-10-20 Thread Michael Newman

Thanks for the help. I finally put two and two together. I was
following this tutorial http://www.djangoproject.com/documentation/forms/
and somehow got myself all messed up. Thanks for the reply and back to
the code.

On Oct 20, 4:02 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Well... Your code looks like a crazy mixture of newforms and
> oldforms :)
> Now it is much wiser to use newforms. They don't have validators, nor
> manipulators.
> The information on newforms can be found in django documentation.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Error when I use datetime.now()

2007-10-19 Thread Michael Newman

try datetime.now().__str__() or if you want to make it pretty try
datetime.now().strftime(YourCustomFormatHere). Look at
http://docs.python.org/lib/strftime-behavior.html#strftime-behavior

Your problem is a datetime object is a not a string. Both those above
examples turn it into a string.

On Oct 19, 11:22 pm, Greg <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a class called Orders that tries to add the current date to
> it's comments field when it's saved.  Here is my code:
>
> from datetime import datetime
>
> class Order(models.Model):
> comments = models.TextField("Comments", maxlength=1000)
> etc...
>
> def save(self):
> self.comments += "This is a string - " + datetime.now() + "
> This is a string "
>
> 
>
> Whenever, I save my order class I get the following error:
>
> TypeError at /admin/plush/order/1/
> cannot concatenate 'str' and 'datetime.datetime' objects
>
> Any Suggestions?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Custom Validator inside of a Custom Manipulator

2007-10-19 Thread Michael Newman

I am so close to getting this project done. The last little bit is all
about validation. I have been following the docs pretty closely and am
really at a loss as to what is going on right now. The Error:
TypeError at /videoUploader/
__init__() got an unexpected keyword argument 'field_name'

Here is my views.py:

from django.http import HttpResponse, HttpResponseRedirect
from django import newforms as forms
from videouploader.upload.models import VideoSubmission
from django.shortcuts import render_to_response, get_object_or_404
from videouploader.upload.validator import VideoManipulator


def upload_video(request):
m = VideoManipulator()
if request.method =='POST':
new_data = request.POST.copy()
new_data.update(request.FILES)
errors = m.get_validation_errors(new_data)
m.do_html2python(new_data)
if not errors:
new_video = VideoSubmission.save(new_data)
return HttpResponseRedirect('/videoUploader/
done/%i' % new_video.id)
else:
errors = new_data = {}
form = forms.FormWrapper(m, new_data, errors)
return render_to_response('form.html',{
'form': form
})

and the validator/manipulator file:

from django.forms import Manipulator
from django import newforms as forms
from django.core import validators
from datetime import date

class VideoManipulator(Manipulator):
def __init__(self):
self.fields = (
forms.FileField( field_name = "videoupload",
validator_list = [self.isValidFile]),
forms.EmailField( field_name = "email",
validator_list = [validators.isValidEmail]),
forms.CharField( field_name = "entrantname",
validator_list = [validators.hasNoProfanities]),
forms.DateField( field_name = "entrantDOB",
vallidator_list = [self.is18]),
forms.CharField( field_name = "name",
validator_list = [validators.hasNoProfanities]),
forms.DateField( field_name = "kidDOB",
validator_list = [self.isInDateRange]),
forms.CharField( field_name = "city",
validator_list = [validators.hasNoProfanities]),
forms.TextField( field_name = "caption",
validator_list = [validators.hasNoProfanities]),
forms.BooleanField( field_name = "TOS",
validator_list = [self.mustBeTrue]),
forms.BooleanField( field_name = "parent",
validator_list = [self.mustBeTrue]),
forms.BooleanField( field_name = "waiver",
validator_list = [self.mustBeTrue]),
)


Any help would be greatly appreciated. This will keep me up tonight ;)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



What is happening with mod_python

2007-10-17 Thread Michael Newman

This is strange and I am sure I am doing something wrong, but i have
been starring at this for a while now and can't see it.
I am getting this mod_python error:

ProcessId:  31673
Interpreter:'mysite'

ServerName: 'mysite'
DocumentRoot:   '/var/www/vhosts/mysite/httpdocs'

URI:'/myapp'
Location:   '/myapp'
Directory:  None
Filename:   '/var/www/vhosts/mysite/httpdocs/myapp'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/local/lib/python2.5/site-packages/mod_python/
importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/local/lib/python2.5/site-packages/mod_python/
importer.py", line 1202, in _process_target
module = import_module(module_name, path=path)

  File "/usr/local/lib/python2.5/site-packages/mod_python/
importer.py", line 304, in import_module
return __import__(module_name, {}, {}, ['*'])

ImportError: No module named django.core.handlers.modpython




my conf file is a basic:




SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE videouploader.settings
PythonDebug On
PythonPath "['/home/django/myapp']+sys.path"


can anyone see the stupid mistake that I am making?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-Many with quantities

2007-06-01 Thread Michael Newman

I use this code in quite a few of my programs and never have issues. I
don't know why you are having this problem and it is not throwing any
errors. Are you using the Web interface at all? If so when saving are
there any errors. If the objects aren;t saving to the db generally
Python throughs some erros that can point the to the problem.
The next guess I would tell you is to use the related_name variable to
rename the foreign key so the code doesn't confuse the variables.

Malcolm is right on this one; you need to figure out exactly what is
going on before you submit a bug, because otherwise you are just
wasting the programmers' time trying to reproduce the problem. Let's
exhaust all the other possibilities first and figure out what is going
on.

Hope that helps,
Mn

On Jun 1, 3:46 am, Gio <[EMAIL PROTECTED]> wrote:
> > The usual process when you have one version of code that is working and
> > a more complicated version that is not working is to add features to the
> > working version, one at a time, until it stops working. In that way you
> > will be able to narrow down exactly which is the problematic step and
> > then work out, for example, if you do that step first, does it still
> > fail. Tracking down precisely where the problem lies is going to be
> > helpful to anybody trying to fix/understand this problem.
>
> > Regards,
> > Malcolm
>
> Yes, but the problem here is already at the level you point to.
> Take my code version and replace
>
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza, core=True)
>
> with
>
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza, edit_inline = models.TABULAR,
> core=True)
>
> and you will switch from a working version to a crappy one.
> edit_inline = models.STACKED is no better.
> I miss something?
>
> I would like to add that I think that this "generalized ManyToMany" is
> very useful, shouldn't this be mentioned in the official
> documentation?
> As 42th Model Example?
> I think this is excellent during first phases of Django learning as it
> exposes you directly to the inner functionality of the ManyToMany
> shortcut.
>
> Let me go even further: what about a new option for ManyToManyField
> letting you declare the amount as seen in our Pizza-Topping example?
> It could be really relevant when using Django for developping web-
> based ERP and similar things.
> Bizarre?
>
> Giovanni.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-Many with quantities

2007-05-31 Thread Michael Newman

Because of the dependants you might need to either manually add the
tables to the db or if you don't have any values in that table delete
all the rows in pizza and run syncdb again. Sometimes when working
within the same class the syncdb doesn't change the database all the
way (and rightly so). Give that a try and if it still doesn't work
we'll try a different solution.

On May 31, 1:03 pm, Gio <[EMAIL PROTECTED]> wrote:
> Thanks to you all, I took something from all the replies and I wrote
> this modifying Michael code:
>
> class Topping(models.Model):
> name = models.CharField(maxlength=255, unique=True)
>
> def __str__(self):
> return self.name
>
> class Admin:
> pass
>
> class Pizza(models.Model):
> name = models.CharField(maxlength=255, unique=True)
>
> def __str__(self):
> return self.name
>
> class Admin:
> pass
>
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza,
>   help_text = 'Toppings to go on Pizza:
> num in admin is how many will show up in Pizza',
>   edit_inline = models.TABULAR,
>   num_in_admin = 3,
>   core=True)
> topping = models.ForeignKey(Topping)
> amount = models.IntegerField()
>
> I got problems in admin: I inserted a few toppings, now when I insert
> a new pizza with his toppings the toppings and quantities aren't
> saved.
> No error messages, but inspecting database reveals no entries for the
> auxiliary table pizza_pizzatopping
>
> Any hint?
> I'd like to solve this problem, leaving a solution for the archives.
>
> Thanks,
> Giovanni.
>
> On 31 Mag, 18:27, Michael Newman <[EMAIL PROTECTED]> wrote:
>
> > Nis;
> > Thanks for catching that I left the manytomany field there. There is
> > no need for that.
> > revised code:
>
> > class Topping(models.Model):
> > # ...
>
> > class Pizza(models.Model):
> > # ...
>
> > class PizzaToppings(model.Model):
> > pizza = models.ForeignKey(Pizza, help_text='Toppings to go on
> > Pizza: num in admin is how many will show up in Pizza',
> > edit_inline=models.TABULAR, num_in_admin=3)
> > topping = models.ManyToOne(Topping)
> > amount = models.IntegerField()
> > #...
>
> > This will appear in the Pizza part of the admin as a stacked model and
> > allow you to use or add as many as you would like. So you can remove
> > the amount if you just want people to be able to add double cheese by
> > adding a second cheese topping.
>
> > Thanks Nis and good luck Giovanni.
>
> > Mn
>
> > On May 31, 12:21 pm, Nis Jorgensen <[EMAIL PROTECTED]> wrote:
>
> > > Gio wrote:
> > > > Hi,
> > > > I searched about this subject and found only a few very old posts, so
> > > > maybe there is a better solution now.
>
> > > > As you may guess the model I'd like to code is similar to the Pizza -
> > > > Toppings you know from the "Creating Models" documentation:
>
> > > > class Topping(models.Model):
> > > > # ...
>
> > > > class Pizza(models.Model):
> > > > # ...
> > > > toppings = models.ManyToManyField(Topping)
>
> > > > And what if I need to say that I can have two or three times the same
> > > > topping on my pizza? Something like twice mozzarella cheese and 3
> > > > times green olives topping?
>
> > > > I though about an intermediary class and indeed this is the same
> > > > solution found in those old posts mentioned before:
>
> > > > class Topping(models.Model):
> > > > # ...
>
> > > > class ToppingAndQuantity(models.Model):
> > > > amount = models.IntegerField()
> > > > topping = models.ForeignKey(Topping)
>
> > > > class Pizza(models.Model):
> > > > # ...
> > > > toppings = models.ManyToManyField(ToppingAndQuantity)
>
> > > > I think it's ugly.
> > > > Can you suggest me a better solution?
> > > > It's that intermediary class really needed?
>
> > > I believe you should have
>
> > > class Topping(models.Model):
> > > # ...
>
> > > class Pizza(models.Model):
> > > # ...
>
> > > class PizzaTopping(models.Model):
> > > amount = models.IntegerField()
> > > topping = models.ForeignKey(Topping)
> > > pizza = models.ForeignKey(Pizza)
>

Re: Many-to-Many with quantities

2007-05-31 Thread Michael Newman

Nis;
Thanks for catching that I left the manytomany field there. There is
no need for that.
revised code:

class Topping(models.Model):
# ...

class Pizza(models.Model):
# ...

class PizzaToppings(model.Model):
pizza = models.ForeignKey(Pizza, help_text='Toppings to go on
Pizza: num in admin is how many will show up in Pizza',
edit_inline=models.TABULAR, num_in_admin=3)
topping = models.ManyToOne(Topping)
amount = models.IntegerField()
#...

This will appear in the Pizza part of the admin as a stacked model and
allow you to use or add as many as you would like. So you can remove
the amount if you just want people to be able to add double cheese by
adding a second cheese topping.

Thanks Nis and good luck Giovanni.

Mn

On May 31, 12:21 pm, Nis Jorgensen <[EMAIL PROTECTED]> wrote:
> Gio wrote:
> > Hi,
> > I searched about this subject and found only a few very old posts, so
> > maybe there is a better solution now.
>
> > As you may guess the model I'd like to code is similar to the Pizza -
> > Toppings you know from the "Creating Models" documentation:
>
> > class Topping(models.Model):
> > # ...
>
> > class Pizza(models.Model):
> > # ...
> > toppings = models.ManyToManyField(Topping)
>
> > And what if I need to say that I can have two or three times the same
> > topping on my pizza? Something like twice mozzarella cheese and 3
> > times green olives topping?
>
> > I though about an intermediary class and indeed this is the same
> > solution found in those old posts mentioned before:
>
> > class Topping(models.Model):
> > # ...
>
> > class ToppingAndQuantity(models.Model):
> > amount = models.IntegerField()
> > topping = models.ForeignKey(Topping)
>
> > class Pizza(models.Model):
> > # ...
> > toppings = models.ManyToManyField(ToppingAndQuantity)
>
> > I think it's ugly.
> > Can you suggest me a better solution?
> > It's that intermediary class really needed?
>
> I believe you should have
>
> class Topping(models.Model):
> # ...
>
> class Pizza(models.Model):
> # ...
>
> class PizzaTopping(models.Model):
> amount = models.IntegerField()
> topping = models.ForeignKey(Topping)
> pizza = models.ForeignKey(Pizza)
>
> The "PizzaTopping" class is really a more elaborate specification of the
> many-to-many relationship, so you don't need the ManyToManyField
> anymore. Your model has the problem that two pizzas can share
> (Mozarella, 2)  - leading to problems if you modify one of them.
>
> You will want to do the invocations for making (topping, pizza) unique
> as well, and possibly do some magic so that trying to add another
> Mozarella will increment the quantity instead.
>
> Disclaimers: I am a novice Django user. The code is untested.
>
> Update: Between posting and reposting from the correct mail address, I
> saw the response from Michael. He is using "ManyToOneField" which I
> don't see in my documentation, and keeps the ManyToManyField(Topping)
> which seems strange to me. I believe you will be able to put together a
> good solution from the two posts.
>
> Nis


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many-to-Many with quantities

2007-05-31 Thread Michael Newman

You could need an extra class for this but it should work:

class Topping(models.Model):
# ...

class Pizza(models.Model):
# ...
toppings = models.ManyToManyField(Topping)

class PizzaToppings(model.Model):
pizza = models.ForeignKey(Pizza, help_text='Toppings to go on
Pizza: num in admin is how many will show up in Pizza',
edit_inline=models.TABULAR, num_in_admin=3)
topping = models.ManyToOne(Topping)
#...

some related material: 
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships

Hope that helps,
Mn


On May 31, 11:48 am, Gio <[EMAIL PROTECTED]> wrote:
> Hi,
> I searched about this subject and found only a few very old posts, so
> maybe there is a better solution now.
>
> As you may guess the model I'd like to code is similar to the Pizza -
> Toppings you know from the "Creating Models" documentation:
>
> class Topping(models.Model):
> # ...
>
> class Pizza(models.Model):
> # ...
> toppings = models.ManyToManyField(Topping)
>
> And what if I need to say that I can have two or three times the same
> topping on my pizza? Something like twice mozzarella cheese and 3
> times green olives topping?
>
> I though about an intermediary class and indeed this is the same
> solution found in those old posts mentioned before:
>
> class Topping(models.Model):
> # ...
>
> class ToppingAndQuantity(models.Model):
> amount = models.IntegerField()
> topping = models.ForeignKey(Topping)
>
> class Pizza(models.Model):
> # ...
> toppings = models.ManyToManyField(ToppingAndQuantity)
>
> I think it's ugly.
> Can you suggest me a better solution?
> It's that intermediary class really needed?
>
> Thank you,
> Giovanni.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with nesh thumbnails and whitespaces

2007-05-31 Thread Michael Newman

You mean White Space in the url of the image?

On May 31, 6:42 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 31-May-07, at 4:05 PM, Alessandro Ronchi wrote:
>
> > I am using ImageWithThumbnailField from nesh utils. if I upload a file
> > with a white
> > space it doens't work, and the file name is thumbnail-none.jpg
>
> ahh - thanks for that tip, some of my sites people were complaining
> that they were getting this none.jpg thing and i couldnt replicate
> the error and they were thinking that I am an idiot and i was
> thinking that they were idiots. White space.
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: views.py filtering and excluding objects

2007-05-29 Thread Michael Newman

Malcolm;
Thanks for everything. I was hoping there was a trick here. I am
interested in getting as much efficiency out of this as possible; in
fact, it is queries like this that made me switch away from php due to
sql hang ups. I guess the long lines of code will have to due. Thanks
for the tip on when Django hits the db,

Thanks for all, Mn

On May 29, 3:17 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-05-29 at 06:56 +, Michael Newman wrote:
> > Thanks for the reply and sorry for my vagueness;
>
> > Rob: I was talking about really long lines of python. Thanks for the
> > heads up about the all. I was just typing off the top of my head and
> > still and figuring out python.
>
> > Malcom: I  suppose that is what I am asking. Is there any simple way
> > to take group of objects like breakingnews in my example and exclude
> > those objects from another set of objects (news) without a for
> > statement?
>
> No. The reasoning runs something like this: If you want to do something
> in two queries like that, it's going to be because you want to filter
> the intermediate results somehow. If you just want to extract the list
> of ids that a straightforward list comprehension over the original
> queryset, so it's not something we need to add extra support for.
>
> If you care about getting every last bit of efficiency out of your
> queries, you won't be doing two queries anyway (we cannot possibly get
> information from the first queryset without running the query, since the
> language is called Python, not Psychic), so this construct isn't
> relevant there. There is a variation on this problem where you might
> need to build nested queries or some such, but there's no support for
> that at the moment. One day, maybe, but not today.
>
> The "long lines" argument isn't really a problem, by the way. You can
> happily write
>
> qs = Story.objects.exclude()
> qs = qs.filter()
> qs = qs.count()
>
> and no database queries will result. Querysets are only evaluated when
> you access the results, not when you add constraints to them. So each
> line need only contain one filter, if that's the way you wish to go.
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: views.py filtering and excluding objects

2007-05-29 Thread Michael Newman

err.. Malcolm--sorry about the typo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: views.py filtering and excluding objects

2007-05-29 Thread Michael Newman

Thanks for the reply and sorry for my vagueness;

Rob: I was talking about really long lines of python. Thanks for the
heads up about the all. I was just typing off the top of my head and
still and figuring out python.

Malcom: I  suppose that is what I am asking. Is there any simple way
to take group of objects like breakingnews in my example and exclude
those objects from another set of objects (news) without a for
statement?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



views.py filtering and excluding objects

2007-05-28 Thread Michael Newman

Something that has been bothering me for awhile and I finally just
decided to post it here because my code work around hits the database
way too many times.

I am writing a custom view for an application that uses multiple
categories per story. So I want to lookup stories so that they aren't
duplicates and they don't appear in a category that is displayed
before. So

breakingnews =
Story.objects.all.filter(category__name__exact="breakingnews")
news = Story.Objects.all.exclude(ids = breakingnews.ids)

Now I realize that I could just exclude the filter, so:
news = Story.Objects.all.exclude(category__name__exact="breakingnews")

but this gets really long once I start factoring time and uniqueness.
Is there an easy way to filter objs like that?

Thanks in advance, Mn


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Data truncated for column 'user_id' at row 1

2007-05-24 Thread Michael Newman

Wow, Thanks for the quick reply. Here I was restructuring my SQL and
everything and it was a simple name problem.

On May 24, 2:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-05-24 at 06:10 +, Michael Newman wrote:
> > This is appearing athttp://speakeasymag.com/staff/Mgnewman
>
> > I have been adjusting the SQL a bit but really don't understand why
> > this error keeps appearing. I did a search and most people who had
> > this problem were dealing with Utf-8 characters. This is an Id column
> > from a foreignKey field, so it is an integer.
>
> > I really have no idea where to start on this one. Any help would be
> > appreciated,
>
> For some reason, you're passing in a string (Mgnewman) where there
> should be an integer. Unfortunately, the traceback nicely hides that
> actual culprit function, which is your view, so we can't see what is the
> root cause. But you need to investigate the line that is trying to do
> the lookup.
>
> Regards,
> Malcolm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: conditional block tag

2007-05-24 Thread Michael Newman

You can also not put anything inside of the {% block header %} and
then when nothing is provided nothing will show up.

On May 23, 11:15 pm, David Robinson <[EMAIL PROTECTED]> wrote:
> I'm probably missing something about your question, and please excuse me
> if that's the case, but wouldn't you be able to do this:
>
> {% if header %}
> 
>{% block header %}Page Heading{% endblock %}
> 
> {% endif %}
>
> Dave
>
> Trey wrote:
> > I have an interesting case that I would like to get some input on,
> > perhaps I am just thinking about it incorrectly.
>
> > It seems useful to have a conditional statement which will check to
> > see if a child template has populated a block.
>
> >   
> > {% block header %}Page Heading{% endblock %}
> >   
>
> > If the block header wasn't sent back, I would like to collapse the
> > header field. Does this seem like something useful or am I going about
> > it the wrong way?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Many to Many relations - DB errors

2007-05-01 Thread Michael Newman

Try using the related_name option in you manytomany feilds as it might
clear up some of your tables. I agree however posting your models.py
will quickly clear this problem up.

On May 1, 9:46 am, MattW <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I'm having problems with the Many-to-Many relations in my model.
>
> I've got a list of questions, each of which has a number of marks
> associated with it. The marks are in another table in the DB. I've
> modelled it as Many-to-Many because it seems that each question can
> have many marks, and each mark (only 1-5) could be associated with
> many questions.
>
> I've tried using both sqlite and mysql (although through mysql_old, as
> I don't have the new Python MySQL interface). Under sqlite I get:
> OperationalError columns X and Y are not unique. Under MySQL, I get
> IntegrityError at xxx, (1062, "Duplicate entry '1-1' for key 2").
> Looking at the DB in PhPMySQL, there's a primary key for the Mark
> table (which has three fields, id, question_id and mark_id), composed
> of the question_id and mark_id fields. I suspect that this is the
> problem, as the mark can change...
>
> Any help in rectify the model.py file would be welcome.
>
> Thanks,
>
> Matt


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Interesting problem importing

2007-04-15 Thread Michael Newman

For anyone looking at this thread in the future. I finally worked this
out. My problem was ridiculously easy. In the settings file for the
MEDIA_URL even though the example gives http://media.lawrence.com it
should be http://media.lawrence.com/. That trailing slash was the
cause of all my problems. Thanks for the help.

On Apr 7, 10:27 pm, "Michael Newman" <[EMAIL PROTECTED]> wrote:
> You're right. Thank you that works. So I am sure that wasn'tproblem.
> Thanks for the help.
>
> On Apr 7, 2:34 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote:
>
> > On 4/7/07, Michael Newman <[EMAIL PROTECTED]> wrote:
>
> > > In the manage.py shell an error when I do the export
> > > File "", line 1
> > > export DJANGO_SETTINGS_MODULE = speakeasy.settings
> > > ^(arrow is under the E)
> > > SyntaxError: invalid syntax
>
> > Hi Michael, I probably wasn't clear in my previous post. I described
> > two ways to launch your python shell, one was to write "python
> > manage.py shell", while the other was to define the environment
> > variable in your bash shell (the export thingy).
>
> > I see that you are already using "python manage.py shell", which means
> > that you don't have to worry about setting the DJANGO_SETTINGS_MODULE
> > environment variable; manage.py already did it for you.
>
> > I apologize if I did things confusing before.
>
> > Cheers,
> > Jorge


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Interesting problem importing

2007-04-07 Thread Michael Newman

You're right. Thank you that works. So I am sure that wasn't problem.
Thanks for the help.

On Apr 7, 2:34 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote:
> On 4/7/07, Michael Newman <[EMAIL PROTECTED]> wrote:
>
>
>
> > In the manage.py shell an error when I do the export
> > File "", line 1
> > export DJANGO_SETTINGS_MODULE = speakeasy.settings
> > ^(arrow is under the E)
> > SyntaxError: invalid syntax
>
> Hi Michael, I probably wasn't clear in my previous post. I described
> two ways to launch your python shell, one was to write "python
> manage.py shell", while the other was to define the environment
> variable in your bash shell (the export thingy).
>
> I see that you are already using "python manage.py shell", which means
> that you don't have to worry about setting the DJANGO_SETTINGS_MODULE
> environment variable; manage.py already did it for you.
>
> I apologize if I did things confusing before.
>
> Cheers,
> Jorge


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Interesting problem importing

2007-04-07 Thread Michael Newman

> Jorge's suggestion is correct for troubleshooting the
> DJANGO_SETTINGS_MODULE error, but it is almost certainly unrelated to
> the problems you're having using nesh.

In the manage.py shell an error when I do the export
File "", line 1
export DJANGO_SETTINGS_MODULE = speakeasy.settings
^(arrow is under the E)
SyntaxError: invalid syntax

> Can you be more specific about what problem you're having with nesh?
> What did you try?
> What code did you use?
> What did you expect to happen?
> What actually happened?

First I tried the ImageWithThumbnailField and in the models and the
models disappeared from the admin. After fooling around with the code
I realized that I needed to use speakeasy.nesh.thumbnail instead of
the default value and it so now the admin field shows up and it
uploads the images but does not create the thumbnails.

This nesh says that the thumbnail creation would fail if PIL isn;t set
up correctly. I tried reinstalling and PIL goes without any errors. So
that isn't the problem.

After fooling around with the I decided to work on the template
filters. Plugging those in as {{image.get_photograph_url|
thumbnail:"width=120"}}. Once again this fails silently and the
original image and size shows up and no thumbnail is created.

Going through the utils.py and the template filter code the only error
I ran into was that import error, which is apparently not an error.

> We'll get this figured out.  Welcome to programming.  :)

Thanks for all. This is really fun when it's not frustrating:)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Block tags inside included templates not getting populated

2007-04-06 Thread Michael Newman

The extends feature is really nice in Django. It's not the php
includes where everything has to be in a block in order and extended
that way. Essentially that means you want all of your base block html
elements in the base and then the higher you go the more detailed you
can get.

Using your example:

base_header.html:
{% extends 'base.html' %}
{% block title %}Your title here{% endblock %}
{% block content %}you could put content here{% endblock content %}


new base.html:



{% block title %}{% endblock title %}

{% block content %}{% endblock %}



You could take this further and create content.html

{% extends 'header.html' %}

{% block content %}
You can put more content here
{% endblock content %}

You could use includes as well but they only carry blocks of text, I
believe, and not the various content blocks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Interesting problem importing

2007-04-06 Thread Michael Newman

I am extremely new to programming, much less Django, but am working my
tail off trying to deploy a student alternative Webzine site.

For the images I have been trying to use the nesh utils,
http://trac.studioquattro.biz/djangoutils/wiki/Thumbnail, because they
look perfect and a friend recommended them to me. I have tried
different methods to install the application and made the changes
talked about here, 
http://groups.google.com/group/nesh-django-utils/browse_thread/thread/5129f1b17267abf5?hl=en
, but am still having problems. I am trying my hardest to break down
the code and figure out what could be going on.

As I was going through the code, I opened a python shell to try to
import the functions. In order I did

from django.conf import settings
from django.core.cache import get_cache

and it raises an 'EnvironmentError: Environment Variable
DJANGO_SETTINGS_MODULE is undefined'. A quick search finds a few code
trac problems and a few fixes regarding this problem but none have
helped.

Do you think I am on the right track? Is this what is causing the
nesh.thumbnail to fail silently?

Thanks for any help feedback, Mn


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---