referencing a specific item in a list...

2009-04-09 Thread Walt

After extensive searching, I'm still unable to find a way to reference
individual items in a list without using a for loop.

For example, I have this basic code in my views.py:

project_list = Project.objects.all().order_by('-id')[:6]

t = loader.get_template('portfolio/index.php')
c = Context({
'project_list' : project_list,
})

Now, in my template file I want to be able reference the six
different elements in the list directly, without having to loop
through them. How can I do this?

I've tried project_list[1] but that just errors out.

Thanks,
Walt

-~

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



Re: referencing a specific item in a list...

2009-04-09 Thread Walt

Thank you! Works perfectly!

Major complaint about Django: some simple things like syntax
and complete API details are either missing from the documentation
or glossed over, a la the link you included. I would've taken from
that
to try my original "project_list[1]" since I thought it would be a
list,
not a method or attribute lookup...

Thanks again!
Walt

-~
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: formfield_for_foreignkey: how to know if we are modifyng an entry

2010-06-27 Thread Walt
I'm not sure if it works in this context but have you tried
self.instance.id?


Walt

-~

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



Admin calendar popups on datefield suddenly missing

2010-01-21 Thread Walt
Hi all,

I don't know of any changes I've made recently other than
checking out the latest django code but the date picker /
popup on all admin datefields has suddenly disappeared.

Any clues as to how to get this back or what might have
caused it to disappear in the first place?


Thanks,
Walt

-~
-- 
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: Admin calendar popups on datefield suddenly missing

2010-01-21 Thread Walt
On Jan 21, 10:28 am, Daniel Roseman  wrote:
>
> Do you have TinyMCE on the same admin page? And are you using Firefox
> 3.5+? If so it might be this bug:http://code.djangoproject.com/ticket/11967

No, I don't think this is the problem. First, I'm not using
TinyMCE on the app at all, secondly, the problem happens
across all browsers, and third the code to display the date
picker isn't even present in the source HTML for the admin
pages, so I think something happened server-side to turn
that feature off.

Thanks!
Walt

-~
-- 
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: Admin calendar popups on datefield suddenly missing

2010-01-21 Thread Walt
Okay, we're getting somewhere. It can find the JS file(s) just fine
and I see that the calendars are added dynamically. However, I'm
have found that it is generating a javascript error when the page
loads:

Error: gettext is not defined
Source File: http://tachamber.org/media/admin/js/calendar.js
Line: 26 [monthsOfYear: gettext('January February March April May June
July August September October November December').split(' '),]

Error: gettext is not defined
Source File: http://tachamber.org/media/admin/js/admin/DateTimeShortcuts.js
Line: 134 [today_link.appendChild(document.createTextNode(gettext
('Today')));]

Any ideas?

Walt

-~
-- 
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: Admin calendar popups on datefield suddenly missing

2010-01-21 Thread Walt
That line is there, but for some reason *that* is the broken link!

That at least gives me something to track down...

Thank you for your help!
Walt

-~
-- 
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: Admin calendar popups on datefield suddenly missing

2010-01-21 Thread Walt
Okay... The latest release of django that I downloaded has this:


A previous version that is currently working is this:


How can I modify or specify that path? And why would it have
changed?

Thanks,
Walt

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




Defining the queryset admin pages use for ForeignKey or ManyToMany fields

2010-01-28 Thread Walt
It seems like this should be possible, and this is the closest,
simplest
solution I can find in the documentation:

class InvoiceAdmin(admin.ModelAdmin):

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "books":
kwargs["queryset"] = Book.objects.filter(sold=False)
return db_field.formfield(**kwargs)
return super(InvoiceAdmin, self).formfield_for_foreignkey
(db_field, request, **kwargs)

But this does not work at all. I need to do this in many places
for a number of different forms, so it would be nice to be able
to specify the queryset for ForeignKey fields in a form without
completely recreating the admin form pages.

Thanks!
Walt

-~

-- 
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: limit_choices_to a value on a field in the same model

2010-03-14 Thread Walt
Here is an idea of what your forms.py should contain:

class AgencyForm(ModelForm):

class Meta:
model = Agency

def __init__(self, *args, **kwargs):
super(AgencyForm, self).__init__(*args, **kwargs)
if self.instance.id:
if self.instance.state_id:
counties =
County.objects.filter(state=self.instance.state_id)

county_field = self.fields['counties'].widget
county_choices = []
county_choices.append(('', '--'))
for county in counties:
county_choices.append((county.id, county.name))
county_field.choices = county_choices


Then in admin.py, make sure you have:

class AgencyAdmin(admin.ModelAdmin):
form = AgencyForm



Hope this helps,
Walt

-~

-- 
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: Need limit_choices_to help

2010-03-20 Thread Walt
Is this the type of solution you have in mind?

http://tinyurl.com/yaqjfx4


Walt

-~

-- 
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: Is it possible to change the width of the boxes displayed by the filter_horizontal in Django admin interface?

2010-03-23 Thread Walt
You'll need add a stylesheet Media class to your admin class:

class ResizeFilterAdmin(admin.ModelAdmin):
# 

class Media:
css = { 'all': ('/relative/path/to/supplemental.css'), }


Then, in that CSS file you'll need to specify the width of your
element:

/* by class */
.filtered {
width: 350px;
}

/* or by object id */
#id_yourfieldname_from {
width: 350px;
}

#id_yourfieldname_to {
width: 350px;
}



This should work. :-)

Walt

-- 
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: Is it possible to change the width of the boxes displayed by the filter_horizontal in Django admin interface?

2010-03-26 Thread Walt
I'm sorry I wasn't more clear, the class Media just gets
added to your existing admin class. The path to the css
should be the path that is appended to your SETTINGS.PY
media path to reach the css file. The class ResizeFilterAdmin
was just an example name.

In other words, if your media path is: /var/www/media
and your css file is stored in /var/www/media/css/bisite.css
then your Media entry would be:

css = { 'all': ('/media/css/bisite.css',)}

So the full entry would be:

class ProfileAdmin(admin.ModelAdmin):
search_fields = ('profile_name',)
ordering = ('profile_name',)
filter_horizontal = ('profile_test',)

class Media:
css = {
'all':('/media/css/bisite.css',)
}


Does that make more sense? Again, I apologize for the
miscommunication!

Thanks,
Walt

-~

-- 
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: Problems with model with optional FileField in Admin

2010-04-06 Thread Walt
Did you also specify null=True?


Walt

-~

-- 
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: Looking for a good Document Management System (DMS) to plug into my Django app

2011-10-18 Thread Walt
You should check out integrating with the Box.net API. I've written a
number
of applications for their site. They support previews of most common
file types.

Feel free to contact me directly if you want to see some simple code
examples
-- tufelkinder (at) gmail (dot) com


Walt

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

2011-04-16 Thread Walt
> searchterm = request.GET['q']

Shouldn't this be: request.GET.get('q','')


Walt

-~

-- 
You received this message because you are subscribed to the Google 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' object has no attribute 'render_context'

2011-04-16 Thread Walt
I'm not sure I know why your code is misbehaving, but any
particular reason you aren't using render_to_response instead
of template/context rendering?

http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response

It's much simpler!

Walt

-~

-- 
You received this message because you are subscribed to the Google 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 python, django user... having issues

2011-04-16 Thread Walt
Windows 64 does make things interesting, but just to summarize
what I do to install on Windows:

Install python2.5: http://www.python.org/download/releases/2.5.4/
Install latest apache: http://httpd.apache.org/download.cgi#apache22
Install mod_python for python 2.5:
http://archive.apache.org/dist/httpd/modpython/win/3.3.1/mod_python-3.3.1.win32-py2.5-Apache2.2.exe
Install your database of choice (postgresql 9.0.1/ mysql):
http://www.enterprisedb.com/products-services-training/pgdownload#windows
http://www.mysql.com/downloads/mysql/
Install the appropriate python connector:
http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.4.win32-py2.5-pg9.0.3-release.exe
http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.win32-py2.5.exe/download

I also usually install svn: http://www.sliksvn.com/en/download
svn co http://code.djangoproject.com/svn/django/trunk/

Add python's bin to your path, add django-admin.py to your path
and you should be good to go.

The reason for using 2.5 is that mod_python or windows and
the MySQL Python connector only support that version, at
least as far as I have been able to find.

Good luck,
Walt


-~

-- 
You received this message because you are subscribed to the Google 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 python, django user... having issues

2011-04-16 Thread Walt
I think you're hijacking this thread, yes?

Can you submit all the code for the models, please?

Perhaps start a new thread...

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

2016-10-03 Thread Walt
You can also check out the Python wrapper for pdftk.

https://github.com/revolunet/pypdftk

It allows you to take a pdf form and fill it dynamically and "flatten" it.

Aside from that, Weasyprint also works pretty well.


Walt



On Monday, October 3, 2016 at 8:05:43 AM UTC-4, M Hashmi wrote:
>
> Hi,
>
> I need some simple library to convert a simple quote form to PDF. I tried 
> xhtml2pdf and few others but need really simple process to use but creating 
> a fancy pdf.
>
> If anyone knows please let me know.
>
> Regards,
> Mudassar
>

-- 
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/a34bcc29-a455-455c-bc24-8651deb67c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.