Re: Tutorial part 3 help: bulleted-list

2016-10-18 Thread Johnny McClung
Thanks so much everyone. I looked over those files many times and I 
couldn't see it. 



On Tuesday, October 18, 2016 at 5:17:55 PM UTC-4, James Schneider wrote:
>
>
>
> On Tue, Oct 18, 2016 at 11:00 AM, Johnny McClung  > wrote:
>
>> I have gotten down to the part where the tutorial reads "Load the page by 
>> pointing your browser at “/polls/”, and you should see a bulleted-list 
>> containing the “What’s up” question from Tutorial 2. The link points to the 
>> question’s detail page."
>>
>> I do not see a bulleted-list. All I see is "No polls are available."
>>
>> This makes me think that I have an error in the if statement in the 
>> template index.html. However, I can not find the error or why it is not 
>> showing me the list. Any help would be appreciated. 
>>
>
> The {% if %} statement is fine. 
>
>  
>
>> mysite>>polls>>templates>>polls>>index.html
>>
>> {% if latest_question_list %}
>> 
>> {% for quesion in latest_question_list %}
>>
>
> You do have a typo in your {% for %} loop, however.
>
>
>
>  
>
>> def index(request):
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = {'latest_quesion_list': latest_question_list,}
>> return HttpResponse(template.render(context, request))
>>
>>
> This is where your issue is. Your template context dictionary also has the 
> same typo as  your  {% for %} loop, so the {% if %} statement is returning 
> False because the variable it is checking (which is spelled correctly) 
> doesn't exist.
>
> -James
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23054cef-e165-48b6-b75d-87c8dd81830b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Tutorial part 3 help: bulleted-list

2016-10-18 Thread Johnny McClung
I have gotten down to the part where the tutorial reads "Load the page by 
pointing your browser at “/polls/”, and you should see a bulleted-list 
containing the “What’s up” question from Tutorial 2. The link points to the 
question’s detail page."

I do not see a bulleted-list. All I see is "No polls are available."

This makes me think that I have an error in the if statement in the 
template index.html. However, I can not find the error or why it is not 
showing me the list. Any help would be appreciated. 

mysite>>polls>>templates>>polls>>index.html

{% if latest_question_list %}

{% for quesion in latest_question_list %}
{{ question.question_text 
}}
{% endfor %}

{% else %}
No polls are available.
{% endif %}


mysite>>polls>>urls.py
from django.conf.urls import url


from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^(?P[0-9]+)/$', views.detail, name='detail'),
url(r'^(?P[0-9]+)/results/$', views.results, 
name='results'),
url(r'^(?P[0-9]+)/vote/$', views.vote, name='vote'),
]


.
mysite>>polls>>views.py
from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse
from django.template import loader

from .models import Question

def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {'latest_quesion_list': latest_question_list,}
return HttpResponse(template.render(context, request))


def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)

def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResonse(response % question_id)

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f0899689-fb34-4728-8ec6-7bfc661c348c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error with Tutorial - Writing your first Django app, part 1

2016-10-10 Thread Johnny McClung
Thank you. I've added the comma as you mentioned. Can't believe I missed 
that. But now I am getting a new error. 



E:\Dropbox\Python Scripts\mysite>python manage.py runserver
Performing system checks...

Unhandled exception in thread started by .wrapper at 0x044B16A8>
Traceback (most recent call last):
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\urls\resolvers.py",
 
line 315, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py",
 
line 226, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py",
 
line 121, in inner_run
self.check(display_num_errors=True)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py",
 
line 374, in check
include_deployment_checks=include_deployment_checks,
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py",
 
line 361, in _run_checks
return checks.run_checks(**kwargs)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\registry.py",
 
line 81, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py",
 
line 14, in check_url_config
return check_resolver(resolver)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py",
 
line 28, in check_resolver
warnings.extend(check_resolver(pattern))
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py",
 
line 24, in check_resolver
for pattern in resolver.url_patterns:
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py",
 
line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\urls\resolvers.py",
 
line 322, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '' 
does not appear to have any patterns in it. If you see valid patterns in 
the file then the issue is probably caused by a circular import.



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c2742620-55fc-4db1-b92a-2dfc392d8903%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error with Tutorial - Writing your first Django app, part 1

2016-10-10 Thread Johnny McClung
I am getting an error when I try to run the Django server. 

>> mysite >> polls >> urls.py
from django.conf.urls import url


from . import views

urlpatters = [
url(r'^$', views.index, name='index'),
]




>> mysite >> mysite >> urls.py
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^polls/', include('polls.urls'))
url(r'^admin/', admin.site.urls),
]



Error:

E:\Dropbox\Python Scripts\mysite>python manage.py runserver
Performing system checks...

Unhandled exception in thread started by .wrapper at 0x03F616A8>
Traceback (most recent call last):
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py",
 
line 226, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py",
 
line 121, in inner_run
self.check(display_num_errors=True)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py",
 
line 374, in check
include_deployment_checks=include_deployment_checks,
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py",
 
line 361, in _run_checks
return checks.run_checks(**kwargs)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\registry.py",
 
line 81, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py",
 
line 14, in check_url_config
return check_resolver(resolver)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py",
 
line 24, in check_resolver
for pattern in resolver.url_patterns:
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py",
 
line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\urls\resolvers.py",
 
line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py",
 
line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\urls\resolvers.py",
 
line 306, in urlconf_module
return import_module(self.urlconf_name)
  File 
"C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
 
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 986, in _gcd_import
  File "", line 969, in _find_and_load
  File "", line 958, in _find_and_load_unlocked
  File "", line 673, in _load_unlocked
  File "", line 661, in exec_module
  File "", line 767, in get_code
  File "", line 727, in source_to_code
  File "", line 222, in 
_call_with_frames_removed
  File "E:\Dropbox\Python Scripts\mysite\mysite\urls.py", line 21
url(r'^admin/', admin.site.urls),
  ^
SyntaxError: invalid syntax


Any help would be appreciated. Thank you. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9a44648b-dfc1-476a-be2f-12b74328e6d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with registration backend

2012-12-05 Thread Johnny Pyhtonic
Thanks for the idea. I followed up on this found that the 
django-registration backend is really only ment for anonymous account 
creation - it will log an athenticated user out upon reaching the page. The 
deal seems to be that in order the create an account, the user must not 
already have an account (must be anonymous). Makes sense for lots of 
situations, just not mine. So how do you make it so that only an 
authenticated user is able to create an account that only an anonymous user 
is allowed to make?

Well, I was able to come up with a little hack whereby anonymous users are 
redirected away from the accounts/registration page, but athenticated users 
will continue toward the page, they're just logged out before they get 
there. It seems to work, however I'm not too happy with it.

My new question is, how to I go about making my own account creation page? 
For instance can I just make a form that gathers all the fileds I want 
(Name, password, etc), build a view and a template? Or is there something 
special that the the django-registration backend is doing that I don't 
realize? That's the part I'm concerned about. Should I inherit from the 
django-registration backend and build on that? Is there a ready made 
solution I don't know about that would allow an authenticated user to 
create accounts?

I feel a bit unsure about how to proceed. Anyone have advice?

Thanks!

On Monday, December 3, 2012 6:10:07 PM UTC-4, Chris Cogdon wrote:
>
> modify the urlconf so that the function to send out registration keys can 
> only be executed if someone is already logged in and/or has the right kind 
> of permission.
>
> eg, instead of
>
>  url(  some-re   some_function )
>
> you can use
>
>  url ( some-re, login_required(some_function) )
>
> or has_perm, or a myriad of other decorators/wrappers.
>
>
>
> On Monday, December 3, 2012 1:40:02 PM UTC-8, Jason Pythonic wrote:
>>
>> Hi All,
>>
>> First time poster here, so apologies if this question has been covered - 
>> believe me, I've searched, but I might be too far off base to know what to 
>> search for.
>>
>> Here's my issue. I'm working on a site that is currently setup to enroll 
>> users via the django-registration user registration backend.
>>
>> User accounts are created by navigating to my_site/accounts/register/, 
>> entering a username, an e-mail address, and a password. Once this form is 
>> filled out, an activatation link is e-mailed to the new user by clicking on 
>> a button. When the user receives this email, they simply follow the link to 
>> activate their account. That all works. The problem I have is that 
>> absolutely anyone can come along and create their own account simply by 
>> going to my_site/accounts/register/ and sending themselves an activation 
>> e-mail. I need a way to ensure that only my website's user is authorized to 
>> create users, and I'm really just not sure of how to go about tackling this.
>>
>> I'd sure appreciate it if someone could provide direction how to do this.
>>
>> Just to summarize, I only want *my *site's user to be allowed to create 
>> new users. How do I accomplish this?
>>
>>
>> Thanks,
>> Jason
>>
>

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



Re: Django 1.3 CSRF faild when upgraded from Django 1.2.5

2011-05-10 Thread _ johnny .
Try add RequestContext in render_to_response()

from django.template import RequestContext

return render_to_response('account/login.html',
> locals(), context_instance=RequestContext(request))


On Tue, May 10, 2011 at 10:10 AM, 阮明辉  wrote:

> return render_to_response('account/login.html')
>

-- 
You received this message because you are subscribed to the Google 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: Re: DjangoCon 2011

2010-09-28 Thread Rev. Johnny Healey
It seems like no one has suggested New Orleans yet, so I'm just going
to toss that out there.

-Johnny

On Tue, Sep 28, 2010 at 7:31 AM, Franklin Einspruch
 wrote:
> You might also have a look at Providence, RI. There's an airport, it's
> an hour from Boston by car, and they have an active tech community
> there:
>
> http://rinexus.com/
> http://providencegeeks.org/
> http://www.pbn.com/Schillings-38-Studios-signs-lease-at-One-Empire-Plaza,52603
>
> Good restaurants abound and entertainment options are at least extant
> if not quite as rich as Portland, OR. Venues are likely to be far
> cheaper than Boston.
>
> - Franklin
>
> On Tue, Sep 28, 2010 at 7:11 AM, Steve Holden  wrote:
>> On 9/28/2010 1:19 AM, Kenneth Gonsalves wrote:
>>> On Mon, 2010-09-27 at 22:51 -0400, Steve Holden wrote:
>>>> I'd just like to briefly report back on the inquiries Nancy and I have
>>>> been making into East coast venues for DjangoCon 2011.
>>>
>>> just curious - why a hotel? In India we hold such conferences in
>>> universities/colleges - they provide all facilities free of cost (except
>>> accomodation - although some make their guest houses available for the
>>> VIPs), and in fact, compete with each other to offer hosting. We have
>>> just finished Pycon India where we got three state of art auditoriums
>>> free of cost.
>>
>> The choice of venue was made in advance for this year - effectively we
>> took over an existing contract. This is the first time anyone has
>> suggested a non-hotel venue.
>>
>> I haven't really heard much support for a university venue from the
>> community at large. They have both advantages and disadvantages. Of
>> course PyCon used a university location for the first three years. After
>> we outgrew the original location the conference's size made it difficult
>> to find university locations large enough (according to the people who
>> made the choices - I only chaired for three years).
>>
>> It would be best not to cast the net too wide, given that a year ahead
>> is a relatively short planning time frame for a conference of this size.
>>
>> regards
>>  Steve
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
>
> --
> Art, writing, journal: http://einspruch.com
> Comics: http://themoonfellonme.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: question about the "default" Manager

2010-09-15 Thread Rev. Johnny Healey
Ahh, clever.

Thanks,
Johnny

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



question about the "default" Manager

2010-09-15 Thread Rev. Johnny Healey
According to the django docs: "If you use custom Manager objects, take
note that the first Manager Django encounters (in the order in which
they're defined in the model) has a special status. Django interprets
the first Manager defined in a class as the "default" Manager, and
several parts of Django (including dumpdata) will use that Manager
exclusively for that model."

I may be missing something here, but this jumps out at me as being
impossible.  The ModelBase metaclass receive the attributes as a dict,
so isn't the original order lost?

-Rev. Johnny Healey

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



Form info about records numbering not updated and not working

2010-07-22 Thread Johnny
Dear All,

I'm using a Django application and within quite all forms I have on
the botton side some info about records present for that form/table
yet inserted.

Something like : "1,2,3,4,..3254 pages"  and total "nr of records
es. 5317"

I did a massive upload of mySQL database directly adding about 10.000
records.

Later, If I come back to front end forms I can't  see any update to
records info on the bottom of forms. So I still see .. 3254 and 5317.

If I go to last record on last page es. # 5317 I can edit it and then
if I use "next record" button I can navigate on "newly" mySQL added
record .
So they exist but I can see the form record info corectly.

Is there a table that control this kind of updating ? What can be the
solution for that problem ?
Is it possible to understand wich is the program used there ?
Many thanks for each suggestion
Johnny

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



Re: Noon Help

2008-10-28 Thread Johnny Utah

Thanks a lot Peter and Jeff.  Your posts have definitely pointed me in
the right direction.

I'll see what I come up with.  If its anything functional, I'll be
sure to give you guys the link. :)

Also, if anybody wants to contribute code - I need all the help I can
get! (and I might have some code questions later)

Thanks again guys.



On Oct 27, 12:01 pm, "Peter Herndon" <[EMAIL PROTECTED]> wrote:
> I might also suggest django-registration
> (http://code.google.com/p/django-registration) to handle your user
> registration needs.
>
> On Mon, Oct 27, 2008 at 2:34 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> > Johnny Utah wrote:
> >> Thanks for the input.
>
> >> When you say Django.admin would be useful, do you mean users would
> >> access the admin interface?
>
> > Please respond to the list when asking further questions.
>
> > That being said: no-- users shouldn't access the admin interface. Admins
> > should. It's there to make your life much easier, and it does that very
> > well. You'll still need to build views for your app, but if you need to
> > go in and change something manually, the admin interface is way better
> > than dropping to SQL.
>
> > Jeff Anderson
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Noon Help

2008-10-26 Thread Johnny Utah

Hi Guys,

If I'm posting this on the wrong site, my apologies.

I'm a beginner to both Python and Django and I would like to develop a
public site.  I'm not looking for help with code as much as with what
modules I will need (e.g. django.contrib.auth).  Any help is greatly
appreciated!

The site:

An inventory system for reptile owners.  A user creates an account.
Once the user is able to login, they can add a reptile.  Once they
have added a reptile, they can add dated entries for feedings,
sheddings, cage cleanings, etc.

Thoughts?


Thanks!

Johnny

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



Using Javascript

2008-10-08 Thread Johnny
Hi everyone,

I'm writting a Web App using Django and I got problems to make appear or
deasappear some content.

Here is the code I was using to write a part of the windows:


  

  
  
Episode
Name
Season
Date
  

  {% for episode in episodes %}

{{ episode.number }} 
{{ episode.title }} 
{{ episode.season }} 
   {% if episode.date %}
 {{ episode.date }} 
   {% endif %}
   
 {% endfor %}
  

   


It works well but now I wan't the window to be empty when opening itself,
then get this content when I clic on a button
So I use a javascript function looking like:




function fill_area(tabl)
 {

  document.getElementById('area').innerHTML =
'EpisodeNameSeasonDate';


  document.getElementById('area').innerHTML += '';
}



Here is half the code. It works, but i can't use variables in it because
Javascript doesn't recognize them.
I've tried to pass the "episodes" object when calling the fill_area()
function but doesn't work either.



Someone's got an idea?

Thank You.

John

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

2008-10-05 Thread johnny

Ok, for example, I can pass in
Modelname.objects.select_related().all() for the queryset, obj's_Id
for the object_id.  And the 'object' in the generic view will actually
be calling a .get(id=obj's_Id) on that lazy, select_related queryset?
thanks for the reply,
Johnny

On Oct 5, 3:18 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-10-05 at 03:32 -0700, johnny wrote:
> > Hi,
> >   I'm wondering if select_related() is used for the object_detail
> > generic view.  If not, shouldn't it be since it's more efficient?
> > Also, is select_related only useful on a .get() method?
>
> It's entirely up to you, when creating your queryset, whether to use
> select_related() or not. It is certainly not something anything like a
> generic view should always put in place, since it can impact performance
> in a negative way if you aren't using all the related fields it
> retrieves (which can be a lot if your model has lots of linkages to
> other models or itself).
>
> select_related() can be used on any queryset, not just when using a
> get() call.
>
> 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
-~--~~~~--~~--~--~---



select_related()

2008-10-05 Thread johnny

Hi,
  I'm wondering if select_related() is used for the object_detail
generic view.  If not, shouldn't it be since it's more efficient?
Also, is select_related only useful on a .get() method?
thanks.
Johnny
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Ticket #5737: "CheckboxSelectMultiple when you use choices, required=False is not respected" reappearing?

2008-10-02 Thread johnny

I found the same problem as ticket #5737.  It was closed due to unable
to reproduce it, but I am seeing the same problem.

I have:
class QueryForm(f.Form):
status   = f.ChoiceField(choices=STATUS_TYPES,
widget=f.CheckboxSelectMultiple(), required=False)

and the form validation errored:

status
* Select a valid choice. [] is not one of the available choices.

html source:
statusSelect a
valid choice. [] is not one of the available choices.



Ticket #5737 (closed: invalid)
CheckboxSelectMultiple when you use choices, required=False is not
respected
http://code.djangoproject.com/ticket/5737


can someone confirm?
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: blank vs. exclude

2008-09-29 Thread johnny

yes, that's it!  My exclude was not under class Meta, but along with
the rest of the fields instead, my bad.
thanks!

On Sep 28, 11:06 pm, Gerard Petersen <[EMAIL PROTECTED]> wrote:
> John,
>
> Looking at your exclude syntax, that might be the problem. This would be the 
> correct code (assuming modelform is used):
>
> class OrderForm(ModelForm):
>     class Meta:
>         model = Order
>         exclude = ['number', 'state', 'state_since']
>
> nb: The excluded fields have no null/blank/editable options set in the model 
> itself.
>
> Regards,
>
> Gerard.
>
>
>
> johnny wrote:
> > I have a question about the exclude property in ModelForm.  When I
> > have a Model and the ModelForm for it excludes a field from that
> > Model, shouldn't the ModelForm validation excludes that field as well?
>
> > It seems the only way to exclude the field from validation is to make
> > it blank=True in the Model.  However,
> > to me, the blank=True/False on Model seems to be in the wrong place.
> > The model is suppose to define the model, and blank defines the form
> > validation, so I don't believe it's in the right place and thus like
> > not to set it there and like to use exclude=('field1', etc.) instead
> > in the ModelForm level.  But that doesn't seem to work and complain
> > that the excluded fields are required..
>
> > An example of this is a timestamp.  The model defines a timestamp
> > field but the ModelForm for it should exclude the field since it needs
> > to be auto-generated.  When the field is excluded from the ModelForm,
> > it should be excluded from the form validation as well, but it doesn't
> > and requires me to set blank=True in the Model instead, which again
> > seems wrong to me since the Model should have nothing to do with form
> > validation.
>
> > thoughts?
> > john
>
> --
> urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl'}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



blank vs. exclude

2008-09-28 Thread johnny

I have a question about the exclude property in ModelForm.  When I
have a Model and the ModelForm for it excludes a field from that
Model, shouldn't the ModelForm validation excludes that field as well?

It seems the only way to exclude the field from validation is to make
it blank=True in the Model.  However,
to me, the blank=True/False on Model seems to be in the wrong place.
The model is suppose to define the model, and blank defines the form
validation, so I don't believe it's in the right place and thus like
not to set it there and like to use exclude=('field1', etc.) instead
in the ModelForm level.  But that doesn't seem to work and complain
that the excluded fields are required..

An example of this is a timestamp.  The model defines a timestamp
field but the ModelForm for it should exclude the field since it needs
to be auto-generated.  When the field is excluded from the ModelForm,
it should be excluded from the form validation as well, but it doesn't
and requires me to set blank=True in the Model instead, which again
seems wrong to me since the Model should have nothing to do with form
validation.

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



Nice representation for Querying with ForeignKeys

2008-08-27 Thread johnny

Hi,
  This should be a simple question but I just couldn't seem to find
the answer.  I have a simple 2 model relationship:

class B(models.Model):
bfield = models.CharField(...)

class A(models.Model):
afield = models.CharField(...)
bfieldFK  = models.ForeignKey(B)

what is the best way to query for example A.objects.filter(pk=1) such
that the representation is something like:
[{'id':1, 'afield':'a', 'bfield':'b'}]

and not:
[{'id':1, 'afield':'a', 'bfieldFK_id':2}]  # eg. using .values()

the objective is to serialize it (if it makes a difference), but the
key idea is to have the output fields represented as if B were never a
separate model.

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



Nice representation for Querying with ForeignKeys

2008-08-27 Thread johnny

Hi,
  This should be a simple question but I just couldn't seem to find
the answer.  I have a simple 2 model relationship:

class B(models.Model):
bfield = models.CharField(...)

class A(models.Model):
afield = models.CharField(...)
modelB  = models.ForeignKey(B)

what is the best way to query for example A.objects.filter(pk=1) such
that the representation is something like:
[{'id':1, 'afield':'a', 'bfield':'b'}]

and not:
[{'id':1, 'afield':'a', 'bfield_id':2}]  # eg. using .values()

the objective is to serialize it (if it makes a difference), but the
key idea is to have the output fields represented as if B were never a
separate model.

thank you so much,
Johnny


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



Form Field Question from python noob

2007-11-14 Thread johnny

I have seen forms without the "self" in front of the fields, eg. more
like this date_from = forms.DateField() and never self.date_form
=forms.DateField().  If you include self.date_form, then date_form
becomes an attribute of an instance rather than a attribute of a
class.

What confusing me is that, when you define form field without self,
like date_from = forms.DateField() , then are you creating only one
date_from field as in java static class or java static variable?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: two block template tags on after another

2007-10-21 Thread johnny

Thank you, Karen and Marty for the help.  It made lot of difference.

john


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: two block template tags on after another

2007-10-19 Thread johnny

What I need to do is, get the records from the database and split
fields contents.  One of the field, has commas separated contents and
another field has - separated fields.  In my view, I just do fetchall
of database records and send to view.  From the view, I do a for loop
to go through each records, and split two of the fields contents that
have - and , separated values.

I have got it to work now.  I think splitting the field records
contents by template tags is the best solution.  Correct me if I am
wrong.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: two block template tags on after another

2007-10-19 Thread johnny

I am looking at this documentation:
http://www.djangoproject.com/documentation/templates_python/#parsing-until-another-block-tag-and-saving-contents

It has the following code:
output = self.nodelist.render(context)
return output.upper()

upper() in output.upper(), I am assuming is the name of the template
tag.  When I try to do it as in this example, I get an error:

Exception Type: AttributeError
Exception Value:'unicode' object has no attribute
'custom_format_string1'

If I comment out #return output.custom_format_string2() and just do it
like this, it works:

#return output.custom_format_string1()
return output

I didn't understand the output.upper() part.  I think the
documentation above is written for people who already know how the
template tag works, it doesn't do any good for beginners.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: two block template tags on after another

2007-10-19 Thread johnny

There is a problem with default django for loop tag {% for  %} {%
endfor%} .  Django template doesn't seem to like nested block tag
inside for loop tag.

{% for a_object in object_list %}
{% load custom_format %}
{% custom_format_string1 a_object.3 %}
{{split_string_data1}}
{% end_custom_format_string1 %)

{% custom_format_string2 a_object.4 %}
{{split_string_data2}}
{% end_custom_format_string2 %)
{% endfor %}

Does it mean I have to overwrite the way django template for loop tag
works?

Django Error:
Exception Type: TemplateSyntaxError
Exception Value:Invalid block tag: 'endfor'


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: two block template tags on after another

2007-10-19 Thread johnny

Can someone help me, plz?

I have two block tags that take an argument and then sets a variable
in the template.  The two block tags are inside the template "for
loop" tags, one after another.

On Oct 18, 3:00 pm, johnny <[EMAIL PROTECTED]> wrote:
> I have  templatetags/custom_format.py, and in it I have
> do_custom_format_string1, do_custom_format_string2.  I placed the
> template tags
> one after another, insdie my html page like this:
>
> {% for a_object in object_list %}
> {% load custom_format %}
> {% custom_format_string1 a_object.3 %}
> {{split_string_data1}}
> {% end_custom_format_string1 %)
>
> {% custom_format_string2 a_object.4 %}
> {{split_string_data2}}
> {% end_custom_format_string2 %)
> {% endfor %}
>
> custom_format.py:
>
> from django import template
> #from django.template import Variable
> from django.template import resolve_variable
> register = template.Library()
>
> @register.tag(name="custom_format_sting1")
> def do_custom_format_sting1(parser, token):
> nodelist = parser.parse(('end_custom_format_sting1',))
> tag_name, data_to_split = token.split_contents()
> parser.delete_first_token()
> return CustomFormatString1Node(nodelist, data_to_split)
>
> class CustomFormatString1Node(template.Node):
> def __init__(self, nodelist, data_to_split):
> self.nodelist = nodelist
> self.data_to_split = data_to_split
> def render(self, context):
> actual_data = resolve_variable(self.data_to_split, context)
> datalist = actual_data.split(',')
> context['split_string_data1'] = "".join(datalist)
> output = self.nodelist.render(context)
> return output.custom_format_sting1()
>
> @register.tag(name="custom_format_sting2")
> def do_custom_format_sting2(parser, token):
> nodelist = parser.parse(('end_custom_format_sting2',))
> tag_name, data_to_split = token.split_contents()
> parser.delete_first_token()
> return CustomFormatString2Node(nodelist, data_to_split)
>
> class CustomFormatString2Node(template.Node):
> def __init__(self, nodelist, data_to_split):
> self.nodelist = nodelist
> self.data_to_split = data_to_split
> def render(self, context):
> actual_data = resolve_variable(self.data_to_split, context)
> datalist = actual_data.split('-')
> context['split_string_data2'] = "".join(datalist)
> output = self.nodelist.render(context)
> return output.custom_format_sting2()
>
> Error I am getting:
>
> Exception Type: TemplateSyntaxError
> Exception Value:Invalid block tag: 'custom_format_string1'
>
> error at html file:
> {% custom_format_string1 a_object.3 %}


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



two block template tags on after another

2007-10-18 Thread johnny

I have  templatetags/custom_format.py, and in it I have
do_custom_format_string1, do_custom_format_string2.  I placed the
template tags
one after another, insdie my html page like this:

{% for a_object in object_list %}
{% load custom_format %}
{% custom_format_string1 a_object.3 %}
{{split_string_data1}}
{% end_custom_format_string1 %)


{% custom_format_string2 a_object.4 %}
{{split_string_data2}}
{% end_custom_format_string2 %)
{% endfor %}

custom_format.py:

from django import template
#from django.template import Variable
from django.template import resolve_variable
register = template.Library()

@register.tag(name="custom_format_sting1")
def do_custom_format_sting1(parser, token):
nodelist = parser.parse(('end_custom_format_sting1',))
tag_name, data_to_split = token.split_contents()
parser.delete_first_token()
return CustomFormatString1Node(nodelist, data_to_split)

class CustomFormatString1Node(template.Node):
def __init__(self, nodelist, data_to_split):
self.nodelist = nodelist
self.data_to_split = data_to_split
def render(self, context):
actual_data = resolve_variable(self.data_to_split, context)
datalist = actual_data.split(',')
context['split_string_data1'] = "".join(datalist)
output = self.nodelist.render(context)
return output.custom_format_sting1()

@register.tag(name="custom_format_sting2")
def do_custom_format_sting2(parser, token):
nodelist = parser.parse(('end_custom_format_sting2',))
tag_name, data_to_split = token.split_contents()
parser.delete_first_token()
return CustomFormatString2Node(nodelist, data_to_split)

class CustomFormatString2Node(template.Node):
def __init__(self, nodelist, data_to_split):
self.nodelist = nodelist
self.data_to_split = data_to_split
def render(self, context):
actual_data = resolve_variable(self.data_to_split, context)
datalist = actual_data.split('-')
context['split_string_data2'] = "".join(datalist)
output = self.nodelist.render(context)
return output.custom_format_sting2()



Error I am getting:

Exception Type: TemplateSyntaxError
Exception Value:Invalid block tag: 'custom_format_string1'

error at html file:
{% custom_format_string1 a_object.3 %}


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



template and array like template variable access

2007-10-17 Thread johnny


{% for a_tup in rs %}

{{ a_tup[0] }}/
 {{ a_tup[1]

{% endfor %}

Exception Type: TemplateSyntaxError
Exception Value:Could not parse the remainder: '[0]' from 'a_tup[0]'

Only way to do this is to have nested for loop inside template?


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



newform: Why Doesn't This work

2007-10-16 Thread johnny

Below  is my form class.  Inside myForm, I tried doing this:

choice = forms.ChoiceField(label="My choice",
   choices=myChoice(self.q_prime).choices())

I get an error right here "choices=myChoice(self.q_prime).choices()":
name 'self' is not defined

My Form Class:

class myChoice:
def __init__(self, q_prime):
_choice = []
#_choice.append(q_prime)

def choices():
_choice.append("yellow")
_choice.append("red")

return _choice

class myForm(forms.Form):
def __init__(self, *args, **kwargs):
try:
self.q_prime = kwargs.pop('q')
except:
pass
super(myForm, self).__init__(*args, **kwargs)

choice = forms.ChoiceField(label="My choice",
   choices=myChoice(self.q_prime).choices()) #I
get an error right here: name 'self' is not defined


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

2007-10-15 Thread johnny

Is there a way to run python code in the template?  In view, I just
fetchall from database and pass it to the template  But I found out I
need to break up the content in one of the field.  As each records are
looped inside the template, I need to break up a field and display 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: django debugging eclipse watch variable problem

2007-10-13 Thread johnny

Has anyone able to watch variable in debug mode of eclipse?

If so, what your project folder structure.  I just have:

c:\django\mysite

mysite folder contains: apps (contains directories of different apps),
manage.py, settings.py, src folder is empty.

I have added

Inside Eclipse :
Window menu > Preferences...
Pydev > Interpreter - Python
System PYTHONPATH > New Folder
Folder : c:\django\mysite

using eclipse with watch variable would make life easier ;)


On Oct 12, 11:04 am, johnny <[EMAIL PROTECTED]> wrote:
> I am trying to watch a variable in my app.  Setup is fine.  I can run
> manage.py runserver inside eclipse and view debug window and place
> break points.  But can't seem to watch the variable values.
>
> I am getting following error:
>
> could not resolve variable
>
> Here is the 
> pic:http://farm3.static.flickr.com/2125/1552069173_49fcc78826_o.png


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



django debugging eclipse watch variable problem

2007-10-12 Thread johnny

I am trying to watch a variable in my app.  Setup is fine.  I can run
manage.py runserver inside eclipse and view debug window and place
break points.  But can't seem to watch the variable values.

I am getting following error:

could not resolve variable

Here is the pic:
http://farm3.static.flickr.com/2125/1552069173_49fcc78826_o.png


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



pagination documentation unclear

2007-10-11 Thread johnny

I was going over documentation on pagination and it mentions you can
do it in two ways as follows:

URL... ?page=x
or
(r'^objects/page(?P[0-9]+)/$', 'object_list', dict(info_dict))

My question is, you would use

"URL... ?page=x" for regular views?

"(r'^objects/page(?P[0-9]+)/$', 'object_list', dict(info_dict))"
for generic views?

object_list is the function in django.views.generic.list_detail ?

What is dict(info_dict) do?

what is objects in "(r'^objects/page(?P[0-9]+)/$'", model name?


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



template base.html block-template-tag above

2007-10-09 Thread johnny

In django template, can you have (% block somename %} above root html
element of a document, like here?

my base.html
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>

{% block html %}
http://www.w3.org/1999/xhtml";>





{% endblock %}


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



Re: fixtures (yaml)

2007-09-28 Thread johnny

Does this command dump the whole app models or can you specify a
specific model?

./manage.py dumpdata --format=yaml yourAppNameHere,  command seems to
print on the screen.  How do you specify to dump it to a file?


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



Re: fixtures: Invalid model identifier

2007-09-19 Thread johnny

FIX: "model": "category.Category",

NOT this: "model": "apps.category.models.Category",





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: fixtures: yaml, manage.py syncdb error when no data in initial_data.yml

2007-09-19 Thread johnny

this error is due to auto incremented primary key.  you can't have
empty fixture file.


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



fixtures: Invalid model identifier

2007-09-19 Thread johnny

from django.db import models
from django.contrib.auth.models import User

class Category(models.Model):
id = models.AutoField(primary_key=True)
parent_id = models.IntegerField()
name = models.CharField(maxlength=200)


Problem installing fixture 'c:\mysite\apps\category\fixtures
\initial_data.yaml': Invalid model identifier:
'apps.category.models.Category'

initial_data.yaml
[{
"pk": "1",
"model": "apps.category.models.Category",
"fields": {
   "name": "Test"}
   }]

I am not sure why I am getting "Invalid model identifier".  Also in
yaml fixtures why you have to put quotes(""), [], {}.  Why not just,
less typing:

Tablename:
Fields:
  attribure: value


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



fixtures: yaml, manage.py syncdb error when no data in initial_data.yml

2007-09-19 Thread johnny

class Category(models.Model):
id = models.AutoField(primary_key=True)
parent_id = models.IntegerField()
name = models.CharField(maxlength=200)

Problem installing fixture 'c:\mysite\apps\category\fixtures
\initial_data.yaml': 'NoneType' object has no attribute 'anchor'

What is the issue here?  I can't have a empty fixture file?


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



"online/offline status" on user profile

2007-09-16 Thread johnny

What I want to do is display "online/offline status" on user profile?

anybody have an idea how to get information about user is logged
in(active session) or not?


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

2007-09-11 Thread johnny

I can someone tell me how the database connection is handled for
threads.  Do I have to pass conneciton object to each threads?

All I am doing is this:

@threadpool(pool)
def process(i):
print 'threadpool %i enter' % i

p = Profile.objects.get(id=i)
p.status ="sent"
p.save()

print 'threadpool %i exit' % i

Threads does save modified Profile object to the database, but after
saving it, threads just stays there.  Threads seem like they are
waiting for something. It doesn't do "print threadpool exit".


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



django database access with threadpool

2007-09-11 Thread johnny

I am implementing a backend python script that updates the database.
It uses threadpool(http://snippets.dzone.com/posts/show/4425#related).
Threadpool size is 3.  When records are returned, eg. 10 records, 3
threads are created, then the threads update the database, but doesn't
seem to do
task_done().  Three threads that were created initially, just hangs.
I am running FC7 with python2.5.

class ProfileManager(models.Manager):
def not_confirmed():

c = connection.cursor()
c.execute("select * from profile_profile where status
='waiting confirmation'")
return c.fetchall()

backend_threaded.py:

#! /usr/bin/env python
from apps.utils.threadpool import *
#Pyhton ThreadPool: http://snippets.dzone.com/posts/show/4425#related
from time import sleep
import datetime

from os import environ
environ['DJANGO_SETTINGS_MODULE'] = "settings"
from settings import *
from apps.profile.models import *

pool = Pool(3)

@threadpool(pool)
def process(i):
print 'threadpool %i enter' % i

p = Profile.objects.get(id=i)
p.status ="sent"
p.save()

print 'threadpool %i exit' % i

def main():

rs = Profile.objects.not_confirmed()
print rs
for l in rs:
process(l[0])
pool.join()

if __name__=="__main__":
main()


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

2007-09-11 Thread johnny

Only works when I put my actual project folder (/home/bobby/dev/
workspace/mysite) into to the $PYTHONPATH and $PATH.  All my django
code, I never do:

from mysite.apps.whatever import

just:

from apps.whatever import

So in this case, I guess you have to put in the project folder into
the $PYTHONPATH and $PATH, not just the parent folder (/home/bobby/dev/
workspace) where all other django projects reside.


# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

export PATH=$PATH:/home/bobby/dev/workspace:/home/bobby/dev/workspace/
mysite
export PYTHONPATH=$PYTHONPATH:/home/bobby/dev/workspace:/home/bobby/
dev/workspace/mysite
export DJANGO_PROJECT='something'
export DJANGO_DB_NAME='something'
export DJANGO_DB_USER='something'
export DJANGO_DB_PASS='something'
export DJANGO_SECRET_KEY='something'
export DJANGO_SETTINGS_MODULE='mysite.settings'

# User specific aliases and functions



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



Linux django_settings_module problem

2007-09-10 Thread johnny

Trying to run standalone python script that uses django orm.
Something wrong with path setup to execute this python script.

Also, what is the purpose of setting
$DJANGO_SETTINGS_MODULE=mysite.settings?  I think this is where the
problem is.

/home/bobby/dev/workspace has folder: mysite, django_src

[EMAIL PROTECTED] test]$ python test_threaded.py
Traceback (most recent call last):
  File "ending_threaded.py", line 2, in 
from apps.utils.threadpool import *
ImportError: No module named apps.utils.threadpool

[EMAIL PROTECTED] test]$ echo $PYTHONPATH
:/home/bobby/dev/workspace

[EMAIL PROTECTED] test]$ echo $DJANGO_SETTINGS_MODULE
mysite.settings

.bashrc:
export PATH=$PATH:/home/bobby/dev/workspace

>>> import sys
>>> print sys.path
['', '/usr/lib/python2.5/site-packages/Pyro-3.7-py2.5.egg', '/usr/lib/
python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg', '/
usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-
linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-
dynload', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-
packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/
python2.5/site-packages/gtk-2.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: Custom_SQL_Method in a Model

2007-09-09 Thread johnny

you create class called PersonManager(models.Manager) and define
my_custom_sql inside there.  Do you place this class in the same
models.py or in a separate file called apps/people/manager.py and then
import it where ever you need it?  What is the best practice?


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

2007-09-09 Thread johnny

I need to define custom sql for a model, so it is only accessible by
model class but not by model instances.
Where do I define is my_custom_sql, like below, inside the Person
class (my guess is not, if need to access my_custom_sql, then I need
to instantiate Person.):

class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)

def my_custom_sql(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
row = cursor.fetchone()
return row


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



Objects.filter only on minutes range

2007-09-09 Thread johnny

If I use a filter, how do retrieve pub_date falls between certain
minutes (0 <= pub_date_minutes < 20 minutes, 20minutes <=
pub_date_minutes  < 40 minutes, so on)


I looked at an example on django site:
Entry.objects.filter(
headline__startswith='What').exclude(
pub_date__gte=datetime.now()).filter(
pub_date__gte=datetime(2005, 1, 1))

What I need to do this, I need to select only records that fall
between including 0-minutes and less than 20 minutes:
pud_date_minutes between (0-20)

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



from settings import *, non-django python script Error

2007-07-24 Thread johnny

import re
from BeautifulSoup import BeautifulSoup
import urllib2
from os import environ
#from settings import *

def myfunction() :

environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
from settings import *

I get an error:
myscript.py:22: SyntaxWarning: import * only allowed at module level.

I have tried placing "from settings import *" above the "def
myfunction()", then I get an error:
raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path?
Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'mysite.settings' (Is it
on sys.path
? Does it have syntax errors?): No module named mysite.settings

If I don't do import *, what do I need to import in order to use
django model in a python script?
Import only the followings:

DATABASE_ENGINE
DATABASE_NAME
DATABASE_USER
DATABASE_PASSWORD
DATABASE_HOST
DATABASE_PORT  ?


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



Query Object and comparing only partial TimeField Value

2007-07-08 Thread johnny

What I want to do is get post between 9:00AM-5:00PM on any day.  I
just want to compare Hour part of "created_at" field.  If the hour is
between 9-5, can be any day, get the matching records.

Pseudo Django Python Code:

Post.objects.get( Q(created_at = (9:00AM - 5:00PM)))

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



Anyone running Django and MySQL Cluster

2007-07-06 Thread johnny

Is it even possible to run Django and MySQL Cluster or I have to write
some patch to django for it to work (I am not a python or Django
guru.)?


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



newb: Model DateTimeField and Timedelta

2007-07-03 Thread johnny

My model named: Post

It has a field created_at as:
created_at = models.DateTimeField(auto_now_add = True)

Would Post.created_at be of string or datetime ?

I want to add 2 weeks to it, like Post.created_at + 14 days.  Can I do
this?
Post.created_at =Post.created_at + datetime.timedelta(weeks=2)


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



RENDER_TO_RESPONSE and PRETTY ROUTING URL

2007-06-19 Thread johnny

When I use render_to_response, can I have routing url in it like '/
posts/all/' or
I have to have '/posts/all.html''?

My small code:
# I am passing list of objects called 'posts' to template
return render_to_response('/posts/all/', {'posts': posts})

In my browser, I want to have pretty url like "mysite/posts/all/" not
"mysite/posts/all.html".

thnx.


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



Q Objects: Can you do this?

2007-06-18 Thread johnny

Can you do this?

citylist = CityList.objects.get(
Q(city="%s" % (line[3])),
Q(state=slist.id)
)

I am getting the following error:

citylist = CityList.objects.get(
NameError: name 'Q' is not defined


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Django Models outside of Django

2007-05-15 Thread johnny

Doing the following:

from os import environ
environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from settings import *

Only works at the parent folder level.  What if you have script in sub
folder level?  I tried it at sub folder level and got error:

from os import environ
environ['DJANGO_SETTINGS_MODULE'] = '../settings'
from settings import *
>>> from apps.mail.models import Email
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named apps.mail.models
>>>


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Django Models outside of Django

2007-05-08 Thread johnny

Since I have my code in threaded manner, do I have to put the
following code inside threaded function or outside?

from os import environ
environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from settings import *


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



Using Django Models outside of Django

2007-05-07 Thread johnny

I have a python script that runs in a multi threaded manner for
backend to update certain flags in the table.  I want to use django
models to do this.  I was wondering if I import the django models just
like any other python, would that work?

Also, what about the database connection, can I just create a database
connection inside the python script and use Django Models?

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



Invalid Login and Throwing Captcha

2007-04-27 Thread johnny

I want to throw captcha, when the user failed to login, after 2nd
try.  How do I keep track of how many times login fails?  Set a cookie
with login attempt?

Thank you.


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



Re: Passing Django Model objects between machines

2007-04-17 Thread johnny

Following dose it.

pickle.dumps(someObject)
pickle.loads(someObject)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Passing Django Model objects between machines

2007-04-17 Thread johnny

To do pickling, do you always have to create a file and send it over
the network to the other machine?  Rather than creating a pickled
file, can you create string?

Thank you.


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



Passing Django Model objects between machines

2007-04-17 Thread johnny

Anyone know, how I can pass Model object from one machine that runs
Django, to another machine that doesn't have Django, but uses
python?

Thank you.


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



Re: Django Manage.py Error After Fresh Linux Install

2007-04-16 Thread johnny

I fixed it.  Symbolic link wasn't pointing to the right directory.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Manage.py Error After Fresh Linux Install

2007-04-16 Thread johnny

I created a link in python/site-packages/django that actually points
to the /home/me/django_src/django.  I copied my project from windows
into linux.  I will delete *.pyc files and try 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
-~--~~~~--~~--~--~---



Django Manage.py Error After Fresh Linux Install

2007-04-16 Thread johnny

I am not sure how to fix this.  I reinstalled linux and now manage.py
has an import problem.  Does this mean I have to add django to $PATH?

My ERROR:

[EMAIL PROTECTED] mysite]$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 2, in ?
from django.core.management import execute_manager
ImportError: No module named django.core.management

Thank you.


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



Re: newb: Sending Request to Django Dev Server, From Python Terminal

2007-04-10 Thread johnny

urllib2 module is the one I need.  Thank you.


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



Django Set HTTP Error manually

2007-04-09 Thread johnny

What I want to do is set HTTP Error manually in my view, when a
request is made to certain url, without post data.

At a particular url, my view is looking for XML document to be sent
over http, by post.  If a request come in without post, I want to
raise an error "405 Method Not Allowed".  How do I do this?

Thank you


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



Re: newb: Sending Request to Django Dev Server, From Python Terminal

2007-04-09 Thread johnny

> why don't you just use a browser?

I need to construct and load xml data from python shell and send it to
the dev server.  I don't think you can do this in the browser.

Thank you.


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



newb: Sending Request to Django Dev Server, From Python Terminal

2007-04-09 Thread johnny

How do you send a request to localhost djanog dev server from Python
Terminal?
I have started mysql and python dev server locally on my machine.
Now, I want to open
python terminal send a request, to 127.0.0.1:8000/putProduct.

Thank you.


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



Re: Recieving XML Documents over HTTP

2007-04-08 Thread johnny

I just need to know how to get the xml document coming in over http.
Is it just regular request.Post?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Recieving XML Documents over HTTP

2007-04-08 Thread johnny

This is what I need to do:

Site will be recieving, orders from retailers ( which comes in as a
xml with list of products), what products are required, quantity and
such by them, and I need to process the xml and update the main
company database.

Thank you.


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



Re: New contribution announcement: RESTful model views.

2007-04-07 Thread johnny

I am python newb.  But I came across this thread.  It sound like
someone has attempted it and it's in google source.
http://groups.google.com/group/django-users/browse_thread/thread/2f2840572fc99fc3/e045e3ef43b2a607?lnk=gst&q=raw_post_data&rnum=2#


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Recieving XML Documents over HTTP

2007-04-07 Thread johnny

I am doing REST, xml over http (sending and receiving xml documents),
which is simpler for me than XML-RPC.  I am having problem with
receiving xml documents.


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



Recieving XML Documents over HTTP

2007-04-06 Thread johnny

This may be stupid question for an expert.  But stupidity is in not
asking.

How do I access the XML Documents sent over to my server in Django
View?  Is it like regular request.POST?
How large POST data can be sent before connection timing out?

Thank you.


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



Django View and Sending XML over HTTP

2007-04-05 Thread johnny

This is simple question.  When you send xml over http, do you just
pass string varible containing the xml document, as a variable to the
template?

Thank you.


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



Re: newb: Lxml Objectify

2007-03-31 Thread johnny

I am trying to do this inside Django view.  I am new to python, I
thought someone might have used lxml to process and create xml
documents in Django.  I looked at the documentation, but for newb, I
need to see an examle like this.

Thank you.


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



newb: Lxml Objectify

2007-03-30 Thread johnny



Breakfast at Tiffany's
Movie
Classic



Borat
Movie
Comedy



How do you represent DVD id=1 and it's elements, and DVD id=2 and it's
elements as child of root "Library"?
Like this:?

from lxml import etree
from lxml import objectify

root = objectify.Element("Library")
child[1] = objectify.Element("DVD", id="1")
root.new_child = child[1]

Thank you


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



Re: Django and Routing SUBDOMAIN STYLE URL

2007-03-25 Thread johnny

I have tried:

http://api.localhost:8000/
http://api.127.0.0.1:8000/

This is not working on my windows machine (using development server,
not apache+mod_python).

Thank you.


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



Re: Django and Routing SUBDOMAIN STYLE URL

2007-03-24 Thread johnny

How do you test the subdomin url style in Django development server?

Developer server is at:
http://127.0.0.1:8000/

Thank you.



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



Django and Routing SUBDOMAIN STYLE URL

2007-03-24 Thread johnny

How do I route subdomains style url: http://api.mysite.com/ ?

Thank you.


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



Re: Django & Web Services Api

2007-03-20 Thread johnny

I am not sure if I want to take XML-RPC approach.  In the future, I
may consider REST for Web Services API, like Flickr.


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



Django & Web Services Api

2007-03-19 Thread johnny

I need to create a simple web api for my project.  Basically they make
a request, I send response back in XML.  Or they send me XML docs to
upload to my site.  Any good python XML  out there for this kind of
service?  I am looking at ElemenTtree.  Any other ideas welcome.

Thank you


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



Re: newb: newforms DateTimeField and User enters in a specific format

2007-03-18 Thread johnny

At least, can someone tell me, what date time format, newforms
DateTimeField takes?  Right now it's not taking 03/17/2007 05:11 PM in
the input field, validation is failing.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newb: newforms and passing an extra parameter: forms.SalesForm(request.POST, p_id)

2007-03-17 Thread johnny

You are calling this as a method from SalesForm?
Yes, I am calling self.data.get('p_id') inside SalesForm.

As [EMAIL PROTECTED] mentioned above, I popped the primary key before
passing to the base form class, I got it to work so far.  But if I add
def clean, some reason, it doesn't validate properly.  I will get back
to this when I have time.  I think I spent too much time just to get
this to work.


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



newb: newforms DateTimeField and User enters in a specific format

2007-03-17 Thread johnny

In the input field user enters date and time, together like this
format: 03/17/2007 05:11 PM
If I do enter it like this, I get a validation error as follows:

03/17/2007 05:11 PM  *** Enter a valid date/time.

I have following code in my forms.py and tempalte add.html:

forms.py
start_at = forms.DateTimeField(label='Start At',
   required = True
   )
add.html

Start At: {{ form.start_at }}
{% if form.start_at.errors %}*** {{ form.start_at.errors|join:",
" }}{% endif %}


I try to run it and see what format python deals with for datatime, it
gives out in this format: (, mm, dd, hh, mm, ss, microsecond)
In python shell the datetime format look like this
>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2007, 3, 17, 17, 23, 50, 578000)
>>>

How can I fix it so it takes the input the way user enters: 03/17/2007
05:11 PM ?

Thank you.


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



Re: newb: newforms and passing an extra parameter: forms.SalesForm(request.POST, p_id)

2007-03-16 Thread johnny

>self.data.get('p_id')

I tried it, getting error:

Exception Type: AttributeError
Exception Value: 'str' object has no attribute 'get'


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newb: newforms and passing an extra parameter: forms.SalesForm(request.POST, p_id)

2007-03-16 Thread johnny

I need to validate the data user enters, based on the product they
have viewed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newb: newforms and passing an extra parameter: forms.SalesForm(request.POST, p_id)

2007-03-16 Thread johnny

I did this: forms.SalesForm(request.POST, p_id). Inside class
SalesForm(forms.Form) which init was overwrote, as you mentioned like
below.  Now within SalesForm, how do I get p_id?

> class SalesForm(forms.Form):
> def __init__(self, *args, **kwargs):
> super(SalesForm, self).__init__(*args, **kwargs)
> # do your stuff 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
-~--~~~~--~~--~--~---



newb: newforms and passing an extra parameter: forms.SalesForm(request.POST, p_id)

2007-03-16 Thread johnny

I have a forms.py that uses newforms.  It has a class
SalesForm(forms.Form). I need to pass an argument, p_id to SalesForm,
which is used to retrieve related product from product model.  When I
run it, I get an error:

Exception Type: TypeError
Exception Value:__init__() takes exactly 2 arguments (3 given)

at 'form = forms.SalesForm(request.POST, p_id)', in view.

In the view.py and forms.py, I have the following:

forms.py:

class SalesForm(forms.Form):
def __init__(self, p_id):
do some stuff here

view.py:

from apps.sales import forms
def forsale_add(request, p_id):
if request.method == 'POST':
form = forms.SalesForm(request.POST, p_id)
if form.is_valid():
do my stuff here
return something
 else:
form = forms.SalesForm(p_id)
 return something

Thank you.


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



newb: Newform conditional regexField

2007-03-16 Thread johnny

In newform, how do I allow a single regexField to accept either a
whole number, or number with decimal places?

Thank you.


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



newb: Django ORM for Custom SQL

2007-03-15 Thread johnny

I need to retrieve latest record (each record has a time stamp,
created_at), only one record, from sale table where product_id=1.  How
do I do this in Django ORM?  I have looked at .objects.extra{}, but I
am getting ProgrammingError 1064.

I need to get this sql into Django ORM:

select created_at
  , amount
  , ...
  from sales
  where product_id = 1
order
by created_at desc
 limit 1


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



newb: Django & CountingDown

2007-03-14 Thread johnny

I have an app that is for online test taking. Most online test are 30
mins to 2hrs. I need to create count down clock from when the test is
stared. If 30 mins test, then count down will start from 30 mins : 00
Secs, 29 min: 59 secs and so on. How do I do this?


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



Django Automatic Page Refreshing

2007-03-11 Thread johnny

I have an online seminar booking application.  What I want to know is,
if 100 people are currently
viewing a room that holds max 200 people, and one person out of 100
books the seat in the room, how do
I refresh all the 100 pages so that they all have an updated version?

Thank you.


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



Re: Django and jQuery Autocomplete Routing Help

2007-03-08 Thread johnny

I am new to python and javaScript, I have created a funtion that
return the tags via ajax.  I tried to replicate the php example.  But
it's not working.  I doesn't return any tags back to my html page via
ajax.  I need some help.  I am using jQuery autocomplete plugin from
here: 
http://just-tech.blogspot.com/2006/12/jquery-tweaking-auto-complete-plugin.html.
Here is my function in view:

def tag_autocomplete(request):
#$q = $_GET['q'];
#foreach($countries as $country) {
#if(eregi("^".$q, $country)) {
#echo $country."\r\n";
#}

s = request.GET.get('q', '')
current_tags = list(Tag.objects.all())
for tag in current_tags:
if (search (s.lower(), tag.normalized_tag)):
print "%s" % (tag.normalized_tag)



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



newb: Model.objects.select_related().get(id=4)

2007-03-08 Thread johnny

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

class Person(models.Model):
# ...
hometown = models.ForeignKey(City)

class Book(models.Model):
# ...
author = models.ForeignKey(Person)
edited = models.ForeignKey(Person)

If do this: Book.objects.select_related().get(id=4), Would it get one
book object, the 2 person and 2 city object, like below?

book: -person-city (author who created it),
  -person-city (editor who edited it)

Thank you


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



Django dev ProgrammingError 1064 MySQLdb/connections.py

2007-03-07 Thread johnny

There seem to be an error I am getting in Dev Version of Django, I
just updated 1/2 hr ago.  It's
related to model back tracking, retrieving foreign key related
objects, line 31: p.question_set.all, in template.

ProgrammingError at /post/1/
(1064, "You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'body,1' at line 1")
Request Method: GET
Request URL:http://127.0.0.1:8000/post/1/
Exception Type: ProgrammingError
Exception Value:(1064, "You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'body,1' at line 1")
Exception Location: H:\xampp\python\lib\site-packages\MySQLdb
\connections.py in defaulterrorhandler, line 35


30  
31  {% for question in p.question_set.all %}
32  {{ question.title }}
33  {{ question.body }}
34  {% endfor %}
35  


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



Django ORM and Atomic Commit and Rollback

2007-03-07 Thread johnny

I have to update two models at the same time, if one model update
fails, I need to rollback the transactions.  How do you do this in
Django ORM.

Thank you.


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



Django and jQuery Autocomplete Routing Help

2007-03-05 Thread johnny

I am using jQuery to do the autocomplete.  Autocomplete  request
backend script like this: script_url?q=foo.  But there is a problem
with django routing?

(r'^tag/autocomplete/?q=(?P\w+)/$',
'apps.tag.views.tag_autocomplete'),

Here is my error:

[05/Mar/2007 15:11:51] "GET /tag/autocomplete/?q=a HTTP/1.1" 404 4218
[05/Mar/2007 15:11:51] "GET /jquery/img/indicator.gif HTTP/1.1" 404
3697
[05/Mar/2007 15:11:52] "GET /tag/autocomplete/?q=app HTTP/1.1" 404
4218

Thank you.


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



Django and jsCalendar

2007-03-03 Thread johnny

Has anyone got Django and jsCalendar to work?  Problem I am having is,
Django has separate input field for DATE and TIME.  jsCalendar combine
both together.  Even if I separate it manually, validation is
failing.  I have spent some days on this.  Didn't get anywhere.   I
like jsCalendar for one reason, Multiple Language support.  It will be
great help if someone post some sample code.  Thank you.


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



Re: newform: Post_add Submission not working

2007-03-02 Thread johnny

I did place form.errors in the template.  If I type the invalid data,
then it displays the errors.  Problem is when I type in valid data, it
doesn't display anything and brings me back to the form with the data
I have entered.  Every frustrating problem.


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



newform: Post_add Submission not working

2007-03-01 Thread johnny

When I submit the information with the form, for some reason, I keep
coming back to the form, with data I entered.  I am not sure why this
is the case.  It should take the data, and save to the file.

def add_post(request):
if request.method == 'POST':
form = forms.postForm(request.POST)
if form.is_valid():
new_post= Post(
title = form.clean_data['title'],
description = form.clean_data['description'],
created_at =
datetime.utcnow(),
)

new_post.save()
return HttpResponseRedirect(new_post.get_absolute_url())
else:
form = forms.postForm()
return render_to_response('post/post_add.html',
  { 'form': form,
  'html_head': ''
  },
  context_instance=RequestContext(request))


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



newform: Post_add Submission not working

2007-03-01 Thread johnny

When I submit the information with the form, for some reason, I keep
coming back to the form, with data I entered.  I am not sure why this
is the case.  It should take the data, and save to the file.

def add_post(request):
if request.method == 'POST':
form = forms.postForm(request.POST)
if form.is_valid():
new_post= Post(
title = form.clean_data['title'],
description = form.clean_data['description'],
created_at =
datetime.utcnow(),
)

new_post.save()
return HttpResponseRedirect(new_post.get_absolute_url())
else:
form = forms.postForm()
return render_to_response('post/post_add.html',
  { 'form': form,
  'html_head': ''
  },
  context_instance=RequestContext(request))


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



  1   2   >