Re: NoReverseMatch Error

2012-08-24 Thread Syam Palakurthy
Hi, Can you please elaborate on how to use this block in the template code? 
 I've tried adding this into my details template code in various places and 
cannot get it to successfully work.  Also, any suggestions/examples you 
could point me to would be much appreciated.

{{ poll.question }}

{% if error_message %}{{ error_message }}{% endif %}


{% import url from future %}


{% csrf_token %}
{% for choice in poll.choice_set.all %}


{{ choice.choice_text 
}}
{% endfor %}



Thanks,
Syam

On Wednesday, August 15, 2012 4:53:23 AM UTC-7, Karen Tracey wrote:
>
> On Tue, Aug 14, 2012 at 10:46 AM, Serge G. Spaolonzi 
>  > wrote:
>
>> Try removing the quotes from 'polls.views.vote':
>>
>> 
>>
>>
>>
> Note that will work for 1.4 but it's doing things the old way, and that 
> will break in 1.5. Much better to add {% import url from future %} and have 
> code that will continue to work with the next release of Django. Removing 
> the quotes is not the best approach at this time.
>  
> Karen
> -- 
> http://tracey.org/kmt/
>
>

-- 
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/-/La3h_D5OnOQJ.
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: Column widths in TabularInline

2012-08-24 Thread Vikas Rawal

>
> In admin.py you can for example ... 
>
>  fieldsets = ( 
>  (None, { 
>  'classes': ['myowncssclassname',], 
>  'fields': ( 
>  'field_abc', 
>  'field_xyz', 
>
> ... and specify myowncssclassname in myextrastyle.css then finally in 
> the template include myextrastyle.css in the extrastyle block 
>
>
I am new to django and CSS. Will try to do this. If you could kindly 
elaborate a bit more (perhaps give an example of how to define the widths 
in extrastyle.css, and where to keep that file), I shall be grateful.

I would want different width for each field. It is not clear to me how 
would your suggestion work since that seems to be specifying a single class 
for the entire fieldset.

Vikas

>
>

-- 
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/-/rpGnNl5uQBoJ.
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: Column widths in TabularInline

2012-08-24 Thread Mike Dewhirst

On 25/08/2012 3:06am, Vikas Rawal wrote:

How do i customise width of different columns in a TabularInline object
in my admin interface.


In admin.py you can for example ...

fieldsets = (
(None, {
'classes': ['myowncssclassname',],
'fields': (
'field_abc',
'field_xyz',

... and specify myowncssclassname in myextrastyle.css then finally in 
the template include myextrastyle.css in the extrastyle block


hth

Mike



V.

--
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/-/dekCUaSTkgAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


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



Re: New to Django, having difficulty creating first app. PLEASE HELP!

2012-08-24 Thread MattDale
Glad you are trying out Django.

That error is telling you what's wrong  The directory that you are in does 
not include the file "manage.py".  Depending on your operating system, when 
you get this error, get the contents of the directory(windows, type dir and 
press enter) if the outputted list doesn't include "manage.py", then you 
are not in the outer mysite directory.  You most likely did not "change 
into the outer mysite directory". So from that point in the tutorial, type 
cd ..  and press enter, and that should be the outer directory. just to be 
sure, check the contents of the directory you are in by typing "dir".  

Sorry if that answer is a little too basic and you already know all that, 
but I wanted to offer the simplest troubleshooting options first. 

Good luck


On Friday, August 24, 2012 7:10:21 PM UTC-4, lukedc wrote:
>
>
> Hello everyone, 
>
> I am doing the django tutorial. 
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
>
> I am on the part where it says, "The development server". It says: Let's 
> verify this worked. Change into the outer mysite directory, if you 
> haven't already, and run the command python manage.py runserver.
>
> When I type in  "python manage.py runserver" on the command prompt, 
> however, it says, "python: can't open file 'manage.py': [Errno 2] no such 
> file or directory. 
>
> What should I do? Can you please tell me?
>
> I have done everything right so far. 
>
> Thank you all so much, Luke
>

-- 
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/-/dvhYfNcXeiMJ.
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.



New to Django, having difficulty creating first app. PLEASE HELP!

2012-08-24 Thread lukedc

Hello everyone, 

I am doing the django tutorial. 
https://docs.djangoproject.com/en/1.4/intro/tutorial01/

I am on the part where it says, "The development server". It says: Let's 
verify this worked. Change into the outer mysite directory, if you haven't 
already, and run the command python manage.py runserver.

When I type in  "python manage.py runserver" on the command prompt, 
however, it says, "python: can't open file 'manage.py': [Errno 2] no such 
file or directory. 

What should I do? Can you please tell me?

I have done everything right so far. 

Thank you all so much, Luke

-- 
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/-/gcEJjLVmVVcJ.
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: Not sure how to describe issue/behavior with Form -- so here's code & YouTube video

2012-08-24 Thread Barry Morrison
Serge,
Thank you.
#92 is for the crispy form.

The crispy-form is the actual form, but the form is using a WYSIWYG editor
http://redactorjs.com/ and when I go to browse for an image it calls url
'photo-uploads' which calls the function 'upload_photos' in the view.

That view is necessary for redactor.js to get the image(s) from it's API
via json, so I understand why the view creates the object, but doing so, it
creates an empty field in the database.

I had separated the models, so I had an Article model and an ArticleImage
model, but then redactor.js failed to work (unsure how to create the
relationship in the crispy form or any form for that matter).

Thanks,
Barry

On Fri, Aug 24, 2012 at 3:00 PM, Sergiy Khohlov  wrote:

>  Hello Barry !
>  I would like to say that your are not novice. now and  your code is
> really clear.
> Could you please move  string #92  up  ? super should be called before
> other field initialization.
> look like your prev activity is stored  after init process and  those
> data is saved at the save operation.
> try to print form  to log after pressing cancel button
>
>  thanks , serge
>
> 2012/8/25 Barry Morrison :
> > For ease of use, let's take the cancel out of the equation perhaps.
> >
> > Url to create a new News Event:
> > ### Create News Article
> > url(r'^account/news/add/$', login_required(CreateView.as_view(
> > model=NewsArticle,
> > form_class=NewsForm,
> > success_url=("/account/news"),
> > template_name="account/news_admin.html")),
> > name="admin-add-news"),
> >
> >
> > Url that gets called when I chose to insert an image into the WYSIWYG
> editor
> > (and calls 'upload_photos' that has the NewsArticle.objects.create())
> >
> > ### Redactor.js WYSIWYG Editor
> > ###
> > url(r"^uploads/$", "web_site.News.views.upload_photos",
> > name="upload_photos"),
> > url(r"^recent/$", "web_site.News.views.recent_photos",
> > name="recent_photos"),
> >
> > and the views themselves:
> >
> > @csrf_exempt
> > @require_POST
> > @login_required
> > def upload_photos(request):
> > images = []
> > for f in request.FILES.getlist("file"):
> > obj = NewsArticle.objects.create(upload=f, is_image=True)
> >
> > images.append({"filelink": obj.upload.url})
> > return HttpResponse(json.dumps(images), mimetype="application/json")
> >
> >
> > @login_required
> > def recent_photos(request):
> > images = [
> > {"thumb": obj.upload.url, "image": obj.upload.url}
> > for obj in
> > NewsArticle.objects.filter(is_image=True).order_by("-date_created")[:20]
> > ]
> > return HttpResponse(json.dumps(images), mimetype="application/json")
> >
> >
> > I've tried to set a .save(commit=False) on obj -- that doesn't work.
> >
> > I realize the behavior is call 'upload_photos' and it'll create the
> object
> > in the database, but on any other event other than submission of the
> form, I
> > want that object to no longer exist.  I guess I want it to ONLY get
> created
> > upon form submission.
> >
> >
> >
> > On Friday, August 24, 2012 3:01:32 AM UTC-7, Tom Evans wrote:
> >>
> >> On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison 
> >> wrote:
> >> > Code: http://dpaste.org/az8Nb/
> >> > Video http://www.youtube.com/watch?v=XFSb044UkPs=youtu.be
> >> >
> >> > so first action, I click + which adds new, hitting cancel, takes me
> back
> >> > to
> >> > the view displaying all the news events
> >> > next action, I hit + again, adds new news event...this time I browse
> for
> >> > an
> >> > image, again, I click cancel, takes me back to the view of all news
> >> > events,
> >> > but you see now an empty news event has been created
> >> > next action, I hit + again, add a new image, hit submit. success_url
> >> > takes
> >> > me go the view of all events, this time it created the form I
> submitted
> >> > and
> >> > created another empty one
> >> >
> >> > The function in views.py "add_news_item" is not set up in the URL, but
> >> > it
> >> > does support the cancel on the form action. The video posted is using
> >> > that
> >> > view for the URL.  With the 'CreateView' in the URL, canceling the
> form
> >> > will
> >> > create an empty field in the database.
> >> >
> >> > Any help/guidance would be greatly appreciated!!
> >> >
> >> > Thanks!
> >>
> >> I've not watched your video. I also have no idea what crispy forms
> >> are, or what django form attributes are created using that syntax.
> >> However…
> >>
> >> Your model definition allows an empty form to be valid - none of those
> >> fields are required AFAICT. Therefore, submitting an empty form using
> >> the cancel button is being allowed to proceed. Therefore your check on
> >> whether "cancel" was submitted is not working.
> >>
> >> Put some debug here:
> >>
> >> http://dpaste.org/az8Nb/#l28
> >>
> >> Output what "submit" is, and all values in request.POST.
> >>
> >> Cheers
> >>
> >> Tom
> >
> > 

Re: Not sure how to describe issue/behavior with Form -- so here's code & YouTube video

2012-08-24 Thread Sergiy Khohlov
 Hello Barry !
 I would like to say that your are not novice. now and  your code is
really clear.
Could you please move  string #92  up  ? super should be called before
other field initialization.
look like your prev activity is stored  after init process and  those
data is saved at the save operation.
try to print form  to log after pressing cancel button

 thanks , serge

2012/8/25 Barry Morrison :
> For ease of use, let's take the cancel out of the equation perhaps.
>
> Url to create a new News Event:
> ### Create News Article
> url(r'^account/news/add/$', login_required(CreateView.as_view(
> model=NewsArticle,
> form_class=NewsForm,
> success_url=("/account/news"),
> template_name="account/news_admin.html")),
> name="admin-add-news"),
>
>
> Url that gets called when I chose to insert an image into the WYSIWYG editor
> (and calls 'upload_photos' that has the NewsArticle.objects.create())
>
> ### Redactor.js WYSIWYG Editor
> ###
> url(r"^uploads/$", "web_site.News.views.upload_photos",
> name="upload_photos"),
> url(r"^recent/$", "web_site.News.views.recent_photos",
> name="recent_photos"),
>
> and the views themselves:
>
> @csrf_exempt
> @require_POST
> @login_required
> def upload_photos(request):
> images = []
> for f in request.FILES.getlist("file"):
> obj = NewsArticle.objects.create(upload=f, is_image=True)
>
> images.append({"filelink": obj.upload.url})
> return HttpResponse(json.dumps(images), mimetype="application/json")
>
>
> @login_required
> def recent_photos(request):
> images = [
> {"thumb": obj.upload.url, "image": obj.upload.url}
> for obj in
> NewsArticle.objects.filter(is_image=True).order_by("-date_created")[:20]
> ]
> return HttpResponse(json.dumps(images), mimetype="application/json")
>
>
> I've tried to set a .save(commit=False) on obj -- that doesn't work.
>
> I realize the behavior is call 'upload_photos' and it'll create the object
> in the database, but on any other event other than submission of the form, I
> want that object to no longer exist.  I guess I want it to ONLY get created
> upon form submission.
>
>
>
> On Friday, August 24, 2012 3:01:32 AM UTC-7, Tom Evans wrote:
>>
>> On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison 
>> wrote:
>> > Code: http://dpaste.org/az8Nb/
>> > Video http://www.youtube.com/watch?v=XFSb044UkPs=youtu.be
>> >
>> > so first action, I click + which adds new, hitting cancel, takes me back
>> > to
>> > the view displaying all the news events
>> > next action, I hit + again, adds new news event...this time I browse for
>> > an
>> > image, again, I click cancel, takes me back to the view of all news
>> > events,
>> > but you see now an empty news event has been created
>> > next action, I hit + again, add a new image, hit submit. success_url
>> > takes
>> > me go the view of all events, this time it created the form I submitted
>> > and
>> > created another empty one
>> >
>> > The function in views.py "add_news_item" is not set up in the URL, but
>> > it
>> > does support the cancel on the form action. The video posted is using
>> > that
>> > view for the URL.  With the 'CreateView' in the URL, canceling the form
>> > will
>> > create an empty field in the database.
>> >
>> > Any help/guidance would be greatly appreciated!!
>> >
>> > Thanks!
>>
>> I've not watched your video. I also have no idea what crispy forms
>> are, or what django form attributes are created using that syntax.
>> However…
>>
>> Your model definition allows an empty form to be valid - none of those
>> fields are required AFAICT. Therefore, submitting an empty form using
>> the cancel button is being allowed to proceed. Therefore your check on
>> whether "cancel" was submitted is not working.
>>
>> Put some debug here:
>>
>> http://dpaste.org/az8Nb/#l28
>>
>> Output what "submit" is, and all values in request.POST.
>>
>> Cheers
>>
>> Tom
>
> --
> 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/-/cf1oUHRglAcJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google 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: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-24 Thread Bill Freeman
While
  u = request.user
may not be enough,
  request.user.username
should be (I don't think you even have to put it in a variable, python
will evaluate it even if the result is discarded).

On Thu, Aug 23, 2012 at 9:20 AM, Alexis Bellido  wrote:
> Ok, I just confirmed my "problem" was caused by Django lazy loading the User
> object.
>
> To confirm it, I just added something like this to my view:
>
> test_var = "some text" + request.user
>
> And I got an error message telling me I couldn't concatenate an str to a
> SimpleLazyObject. At this point the lazy loading logic hasn't got a real
> User object yet.
>
> To bypass the lazy loading, hence return a non-cache view for authenticated
> users, I just needed to access some method or attribute to triggers an
> actual query on the User object. I ended up with this, which I think it's
> the simplest way:
>
> bypass_lazyload = request.user.is_authenticated()
>
> My conditional_cache decorator is no longer needed, although it was an
> interesting exercise.
>
> I may not need to do this when I finish working with my views as I'll access
> some user methods and attributes on my templates anyway but it's good to
> know what was going on.
>
> Regards.
>
>
> On Thursday, August 23, 2012 2:40:47 AM UTC-3, ke1g wrote:
>>
>> I guess this is probably because the request.user object is created on
>> demand
>> (is a python "property").  The intent, I presume, is to not bother
>> fetching the session,
>> etc., unless it is used, as an optimization.
>>
>> You should find that simply referring to request.user in the view
>> helps.  If so, then
>> you may want to add such to the views you want to leave uncached.  An
>> alternative
>> is to add a middleware that does this, which will incur the lookup
>> costs for all views.
>>
>> Bill
>>
>> On Tue, Aug 21, 2012 at 1:27 PM, Alexis Bellido 
>> wrote:
>> > Hello,
>> >
>> > I am working on a Django 1.4 project and writing one simple application
>> > using per-site cache as described here:
>> >
>> > https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache
>> >
>> > I have correctly setup a local Memcached server and confirmed the pages
>> > are
>> > being cached.
>> >
>> > Then I set CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True because I don't want
>> > to
>> > cache pages for authenticated users.
>> >
>> > I'm testing with a simple view that returns a template with
>> > render_to_response and RequestContext to be able to access user
>> > information
>> > from the template and the caching works well so far, meaning it caches
>> > pages
>> > just for anonymous users.
>> >
>> > And here's my problem. I created another view using a different template
>> > that doesn't access user information and noticed that the page was being
>> > cached even if the user was authenticated. After testing many things I
>> > found
>> > that authenticated users were getting a cached page if the template
>> > didn't
>> > print something from the user context variable. It's very simple to
>> > test:
>> > print the user on the template and the page won't be cached for an
>> > authenticated user, remove the user on the template, refresh the page
>> > while
>> > authenticated and check the HTTP headers and you will notice you're
>> > getting
>> > a cached page. You should clear the cache between changes to see the
>> > problem
>> > more clearly.
>> >
>> > I tested a little more and found that I could get rid of the user in the
>> > template and print request.user right on the view (which prints to the
>> > development server console) and that also fixed the problem of showing a
>> > cached page to an authenticated user but that's an ugly hack.
>> >
>> > A similar problem was reported here but never got an answer:
>> >
>> > https://groups.google.com/d/topic/django-users/FyWmz9csy5g/discussion
>> >
>> > I can probably write a conditional decorator to check if
>> > user.is_authenticated() and based on that use @never_cache on my view
>> > but it
>> > seems like that defeats the purpose of using per-site cache, doesn't it?
>> >
>> > Any suggestions will be appreciated.
>> >
>> > Thanks!
>> >
>> > --
>> > 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/-/dZx3IJsXp9EJ.
>> > To post to this group, send email to django...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users...@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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/uzyHfkEIe7UJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> 

Re: Not sure how to describe issue/behavior with Form -- so here's code & YouTube video

2012-08-24 Thread Barry Morrison
For ease of use, let's take the cancel out of the equation perhaps.  

Url to create a new News Event: 
### Create News Article
url(r'^account/news/add/$', login_required(CreateView.as_view(
model=NewsArticle,
form_class=NewsForm,
success_url=("/account/news"),
template_name="account/news_admin.html")),
name="admin-add-news"),


Url that gets called when I chose to insert an image into the WYSIWYG 
editor (and calls 'upload_photos' that has the NewsArticle.objects.create())

### Redactor.js WYSIWYG Editor
###
url(r"^uploads/$", "web_site.News.views.upload_photos", 
name="upload_photos"),
url(r"^recent/$", "web_site.News.views.recent_photos", 
name="recent_photos"),

and the views themselves:

@csrf_exempt
@require_POST
@login_required
def upload_photos(request):
images = []
for f in request.FILES.getlist("file"):
obj = NewsArticle.objects.create(upload=f, is_image=True)

images.append({"filelink": obj.upload.url})
return HttpResponse(json.dumps(images), mimetype="application/json")


@login_required
def recent_photos(request):
images = [
{"thumb": obj.upload.url, "image": obj.upload.url}
for obj in 
NewsArticle.objects.filter(is_image=True).order_by("-date_created")[:20]
]
return HttpResponse(json.dumps(images), mimetype="application/json")


I've tried to set a .save(commit=False) on obj -- that doesn't work. 

I realize the behavior is call 'upload_photos' and it'll create the object 
in the database, but on any other event other than submission of the form, 
I want that object to no longer exist.  I guess I want it to ONLY get 
created upon form submission.



On Friday, August 24, 2012 3:01:32 AM UTC-7, Tom Evans wrote:
>
> On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison 
>  
> wrote: 
> > Code: http://dpaste.org/az8Nb/ 
> > Video http://www.youtube.com/watch?v=XFSb044UkPs=youtu.be 
> > 
> > so first action, I click + which adds new, hitting cancel, takes me back 
> to 
> > the view displaying all the news events 
> > next action, I hit + again, adds new news event...this time I browse for 
> an 
> > image, again, I click cancel, takes me back to the view of all news 
> events, 
> > but you see now an empty news event has been created 
> > next action, I hit + again, add a new image, hit submit. success_url 
> takes 
> > me go the view of all events, this time it created the form I submitted 
> and 
> > created another empty one 
> > 
> > The function in views.py "add_news_item" is not set up in the URL, but 
> it 
> > does support the cancel on the form action. The video posted is using 
> that 
> > view for the URL.  With the 'CreateView' in the URL, canceling the form 
> will 
> > create an empty field in the database. 
> > 
> > Any help/guidance would be greatly appreciated!! 
> > 
> > Thanks! 
>
> I've not watched your video. I also have no idea what crispy forms 
> are, or what django form attributes are created using that syntax. 
> However… 
>
> Your model definition allows an empty form to be valid - none of those 
> fields are required AFAICT. Therefore, submitting an empty form using 
> the cancel button is being allowed to proceed. Therefore your check on 
> whether "cancel" was submitted is not working. 
>
> Put some debug here: 
>
> http://dpaste.org/az8Nb/#l28 
>
> Output what "submit" is, and all values in request.POST. 
>
> Cheers 
>
> Tom 
>

-- 
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/-/cf1oUHRglAcJ.
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 by Example: error with to do app; global name 'escape' is not defined

2012-08-24 Thread koiwai
plus code

def response_add(self, request, obj, post_url_continue='../%s/'):
"""
Determines the HttpResponse for the add_view stage.
"""
opts = obj._meta
pk_value = obj._get_pk_val()

msg = "Item(s) were added successfully."
# Here, we distinguish between different save types by checking for
# the presence of keys in request.POST.
if "_continue" in request.POST:
self.message_user(request, msg + ' ' + _("You may edit it again 
below."))
if "_popup" in request.POST:
post_url_continue += "?_popup=1"
return HttpResponseRedirect(post_url_continue % pk_value)

if "_popup" in request.POST:
return HttpResponse(
''
'opener.dismissAddAnotherPopup(window, "%s", 
"%s");' % \
# escape() calls force_text.
(escape(pk_value), escapejs(obj)))
elif "_addanother" in request.POST:
self.message_user(request, msg + ' ' + (_("You may add another 
%s below.") % force_text(opts.verbose_name)))
return HttpResponseRedirect(request.path)
else:
self.message_user(request, msg)
return 
HttpResponseRedirect(reverse("admin:todo_item_changelist"))

thanks 

On Friday, August 24, 2012 4:54:16 PM UTC+1, koiwai wrote:
>
> Hi,
>
> I'm currently working through Django by 
> Examplesand I am getting an error when attempting 
> to have the user automatically go 
> back to the listing of 'todo items'  after entering new 'to do items' 
> through creating a new date. The 
> siteasks us 
> to copy a function from a template provided by django, and alter a 
> couple of things. The code example and the template are a bit different 
> post altering though (I guess this is because I am using 1.4;s default 
> packages and presumably the author was using 1.2), but I don't think these 
> are relevant to my problem (I use in rather than has.key etc)
>
> Name Error at /admin/todo/datetime/add/
> global name 'escape' is not defined
>

-- 
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/-/zw4c7aTNGRYJ.
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.



Column widths in TabularInline

2012-08-24 Thread Vikas Rawal
How do i customise width of different columns in a TabularInline object in 
my admin interface.

V.

-- 
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/-/dekCUaSTkgAJ.
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: Layout of widgets in admin form

2012-08-24 Thread Vikas Rawal
Thanks. Worked perfectly.


Vikas


On Friday, August 24, 2012 6:32:03 PM UTC+5:30, Melvyn Sopacua wrote:
>
> On 24-8-2012 14:05, Vikas Rawal wrote: 
> >> 
> >> <
> https://docs.djangoproject.com/en/1.4/intro/tutorial02/#customize-the-admin-form>
>  
>
> >> 
> >> See the fieldsets part. 
> > 
> > 
> > The examples shown for fieldsets seem to divide the fields into 
> > different groups. But in all the examples, fields still appear, within 
> > each group, one after another, vertically. 
>
> Ah, right it's not properly covered in the tutorial. Within the fields 
> member of the dictionary you can group them. Details are here: 
> <
> https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields>
>  
>
>
> Short version: 
> fieldsets = ( 
> (None, { 
> 'fields': ( (question, pub_date), ), 
> } 
> ), 
> #... 
> ) 
> -- 
> Melvyn Sopacua 
>

-- 
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/-/xAuArkAr4_gJ.
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 makemessages doesn't recognize trans in templates

2012-08-24 Thread Jojo
thank you guys! very helpful!

Il giorno lunedì 20 agosto 2012 12:43:20 UTC-5, Nick Apostolakis ha scritto:
>
>
>
> On Mon, Aug 20, 2012 at 8:18 PM, Jojo  > wrote:
>
>> what is the meaning of the fuzzy mark?
>>
>>
> fuzzy is some kind of auto translated field.
> it may be correct or not.
> when you are sure that the translation is correct, you remove the fuzzy 
> annotation and then the translation works fine 
> -- 
> ---
> Nick Apostolakis
> email:n...@oncrete.gr 
> Web Site: http://nick.oncrete.gr
> ---
>

-- 
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/-/ZsGNf66ZSR8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django by Example: error with to do app; global name 'escape' is not defined

2012-08-24 Thread koiwai
Hi,

I'm currently working through Django by Examples and 
I am getting an error when attempting to have the user automatically go 
back to the listing of 'todo items'  after entering new 'to do items' 
through creating a new date. The 
siteasks us to 
copy a function from a template provided by django, and alter a 
couple of things. The code example and the template are a bit different 
post altering though (I guess this is because I am using 1.4;s default 
packages and presumably the author was using 1.2), but I don't think these 
are relevant to my problem (I use in rather than has.key etc)

Name Error at /admin/todo/datetime/add/
global name 'escape' is not defined

-- 
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/-/1P4N5wMm4VEJ.
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: Why is my groundwork in django show up in 404 page?

2012-08-24 Thread Masud Khokhar
Hi Melvyn,

Many thanks for clarifying.

@txshon, I would recommend the same as Melvyn, please file a ticket with
their developers.

Best wishes,
Masud

On 24 August 2012 15:46, Melvyn Sopacua  wrote:

> On 24-8-2012 15:42, Masud Khokhar wrote:
>
> > I have never worked with groundwork before, but it seems like you need
> the
> > newly created app URLs in your urls.py file.
>
> That's what groundwork is supposed to do for you:
> <
> https://github.com/madhusudancs/django-groundwork/blob/master/django-groundwork/management/commands/groundwork.py#L21
> >
>
> @Masud: if you don't get a good answer from users here, you may want to
> file a ticket with them.
> --
> Melvyn Sopacua
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google 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: runserver error: "No module named app3"

2012-08-24 Thread Bill Beal
I am using pip, and once I tried virtualenv without understanding it and it
worked.  There's a kind of knowledge that I call "who's on first"
knowledge: you know what comes next but you don't know why.

On Thu, Aug 23, 2012 at 6:29 PM, Alexis Bellido wrote:

> I'd suggest you decouple your apps from your projects. If you want to have
> everything under the same tree you could, I don't do it that way though.
>
> You could have a tree like this:
>
> /home/user
> --proj
> proj (this contains settings.py in Django 1.4)
> app1
> app2
> --app3
>
> You already noticed that Django 1.4 has an inner proj directory which
> contains settings.py but notice the outer directory doesn't need to be
> called proj, you could rename it and everything will work. In fact, you
> could change the inner directory name too if you update the corresponding
> variables in settings.py (ROOT_URLCONF and WSGI_APPLICATION are the two
> ones that come to mind).
>
> In my example tree I have app1 and app2 under the outer proj and at the
> same level with the inner proj and I have app3 at the same level with the
> outer proj but that doesn't matter much because as long as you have app1,
> app2 and app3 in your PYTHONPATH you will able to do something like this:
>
> INSTALLED_APPS = (
> ...
> ...
> 'app1',
> 'app2',
> 'app3',
> )
>
> If you are not using virtualenv and pip yet you should, it helps a lot.
>
> Notice you don't need to include use proj (such as in 'proj.app1') and
> this is the way to go if you want to reuse your apps in other projects.
>
> Good luck!
>
> On Wednesday, August 22, 2012 6:16:15 PM UTC-3, Bill Beal wrote:
>>
>> Hi all,
>>
>> I have a Django project with apps that works OK on a Mac with Django 1.3
>> and Python 2.6, and I'm trying to move it to a Linux box with Django 1.4
>> and Python 2.7.  I created an empty project 'proj' with apps 'app1',
>> 'app2', 'app3' on the Linux system and carefully merged settings.py,
>> urls.py etc. with the initial files that were created.  When I run 'python
>> manage.py runserver' it says "Error: no module named app3" if app3 is the
>> last in the list of installed apps (see below), but if I swap app2 and app3
>> it claims app2 (now the last one in the list) is missing.  The error
>> message seems to be lying to me, and I don't know where to look for the
>> error.  In the settings.py file I have
>>
>> INSTALLED_APPS = (
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.sites',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> # Uncomment the next line to enable the admin:
>> 'django.contrib.admin',
>> # Uncomment the next line to enable admin documentation:
>> 'django.contrib.admindocs',
>> 'django.django-adminfiles',
>> 'proj.app1',
>> 'proj.app2',
>> 'proj.app3',
>> )
>>
>> I've looked around for anything on "Error: No module named xxx", but
>> haven't found any that seem to relate to this behavior.  Has anyone seen
>> this kind of error dependent on the order of the apps?  Is there any way I
>> can force a more informative error?  I tried adding an empty module name at
>> the end, and it gave me an error trace, but I couldn't figure out anything
>> from  it.  My directory tree looks like this:
>>
>> proj/
>> manage.py
>> proj/proj/
>> __init__.py
>> settings.py
>> urls.py
>> wsgi.py
>> proj/app1/
>> __init__.py
>> forms.py
>> models.py
>> tests.py
>> views.py
>> proj/app2/
>> __init__.py
>> forms.py
>> models.py
>> tests.py
>> views.py
>> proj/app3/
>> __init__.py
>> forms.py
>> models.py
>> tests.py
>> views.py
>> proj/templates/
>> . . .
>>
>> Django 1.4 seems to have a second proj directory under the first level
>> proj directory.  I didn't see this in 1.3.
>>
>>  --
> 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/-/pdq0xqjRk_QJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google 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: After form validation, need to post and call a perl program to display to a log file

2012-08-24 Thread Nick Santos
Obligatory followup (though the docs I believe cover this pretty well) - be 
*very* careful calling subprocess with anything related to a form 
submission. Read the documents that Melvyn linked to carefully because you 
can be opening a massive security hole. If this is just temporary to check 
some output, that's fine, but if you plan on going into production, make 
sure to know the risks and consider alternatives.
-Nick

On Friday, August 24, 2012 6:11:45 AM UTC-7, Melvyn Sopacua wrote:
>
> On 24-8-2012 8:41, Pervez Mulla wrote: 
>
> > Once validation happened (its working good), I wanna call perl script to 
> > disply it content to lof file ... 
> > 
> > 
> > How can I do this ..?? 
>
>  
> FYI, it don't matter that it's perl, you can do this for anything that 
> can be invoked as a "program". 
>
> -- 
> Melvyn Sopacua 
>

-- 
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/-/T4GGbPbHxGoJ.
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: Why is my groundwork in django show up in 404 page?

2012-08-24 Thread Melvyn Sopacua
On 24-8-2012 15:42, Masud Khokhar wrote:

> I have never worked with groundwork before, but it seems like you need the
> newly created app URLs in your urls.py file.

That's what groundwork is supposed to do for you:


@Masud: if you don't get a good answer from users here, you may want to
file a ticket with them.
-- 
Melvyn Sopacua

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



RES: Django-tables2

2012-08-24 Thread MattDale
If you make that column a regular Column does it render properly? If not then 
confirm that you define the column exactly as it is spelled in your 
models.py(case and all). Once it renders properly as a regular Column, then try 
changing to a LinkColumn. 

-- 
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/-/kGHFiQpIuDYJ.
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: Why is my groundwork in django show up in 404 page?

2012-08-24 Thread Masud Khokhar
Hi there,

I have never worked with groundwork before, but it seems like you need the
newly created app URLs in your urls.py file. Something like this at the end
of your urls.py file may work.

urlpatterns += patterns('bookapp.views',
url(r'^book/list/$', 'VIEW_NAME', name='list'),
)


On 24 August 2012 14:30, Sergiy Khohlov  wrote:

> you does not have enabled this in urls.py 
>
> 2012/8/24 txshon :
> > I follow the installation steps online about groundwork
> >
> > I use the command to setup groundwork for my project
> >
> >   python manage.py groundwork bookapp Book
> >
> > However, I go to the page
> >
> > http://127.0.0.1:8000/bookapp/book/list/
> >
> > it show up 404 error
> >
> > this is the information on that page
> >
> > Page not found (404)Request Method:GETRequest
> > URL:http://127.0.0.1:8000/bookapp/book/list/
> > Using the URLconf defined in BOOKMS.urls, Django tried these URL
> patterns,
> > in this order:
> >
> > ^admin/doc/
> > ^admin/
> >
> > The current URL, bookapp/book/list/, didn't match any of these.
> >
> > Please help... Thank you
> >
> > @txshon
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google 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: Why is my groundwork in django show up in 404 page?

2012-08-24 Thread Sergiy Khohlov
you does not have enabled this in urls.py 

2012/8/24 txshon :
> I follow the installation steps online about groundwork
>
> I use the command to setup groundwork for my project
>
>   python manage.py groundwork bookapp Book
>
> However, I go to the page
>
> http://127.0.0.1:8000/bookapp/book/list/
>
> it show up 404 error
>
> this is the information on that page
>
> Page not found (404)Request Method:GETRequest
> URL:http://127.0.0.1:8000/bookapp/book/list/
> Using the URLconf defined in BOOKMS.urls, Django tried these URL patterns,
> in this order:
>
> ^admin/doc/
> ^admin/
>
> The current URL, bookapp/book/list/, didn't match any of these.
>
> Please help... Thank you
>
> @txshon
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google 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: After form validation, need to post and call a perl program to display to a log file

2012-08-24 Thread Melvyn Sopacua
On 24-8-2012 8:41, Pervez Mulla wrote:

> Once validation happened (its working good), I wanna call perl script to
> disply it content to lof file ...
> 
> 
> How can I do this ..??


FYI, it don't matter that it's perl, you can do this for anything that
can be invoked as a "program".

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google 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: Layout of widgets in admin form

2012-08-24 Thread Melvyn Sopacua
On 24-8-2012 14:05, Vikas Rawal wrote:
>>
>> 
>>
>> See the fieldsets part.
> 
> 
> The examples shown for fieldsets seem to divide the fields into
> different groups. But in all the examples, fields still appear, within
> each group, one after another, vertically.

Ah, right it's not properly covered in the tutorial. Within the fields
member of the dictionary you can group them. Details are here:


Short version:
fieldsets = (
(None, {
'fields': ( (question, pub_date), ),
}
),
#...
)
-- 
Melvyn Sopacua

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



RES: Django-tables2

2012-08-24 Thread Roberto Ferreira Junior
Hi Matt,

 

When I use linkcolum instead of a template tag, my collum cell
does not display nothing!

 

Muito Obrigado,

--

Roberto Ferreira Junior

robefe...@gmail.com

11 98009942

 

De: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Em
nome de MattDale
Enviada em: sexta-feira, 24 de agosto de 2012 09:15
Para: django-users@googlegroups.com
Assunto: Re: Django-tables2

 

Here's an example of one of my tables.

 

class NeedsTable(tables.Table):

needQuantity = tables.Column()

prod_id = tables.Column()

description = tables.LinkColumn('needsdetail', args=[A('pk')])

department = tables.Column()

order = tables.Column()

priority = tables.Column(accessor='order.event.priority')

show = tables.Column(accessor='order.event.name')

preppedQuantity = tables.Column()

prepdate = tables.Column()



class Meta:

order_by = 'priority'

attrs = {'class': 'general_table'}

 

URLS.py - 

url(r'^qcarea/needs/detail/(?P\d+)/$', 'needs.views.needsdetail',
name='needsdetail') 

 

LinkColumn uses reverse() to get its view and you use the Accessor(A) to
pass the pk to the args of the reverse call.  This means that you must name
your URL in your urls.py.  

 

In your example, I can't quite figure out what you are attempting with the
TemplateColumn.  To me it seems like you need to create two link columns.  

Good Luck

 


On Thursday, August 23, 2012 1:28:01 PM UTC-4, Robert wrote:

Hi All,

 

I would like to ask something, I´m trying to render a table
using Django-tables2 and that table has a link column that I want to link
with another page, I cant figure out how can I link my model, and pass my PK
to url.py.  Here’s My code:

 

 

## Models.py:  ##



 

class Projetos(models.Model):

 

#FIELDS

nome_projeto = models.CharField("Projeto", max_length=150, null='true',)

desc_oferta = models.CharField("Descrição da oferta", max_length=500,
null='true',) #aumentar

integrador = models.CharField("Integrador", max_length=150,
null='true',)

contend_provider = models.CharField("Contend Provider", max_length=150,
null='true',)

marca_servico = models.CharField("Marca do Serviço", max_length=150,
null='true',)

valor_retry = models.IntegerField("Valor de retry", null='true',)

la =  models.IntegerField("Large account", null='true',)

lanc_comercial = models.DateField("Lançamento comercial", null='true')

term_projeto = models.DateField("Término do projeto", null='true')

data_acordo = models.DateField("Data de Acordo", null='true')

data_revisao = models.DateField("Data de Revisão", null='true')

ura_id =  models.IntegerField("URA ID", null='true')

ura_desc = models.CharField("Descição URA",max_length=150, null='true')

 



## tables.py  ##



 

TEMPLATE = '''

 

   Edit

 

upload

 

'''

 

 

class ProjetosMain(tables.Table):

 

pdb.set_trace()

nome_projeto = tables.Column(verbose_name='Projeto',orderable=False)

integrador =
tables.Column(verbose_name='Integrador',orderable=False)

contend_provider = tables.Column(verbose_name='CP',orderable=False)

status = tables.Column(verbose_name='Status',orderable=False)

term_projeto =
tables.Column(verbose_name='Vigencia',orderable=False)

 

Acoes = tables.TemplateColumn(TEMPLATE)

 

class Meta:

attrs = {'class': 'bordered'}

#

##  url.py ##

#

 

urlpatterns = patterns('',

 

# Main Page portal

(r'^$', portal_main_page),

 

# Home Page

(r'home/$', portal_main_page),

 

# Project Page

url(r'projetos/$', projetos_main_page),

url(r'projetos/?P\d{1,2,3,4}/edit/', project_edit,
name="project_edit"),

url(r'projetos/?P\d{1,2,3,4}/docs/', project_docs,
name="project_docs"),

 

# Upload File

(r'^uploadfile/$', uploadfile),

(r'^uploadsuccess/$', uploadsuccess),

 

)

 

 

Best Regards / Muito Obrigado,

--

Roberto Ferreira Junior

robefe...@gmail.com  

11 98009942

 

-- 
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/-/vm2VIX0jZOAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

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



Re: Django-tables2

2012-08-24 Thread MattDale
Here's an example of one of my tables.

class NeedsTable(tables.Table):
needQuantity = tables.Column()
prod_id = tables.Column()
description = tables.LinkColumn('needsdetail', args=[A('pk')])
department = tables.Column()
order = tables.Column()
priority = tables.Column(accessor='order.event.priority')
show = tables.Column(accessor='order.event.name')
preppedQuantity = tables.Column()
prepdate = tables.Column()

class Meta:
order_by = 'priority'
attrs = {'class': 'general_table'}

URLS.py - 
url(r'^qcarea/needs/detail/(?P\d+)/$', 'needs.views.needsdetail', 
name='needsdetail') 

LinkColumn uses reverse() to get its view and you use the Accessor(A) to 
pass the pk to the args of the reverse call.  This means that you must name 
your URL in your urls.py.  

In your example, I can't quite figure out what you are attempting with the 
TemplateColumn.  To me it seems like you need to create two link columns.  
Good Luck


On Thursday, August 23, 2012 1:28:01 PM UTC-4, Robert wrote:
>
> Hi All,
>
>  
>
> I would like to ask something, I´m trying to render a table 
> using *Django-tables2 *and that table has a link column that I want to 
> link with another page, I cant figure out how can I link my model, and pass 
> my PK to url.py.  Here’s My code:
>
>  
>
>  
>
> *## Models.py:  ##*
>
> 
>
>  
>
> class Projetos(models.Model):
>
>  
>
> #FIELDS
>
> nome_projeto = models.CharField("Projeto", max_length=150, 
> null='true',)
>
> desc_oferta = models.CharField("Descrição da oferta", max_length=500, 
> null='true',) #aumentar
>
> integrador = models.CharField("Integrador", max_length=150, 
> null='true',)
>
> contend_provider = models.CharField("Contend Provider", 
> max_length=150, null='true',)
>
> marca_servico = models.CharField("Marca do Serviço", max_length=150, 
> null='true',)
>
> valor_retry = models.IntegerField("Valor de retry", null='true',)
>
> la =  models.IntegerField("Large account", null='true',)
>
> lanc_comercial = models.DateField("Lançamento comercial", null='true')
>
> term_projeto = models.DateField("Término do projeto", null='true')
>
> data_acordo = models.DateField("Data de Acordo", null='true')
>
> data_revisao = models.DateField("Data de Revisão", null='true')
>
> ura_id =  models.IntegerField("URA ID", null='true')
>
> ura_desc = models.CharField("Descição URA",max_length=150, null='true')
>
>  
>
> **
>
> *## tables.py  ##*
>
> **
>
>  
>
> TEMPLATE = '''
>
>  
>
>Edit
>
>  
>
> upload
>
>  
>
> '''
>
>  
>
>  
>
> class ProjetosMain(tables.Table):
>
>  
>
> pdb.set_trace()
>
> nome_projeto = 
> tables.Column(verbose_name='Projeto',orderable=False)
>
> integrador = 
> tables.Column(verbose_name='Integrador',orderable=False)
>
> contend_provider = tables.Column(verbose_name='CP',orderable=False)
>
> status = tables.Column(verbose_name='Status',orderable=False)
>
> term_projeto = 
> tables.Column(verbose_name='Vigencia',orderable=False)
>
>  
>
> Acoes = tables.TemplateColumn(TEMPLATE)
>
>  
>
> class Meta:
>
> attrs = {'class': 'bordered'}
>
> *#*
>
> *##  url.py ##*
>
> *#*
>
>  
>
> urlpatterns = patterns('',
>
>  
>
> # Main Page portal
>
> (r'^$', portal_main_page),
>
>  
>
> # Home Page
>
> (r'home/$', portal_main_page),
>
>  
>
> # Project Page
>
> url(r'projetos/$', projetos_main_page),
>
> url(r'projetos/?P\d{1,2,3,4}/edit/', project_edit, 
> name="project_edit"),
>
> url(r'projetos/?P\d{1,2,3,4}/docs/', project_docs, 
> name="project_docs"),
>
>  
>
> # Upload File
>
> (r'^uploadfile/$', uploadfile),
>
> (r'^uploadsuccess/$', uploadsuccess),
>
>  
>
> )
>
>  
>
>  
>
> Best Regards / Muito Obrigado,
>
> --
>
> Roberto Ferreira Junior
>
> robefe...@gmail.com 
>
> 11 98009942
>
>  
>

-- 
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/-/vm2VIX0jZOAJ.
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: Layout of widgets in admin form

2012-08-24 Thread Vikas Rawal
> 
> 
> 
> See the fieldsets part.


The examples shown for fieldsets seem to divide the fields into
different groups. But in all the examples, fields still appear, within
each group, one after another, vertically.

Vikas

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



Re: Django-tables2

2012-08-24 Thread MattDale
It is just a very easy way to create html tables with one simple template 
tag that have features like sorting by column, easy, quick css etc. without 
using javascript at all.  There are times when this is easier than creating 
a table and customizing it.  I use it for general tables that don't need 
any ajax features.  Although I've lately been creating manual tables and 
using the "tablesorter.js" to handle quick sorting.  


On Friday, August 24, 2012 1:58:03 AM UTC-4, Alex Strickland wrote:
>
> On 2012/08/24 01:49 AM, MattDale wrote: 
>
> > I love django-tables2! 
>
> May I ask why? I'm not trolling, I'd like to know more about it. 
>
> -- 
> Regards 
> Alex 
>

-- 
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/-/OvDvrRqhel0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Context Help

2012-08-24 Thread Gregory Strydom

Thanks for taking the time to help out i really appreciate it :)

Im still a little confused so i think the best thing to do would be to 
start from scratch, going through the tutorial again, and again and taking 
things really slowly (slower thanks snails pace lol), and work through it 
step by step until i get a better understanding.

I think im getting frustrated as well because i kind of rushed through the 
tutorial as i am currently on a deadline with my company to get this 
project completed. I will just need to explain it is going to take a little 
longer than i expected and as i said take things very slowly and make sure 
i understand each step before moving on to the next.

What you guys said does make a lot more sense though, thanks again!

-- 
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/-/-H2wiyGfqxIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Context Help

2012-08-24 Thread Melvyn Sopacua
On 24-8-2012 10:09, Gregory Strydom wrote:

> I can understand that perfectly. What i cant understand is where do place 
> the P = Context() P['Name'] = "Fred".
> Does it go in the models file, Views file, html file, seperate file??

With Class Based Views this is a lot simpeler:

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google 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: Layout of widgets in admin form

2012-08-24 Thread Melvyn Sopacua
On 24-8-2012 12:15, Vikas Rawal wrote:
> I am new to django. I am trying to develop an application where I need to 
> work with the admin interface. The usual admin interface (for example in 
> the poll app of django tutorial) lays out the widgets vertically. How do I 
> change that?



See the fieldsets part.

> If I want to put two or three widgets side by side, customise 
> the width of each widget, etc, what should I do? 

Same thing, and set the HTML classes to something that gives them your
width.
-- 
Melvyn Sopacua

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



Re: Using Tag Filters in a generic view

2012-08-24 Thread Melvyn Sopacua
On 23-8-2012 18:56, miked wrote:

> The odd thing is that the parameter "record" when passed to the
> template tag file seems to resolve to the primary key of the object.

Nope, the expected thing is that record resolves to a model instance.

> I am expecting the parameter "record" to be a dictionary containing
> all fields within a record.

What part of the docs gave you that idea? Maybe it needs clarification.

> Is there anyway to get this within the template.

def attr_lookup(obj, attr):
  return getattr(obj, attr, "")
register.filter('attr_lookup', attr_lookup)

-- 
Melvyn Sopacua

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



Re: Context Help

2012-08-24 Thread Tom Evans
On Fri, Aug 24, 2012 at 9:09 AM, Gregory Strydom
 wrote:
> I'm at the end of  my rope lol.
>
> For the life of me i cant discern where you put Context definitions.
> Ive had a look at django tutorial and the documentation and unless im
> seriously overlooking something i cant find the information i need.
> I understand perfectly how it works.

If you understood perfectly, you wouldn't be asking these questions :)

>
> E.g:  P = Context()
> P['Name'] = "Fred"
> P["Age"] = "27"
>
> 
> 
> 
> 
> Hi my name is {{ P.Name }}
> 
> 
>
> I can understand that perfectly. What i cant understand is where do place
> the P = Context() P['Name'] = "Fred".
> Does it go in the models file, Views file, html file, seperate file??
>
> Im basically tearing my hair out in frustration as im sure its really simple
> but i just cant see it.
>
> If someone could someone please give an example or explain where i need to
> place it i would be extremely gratefull!!
>

Contexts are used when rendering templates. All function calls that
render templates also take two additional arguments, which can be used
to populate a context. Eg:

render_to_string(template_name, dictionary=None, context_instance=None)

The context_instance here is the Context you wish to use to render the
template. The key-value-pairs in the dictionary are merged into a
supplied context_instance, or used to create a new Context if none is
supplied.

Finally, there is a sub-class of Context called RequestContext. This
is a context that is created with a request object. It will step
through each context processor defined in
settings.TEMPLATE_CONTEXT_PROCESSORS, and call the functioned
specified there, passing the request as the only argument. The
dictionary returned from this function is then merged into the
context.

All of this is documented on a single page here:

https://docs.djangoproject.com/en/1.4/ref/templates/api/

So, what does this mean? Well, typically on a "full fat" web page,
you'll want to use a RequestContext, so that common variables - like
the currently logged in user - are automatically available in your
template. Therefore, in a view, you will commonly have a pattern like
this:

def myview(request):
  ctxt = RequestContext(request)
  return render_to_response("myapp/myview.html", {
'hello': 'world',
'testing': '123', }, context_instance=ctxt)

Inside the template itself, the context is now the global scope.
Therefore, you don't refer to the 'name' of the context, eg in your
example, "{{ P.Name }}" is incorrect; the context has a variable
called 'Name' in it, so "{{ Name }}" is the correct usage.

Cheers

Tom

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



Layout of widgets in admin form

2012-08-24 Thread Vikas Rawal
I am new to django. I am trying to develop an application where I need to 
work with the admin interface. The usual admin interface (for example in 
the poll app of django tutorial) lays out the widgets vertically. How do I 
change that? If I want to put two or three widgets side by side, customise 
the width of each widget, etc, what should I do? 

Vikas

-- 
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/-/8Hb_tlC6JIgJ.
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: database file doesn't increase in size

2012-08-24 Thread Melvyn Sopacua
On 24-8-2012 8:46, heni yemun wrote:

> When i create a user account, fill the fields with some value and save() it 
> in the database file *myfile.db* for example, the file doesn't show any 
> change in size. So how do i know if i'm actually saving it and can later 
> access the values?

Because save complains loudly if it didn't work. It's kind of like
crossing the street: if you make it without feeling pain, you can be
sure you weren't hit by a car. There's no need to check your clothes for
any evidence of the contrary.

The reason database files do not grow in size on every new record is
because some space is pre-allocated and space previously occupied by
deleted records is reused if it fits to prevent large holes (meaning
more seeks).
-- 
Melvyn Sopacua

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

2012-08-24 Thread Melvyn Sopacua
On 23-8-2012 20:15, Kurtis Mullins wrote:

> class Factory(models.Model):
> # Assuming suppliers and customers are just two sides of the same
> relationship
> suppliers = models.ManyToManyField("self", related_name="customers")
> 
> Then simply query accordingly:
> 
> factory_a = Factory.objects.create()
> factory_b = Factory.objects.create()
> factory_c = Factory.objects.create()
> factory_b.customers.add(factory_a)
> factory_c.suppliers.add(factory_a)

Just a "heads up". This works as long as you only have factories. If you
add other entities like "exporters" and "wholesalers" you're going to
need generic relations:


-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google 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: Not sure how to describe issue/behavior with Form -- so here's code & YouTube video

2012-08-24 Thread Tom Evans
On Fri, Aug 24, 2012 at 9:37 AM, Barry Morrison  wrote:
> Code: http://dpaste.org/az8Nb/
> Video http://www.youtube.com/watch?v=XFSb044UkPs=youtu.be
>
> so first action, I click + which adds new, hitting cancel, takes me back to
> the view displaying all the news events
> next action, I hit + again, adds new news event...this time I browse for an
> image, again, I click cancel, takes me back to the view of all news events,
> but you see now an empty news event has been created
> next action, I hit + again, add a new image, hit submit. success_url takes
> me go the view of all events, this time it created the form I submitted and
> created another empty one
>
> The function in views.py "add_news_item" is not set up in the URL, but it
> does support the cancel on the form action. The video posted is using that
> view for the URL.  With the 'CreateView' in the URL, canceling the form will
> create an empty field in the database.
>
> Any help/guidance would be greatly appreciated!!
>
> Thanks!

I've not watched your video. I also have no idea what crispy forms
are, or what django form attributes are created using that syntax.
However…

Your model definition allows an empty form to be valid - none of those
fields are required AFAICT. Therefore, submitting an empty form using
the cancel button is being allowed to proceed. Therefore your check on
whether "cancel" was submitted is not working.

Put some debug here:

http://dpaste.org/az8Nb/#l28

Output what "submit" is, and all values in request.POST.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: httpresponse from stand alone script

2012-08-24 Thread Tom Evans
On Fri, Aug 24, 2012 at 9:47 AM, Blaxton  wrote:
> Hi
>
> I am calling a stand alone script from within views.py and
> was able to generate a html file with render_to_string in a stand alone
> script
> by include followng line:
> from django.template.loader import render_to_string

Why would you call an external script instead of importing a module
and calling a function? This seems sub-optimal.

>
> now , need to use "httpresponse" to generate a response.
> is it possible ? tried importing httpresponse and then use
> "return httpresponse" but got error from "return" as it is a stand alone
> script and not a funtion.
>
> currently, I am writing the result of stand alone script to a file and then
> render it
> in views.py.
>
> If I could pass some variables to views.py , or if I could use httpresponse
> in
> stand alone script , then there was no need of writing to a file and then
> render the file.
>
> Thanks for help
>

If there is some really really good reason why you are doing this,
then the standard way to get output from an external script is to have
the script write to stdout, not a file, and have your view function
read the input. Something like this in your view:

import subprocess
content = subprocess.check_output(["python", "/path/to/script", arg1, arg2 ])
return HttpResponse(content)

I still think there is no valid reason to call an external python
script, simply import and call the function you want.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-24 Thread Melvyn Sopacua
On 23-8-2012 15:20, Alexis Bellido wrote:

> And I got an error message telling me I couldn't concatenate an str to a 
> SimpleLazyObject. At this point the lazy loading logic hasn't got a real 
> User object yet.
> 
> To bypass the lazy loading, hence return a non-cache view for authenticated 
> users, I just needed to access some method or attribute to triggers an 
> actual query on the User object. I ended up with this, which I think it's 
> the simplest way:
> 
> bypass_lazyload = request.user.is_authenticated()

I agree that it's a POLA-violation and you should probably file a bug
report. I would expect that setting CACHE_MIDDLEWARE_ANONYMOUS_ONLY
would call request.user.is_anonymous() and as such load the lazy object.
For this to work, the cache middleware should probably be later in the
sequence then the authentication middleware.

-- 
Melvyn Sopacua

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



httpresponse from stand alone script

2012-08-24 Thread Blaxton
Hi

I am calling a stand alone script from within views.py and 
was able to generate a html 
file with render_to_string in a stand alone script
by include followng line:
from django.template.loader 
import render_to_string

now , need to use "httpresponse" to generate a response.
is it possible ? tried importing httpresponse and then use
"return httpresponse" but got error from "return" as it is a stand alone
script and not a funtion. 


currently, I am writing the result of stand alone script to a file and then 
render it
in views.py.

If I could pass some variables to views.py , or if I could use httpresponse in
stand alone script , then there was no need of writing to a file and then 

render the file.

Thanks for help

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



Not sure how to describe issue/behavior with Form -- so here's code & YouTube video

2012-08-24 Thread Barry Morrison
Code: http://dpaste.org/az8Nb/
Video http://www.youtube.com/watch?v=XFSb044UkPs=youtu.be

so first action, I click + which adds new, hitting cancel, takes me back to 
the view displaying all the news events
next action, I hit + again, adds new news event...this time I browse for an 
image, again, I click cancel, takes me back to the view of all news events, 
but you see now an empty news event has been created
next action, I hit + again, add a new image, hit submit. success_url takes 
me go the view of all events, this time it created the form I submitted and 
created another empty one

The function in views.py "add_news_item" is not set up in the URL, but it 
does support the cancel on the form action. The video posted is using that 
view for the URL.  With the 'CreateView' in the URL, canceling the form 
will create an empty field in the database.  

Any help/guidance would be greatly appreciated!! 

Thanks! 

-- 
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/-/bFlAdN00t0sJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using Tag Filters in a generic view

2012-08-24 Thread Carlos Palol
Hi, please share your view class.

Cheers



On Thursday, 23 August 2012 18:56:37 UTC+2, miked wrote:
>
> I have create a generic view and in that view I have specified 
> context_object_name of errata_id_list in this case.  This generic view is 
> tied to a query set of a model and in the view I specify the list of keys I 
> would like to display.  Here is a snippit from the template: 
>
>
> {% for record in errata_id_list %} 
>  
> {% for key in keys %} 
> {{record|dict_lookup:key}} 
> {% endfor %} 
> < 
> {% endfor %} 
>
> The template tag file dict_lookup is: 
>
> def dict_lookup(dict, key): 
>   return dict[key] 
> register.filter('dict_lookup',dict_lookup) 
>
>
> The odd thing is that the parameter "record" when passed to the template 
> tag file seems to resolve to the primary key of the object.  I am expecting 
> the parameter "record" to be a dictionary containing all fields within a 
> record. 
>
> Is there anyway to get this within the template.

-- 
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/-/S-03r-cVRjEJ.
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.



database file doesn't increase in size

2012-08-24 Thread heni yemun
Hi,
When i create a user account, fill the fields with some value and save() it 
in the database file *myfile.db* for example, the file doesn't show any 
change in size. So how do i know if i'm actually saving it and can later 
access the values?  Or is there another problem i should deal with first? 
THANK YOU!!

-- 
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/-/PAsutRO3wfwJ.
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.



After form validation, need to post and call a perl program to display to a log file

2012-08-24 Thread Pervez Mulla
Hi,

I have written code for form validation for different filed .

Once validation happened (its working good), I wanna call perl script to
disply it content to lof file ...


How can I do this ..??

Please help me
Pervez

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