On Wed, Dec 8, 2010 at 10:49 AM, JeffH wrote:
> So I'm working along, everything's humming fine. Then I try to add a
> record via the admin, and get the following:
>
> TemplateSyntaxError at /admin/expert/expertresponse/add/
> Caught AttributeError while rendering: 'unicode' object has no
> attribute 'date'
>
> [snip]
>
> Template error
>
> In template c:\python26\lib\site-packages\django\contrib\admin
> \templates\admin\includes\fieldset.html, error at line 12
> Caught AttributeError while rendering: 'unicode' object has no
> attribute 'date'
> 2 {% if fieldset.name %}{{ fieldset.name }}{% endif %}
> 3 {% if fieldset.description %} class="description">{{ fieldset.description|safe }}{% endif %}
> 4 {% for line in fieldset %}
> 5
> 6 {{ line.errors }}
> 7 {% for field in line %}
> 8 endif %}>
> 9 {% if field.is_checkbox %}
> 10 {{ field.field }}{{ field.label_tag }}
> 11 {% else %}
> 12 {{ field.label_tag }}{{ field.field }}
>
> I can add records via a ModelForm without problem, it just doesn't
> work in the admin.
>
> As you probably surmised from the error, the admin is expecting a field
attribute of type date on your model object (line?). Anyway, what is
getting passed is an Unicode object, which obviously does not have the
attribute (field) it is looking for.
I would guess that the problem lies somewhere in your admin file
(admin.py). What are the contents of it?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
El Wed, 8 Dec 2010 20:00:42 +0100
Łukasz Rekucki escribió:
> 2010/12/8 Nuño Iglesias :
> >
> > What i'm trying to do is this:
> > {{ mystring | upper }}
> > to convert "mystring" into upper-case.
>
> AFAIR, there should be no spaces before or after "|":
> {{ variable|upper }}
>
>
Ups :-s
Thanks a lot, I have been 40 minutes reading about the marvellous
template system...getting crazy
Now I fell stupid...but very happy :)
Thanks a lot Łukasz
--
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.
Have you successfully installed django-extensions into python?
Here are the detailed instructions
http://code.google.com/p/django-command-extensions/wiki/InstallationInstructions
Fei
On Dec 8, 6:30 am, mongoose wrote:
> Hi all,
>
> I'm trying out django-command-extensions I want to use the dumpscript
> command but I don't understand what I'm supposed to do to set it up.
>
> How to use django-command-extentions dumpscript?
>
> Thanks
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
On Dec 7, 7:55 pm, dmitry b wrote:
> Hi,
>
> How do I use Django's FileField with autogenerated files? That is,
> these files aren't uploaded by a user, but rather are created on the
> fly. I've looked at ContentFile, but this class doesn't seem to have
> a way to attach a file name (the name is also computed at run-time
> based on some criteria). Do I need to write my own implementation of
> File for this or am I missing an existing class?
>
> Thanks
> Dmitry
Hello,
I'm not sure I understand the question so am making the following
assumptions. Sorry if this isn't what you are looking for.
1. You know how to access the generated content.
2. You want to serve the content as a file with a specific name.
For this example let's say your file is a CSV file with content in
FILE_CONTENT. You will need to set a few thing up in you http
response to serve up a proper csv file.
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename=%s' %
'MyRandomFileName'
response.write(FILE_CONTENT)
return response
You can set other header options like Expires, Content-Length, etc. in
this fashion.
Hope I helped.
Mark
--
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.
2010/12/8 Nuño Iglesias :
>
> What i'm trying to do is this:
> {{ mystring | upper }}
> to convert "mystring" into upper-case.
AFAIR, there should be no spaces before or after "|": {{ variable|upper }}
--
Łukasz Rekucki
--
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.
Hi, i think it's the first time i write to this list, so
Hello to everybody...¡¡
Well, now my problem.
I'm trying to use "template filters" in one of my templates.
What i'm trying to do is this:
{{ mystring | upper }}
to convert "mystring" into upper-case.
but Django is complaining:
TemplateSyntaxError at /
Could not parse the remainder:'| upper' from 'row.0 | upper'
I suppose I've forgotten to import something...but I cant find it.
Any help ?
Thanks.
Nuño
--
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.
OK - here's my 2 cents:
Django 1.2.1, Oracle 9.2.0.7
Cheers
Jirka
In [1]: from django.db import connections
In [2]: c = connections['oracle'].cursor()
In [3]: c.execute(r"SELECT 1 FROM DUAL WHERE 'A' LIKE TRANSLATE('A'
USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)")
---
Traceback (most recent call last)
/data/ig/webapps/ig/ in ()
/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py in
execute(self, query, params)
505 self._guess_input_sizes([params])
506 try:
--> 507 return self.cursor.execute(query,
self._param_generator(params))
508 except Database.IntegrityError, e:
509 raise utils.IntegrityError,
utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
: ORA-01425: escape character
must be character string of length 1
In [4]: c.execute("SELECT 1 FROM DUAL WHERE DUMMY LIKE TRANSLATE('X'
USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)")
---
Traceback (most recent call last)
/data/ig/webapps/ig/ in ()
/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py in
execute(self, query, params)
505 self._guess_input_sizes([params])
506 try:
--> 507 return self.cursor.execute(query,
self._param_generator(params))
508 except Database.IntegrityError, e:
509 raise utils.IntegrityError,
utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
: ORA-01425: escape character
must be character string of length 1
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
On 08/12/10 17:42, dgmyrs wrote:
> That's a simplified sql just as an example. The actual one I need the
> in clause is a lot more complex and can't be handled in the ORM.
>
[Are you _sure_? name__in=... is so much handier, django sorts it out
for you...]
Anyway, see also
http://code.djangoproject.com/browser/django/trunk/django/db/models/sql/where.py#L177
Build up a parameterised query string dynamically (eurgh, I know):
l = ('Restaurants','Fast Food',)
pquery = "SELECT id FROM app_category WHERE name IN (%s)" % ',
'.join(["%s"]*len(l))
Category.objects.raw(pquery, l)[0]
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
Hi,
I've written a custom Storage that uses WebDAV as its underlying
engine. When I save a file '/foo/bar/file.ext', I want it to be saved
under /foo/bar in the webdav filesystem. However, it seems that
FileField overrides the directory structure:
def generate_filename(self, instance, filename):
return os.path.join(self.get_directory_name(),
self.get_filename(filename))
where get_directory_name() is defined as
def get_directory_name(self):
return
os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(self.upload_to
I'm not really sure why FileField finds it appropriate to impose its
own directory structure on the underlying storage engine. But short
of creating a custom subclass of FileField and overriding
generate_filename and/or get_directory_name(), is there a different
way of preserving the original file location path?
Thanks
Dmitry
--
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.
Thanks Tom, worked like a charm.
So actually qs is a collection of results and I can iterate through
them. Good to know.
Cheers.
On Dec 7, 7:52 pm, Tom Evans wrote:
> On Tue, Dec 7, 2010 at 5:29 PM, mongoose wrote:
> > Hi all,
>
> > I have this in my model.py
> > def recipe_cost(self):
>
> > total = IngredientInfo.objects.filter(recipe =
> > self.id).aggregate(Sum('total')).values()
>
> > return total
>
> > Then in my admin.py I call that to display the cost.
> > class RecipeAdmin(admin.ModelAdmin):
> > list_display = ('title','recipe_cost')
>
> > I can see the cost but it's being returned like this:
> > [Decimal('500.00')]
>
> > But obviously I'd just want the value 500. What should I change?
>
> > Thanks
>
> What you are calling total isn't the total, its a ValuesQuerySet. You
> want to extract the value from there, and convert it into whatever
> format you want.
>
> Eg:
>
> def recipe_cost(self):
> qs = IngredientInfo.objects.filter(
> recipe=self.id).aggregate(Sum('total')).values()
> return unicode(qs[0])
>
> 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-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.
On 08-12-10 18:39, Tom Evans wrote:
> On Wed, Dec 8, 2010 at 4:52 PM, martvefun wrote:
>> Hello,
>>
>> I'd like to start some threads when the server launch to listen to
>> events (I'm doing message passing).
>>
>> To do so, I guess I should be using the __init__.py file at the root of
>> my project (by the way, what's the used of the other __init__.py files
>> in the apps)
>>
>> I've tried with a simple test by only having 'print "starting server"'
>> into the file and the result is :
>>
>> $ python manage.py runserver
>> starting server
>> starting server
>> Validating models...
>> 0 errors found
>>
>> Django version 1.2.3, using settings 'website.settings'
>> Development server is running at http://127.0.0.1:8000/
>> Quit the server with CONTROL-C.
>>
>> Why the file is executed twice ? I don't want to have twice the same
>> threads.
>>
>> Thank you
>>
>> mart
>>
>
> __init__.py files aren't executed at the start of programs, the
> presence of them denotes that a directory is a python module, and the
> __init__.py is executed when that module is first imported under a
> particular name.
>
> Do you have a structure like this:
>
> project
> ├── __init__.py
> ├── app1
> │ └── __init__.py
> └── app2
> ├── __init__.py
> └── models.py
>
> and import from project.app2.models and from app2.models? That would
> cause app2's __init__.py to be executed twice.
>
> Cheers
>
> Tom
>
Yes the structure of my project is more or less like that but I've not
two but 6 apps all with 'from django.db import models' in models.py
In several model (more than two), I'm using foreign keys to different
models.
For now the site doesn't do much, I'm using the database created with
the models in other files in the project folder.
So if the __init__.py is not a good place to start operations at server
startup, where should I put it ?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
This. Form processing is one of those tedious things 90% of which is
the same in every form: field definition, display, validation, and
error handling/presentation.
Django takes care of the repetitive parts, and if you need to
customize the validation or display, allows you to do so while still
abstracting away all the rest of the fiddly stuff.
If anything, manual form processing in Django would be overkill,
unless you have some special case that the form API simply can't
handle (e.g. nested formsets, although there are a few apps now that
enable that, IIRC)
On Dec 8, 12:14 pm, Wayne Smith wrote:
> It is important to distinguish between display and functionality with
> forms. What I mean is, using the forms does not mean you have to render
> (display) them the way Django has it set up by default. I always use the
> Form API, and if I need custom validation on a field or the entire form, I
> override the appropriate clean method. I pass the widget argument if I want
> a different widget.
>
> IMO, one of the best things about Django is the ease in which I can
> customize its parts but still leverage its functionality.
>
> On Wed, Dec 8, 2010 at 10:36 AM, christian.posta
> wrote:
>
> > Do django developers use the Form API any time form elements need to
> > be displayed to users? Or do you just code the form yourself in the
> > templates and manually process them for smaller forms?
>
> > In general, is it always better to use the Form API for any form you
> > display, regardless how simple, because of the built-in functionality
> > provided by django, or is it overkill?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
That's a simplified sql just as an example. The actual one I need the
in clause is a lot more complex and can't be handled in the ORM.
On Dec 8, 11:40 am, Tom Evans wrote:
> On Wed, Dec 8, 2010 at 5:21 PM, dgmyrs wrote:
> > Hi, I am trying to work with an in clause in my sql in a raw sql
> > statement. A simplified example:
>
> >
> Category.objects.raw('select * from app_category where name
> in(\'Restaurants\',\'Fast Food\')')[0]
> >
> >
>
> > So that works fine with the in clause hard coded in there, and I could
> > simply build that sql string, but I am wondering if there is a way to
> > use the parameters argument of raw? I tried using a list with the
> > strings, and just a string itself with the escaped quotes, but
> > couldn't get either to work.
>
> > Thanks
>
> Why use raw? Why not just use the ORM?
>
> Category.objects.filter(name__in=['Restaurants', 'Fast Food'])
>
> 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-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.
On Wed, Dec 8, 2010 at 5:21 PM, dgmyrs wrote:
> Hi, I am trying to work with an in clause in my sql in a raw sql
> statement. A simplified example:
>
>
Category.objects.raw('select * from app_category where name
in(\'Restaurants\',\'Fast Food\')')[0]
>
>
>
> So that works fine with the in clause hard coded in there, and I could
> simply build that sql string, but I am wondering if there is a way to
> use the parameters argument of raw? I tried using a list with the
> strings, and just a string itself with the escaped quotes, but
> couldn't get either to work.
>
> Thanks
>
Why use raw? Why not just use the ORM?
Category.objects.filter(name__in=['Restaurants', 'Fast Food'])
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-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.
On Wed, Dec 8, 2010 at 4:52 PM, martvefun wrote:
> Hello,
>
> I'd like to start some threads when the server launch to listen to
> events (I'm doing message passing).
>
> To do so, I guess I should be using the __init__.py file at the root of
> my project (by the way, what's the used of the other __init__.py files
> in the apps)
>
> I've tried with a simple test by only having 'print "starting server"'
> into the file and the result is :
>
> $ python manage.py runserver
> starting server
> starting server
> Validating models...
> 0 errors found
>
> Django version 1.2.3, using settings 'website.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
>
> Why the file is executed twice ? I don't want to have twice the same
> threads.
>
> Thank you
>
> mart
>
__init__.py files aren't executed at the start of programs, the
presence of them denotes that a directory is a python module, and the
__init__.py is executed when that module is first imported under a
particular name.
Do you have a structure like this:
project
├── __init__.py
├── app1
│ └── __init__.py
└── app2
├── __init__.py
└── models.py
and import from project.app2.models and from app2.models? That would
cause app2's __init__.py to be executed twice.
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-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.
Hello,
I'd like to start some threads when the server launch to listen to
events (I'm doing message passing).
To do so, I guess I should be using the __init__.py file at the root of
my project (by the way, what's the used of the other __init__.py files
in the apps)
I've tried with a simple test by only having 'print "starting server"'
into the file and the result is :
$ python manage.py runserver
starting server
starting server
Validating models...
0 errors found
Django version 1.2.3, using settings 'website.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Why the file is executed twice ? I don't want to have twice the same
threads.
Thank you
mart
--
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.
Hi, I am trying to work with an in clause in my sql in a raw sql
statement. A simplified example:
>>>Category.objects.raw('select * from app_category where name
>>>in(\'Restaurants\',\'Fast Food\')')[0]
So that works fine with the in clause hard coded in there, and I could
simply build that sql string, but I am wondering if there is a way to
use the parameters argument of raw? I tried using a list with the
strings, and just a string itself with the escaped quotes, but
couldn't get either to work.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
It is important to distinguish between display and functionality with
forms. What I mean is, using the forms does not mean you have to render
(display) them the way Django has it set up by default. I always use the
Form API, and if I need custom validation on a field or the entire form, I
override the appropriate clean method. I pass the widget argument if I want
a different widget.
IMO, one of the best things about Django is the ease in which I can
customize its parts but still leverage its functionality.
On Wed, Dec 8, 2010 at 10:36 AM, christian.posta
wrote:
> Do django developers use the Form API any time form elements need to
> be displayed to users? Or do you just code the form yourself in the
> templates and manually process them for smaller forms?
>
> In general, is it always better to use the Form API for any form you
> display, regardless how simple, because of the built-in functionality
> provided by django, or is it overkill?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
Should your relationship be Many-to-Many I found this to be very
helpful:
Autocomplete manytomany widget for admin panel
http://djangosnippets.org/snippets/1365/
On Dec 7, 1:29 pm, Heigler wrote:
> If you can't use raw_id_fields i guess you should write that view and
> use javascript to search inside the view.
>
> Can you use a auto complete approach instead a drop down menu? If you
> can, my suggestion is to use a jquery plugin to do the hard
> work:http://docs.jquery.com/Plugins/autocomplete
--
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.
that use django-template* app .. can change it.
On Wed, Dec 8, 2010 at 12:30 AM, derek wrote:
> The button on the first page of http://www.django-projector.org/ says
> "Sing up for the demo project". Makes a refreshing change from the
> usual getting started red-tape ;)
>
> On Dec 7, 6:59 am, zodman wrote:
>> django-projector
>>
>>
>>
>> On Wed, Nov 10, 2010 at 2:05 PM, Toby Champion
>> wrote:
>> > I don't know of a Django-based issue tracker that's in active
>> > development, but I'd suggest you first try using a web-based, hosted
>> > tool. If your project is simple enough, something
>> > likehttp://www.unfuddle.com/
>> > might meet your needs. Accounts are free for very small projects, and
>> > include a SVN or Git repository. Otherwise Trac, which is of course
>> > used for tracking issues in Dango itself athttp://code.djangoproject.com/,
>> > so at least you know there's knowledge in the community. It's written
>> > in Python, too, so if you enjoy working in Python even without Django,
>> > you're onto a winner.
>>
>> > On Nov 10, 12:12 am, Joakim Hove wrote:
>> >> Hello,
>>
>> >> I am setting up a bug/issue tracker - the project is quite small and I
>> >> do not have complex needs. As I enjoy working with Django I was
>> >> looking for a Django based solution. Can someone reccomend a Django
>> >> based issue tracker?
>>
>> >> In case I fail finding something based on Django I think I will use
>> >> Trac which seems quite nice.
>>
>> >> Joakim
>>
>> > --
>> > 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
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> Andres Vargaswww.zodman.com.mx
>
> --
> 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.
>
>
--
Andres Vargas
www.zodman.com.mx
--
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.
So I'm working along, everything's humming fine. Then I try to add a
record via the admin, and get the following:
TemplateSyntaxError at /admin/expert/expertresponse/add/
Caught AttributeError while rendering: 'unicode' object has no
attribute 'date'
[snip]
Template error
In template c:\python26\lib\site-packages\django\contrib\admin
\templates\admin\includes\fieldset.html, error at line 12
Caught AttributeError while rendering: 'unicode' object has no
attribute 'date'
2 {% if fieldset.name %}{{ fieldset.name }}{% endif %}
3 {% if fieldset.description %}{{ fieldset.description|safe }}{% endif %}
4 {% for line in fieldset %}
5
6 {{ line.errors }}
7 {% for field in line %}
8
9 {% if field.is_checkbox %}
10 {{ field.field }}{{ field.label_tag }}
11 {% else %}
12 {{ field.label_tag }}{{ field.field }}
I can add records via a ModelForm without problem, it just doesn't
work in the admin.
--
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.
Do django developers use the Form API any time form elements need to
be displayed to users? Or do you just code the form yourself in the
templates and manually process them for smaller forms?
In general, is it always better to use the Form API for any form you
display, regardless how simple, because of the built-in functionality
provided by django, or is it overkill?
--
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.
On Dec 8, 3:20 pm, gunnar wrote:
> Dear group,
>
> I run django 1.2 on windows on the development server.
>
> I set up a login site via the standard django login view. The user is
> then redirected to a site built from a base template. The view that
> calls the base template is only available to logged-in users (via the
> @login_required decorator) - otherwise, the user is redirected to the
> login site. This part works.
>
> However, when I try to access {{user.username}} from within the
> template, I find that it is empty. is_authenticated returns false.
>
> What am I doing wrong?
>
> Gunnar
You're probably simply not sending the user object to the template.
You need to either send it explicitly in the context, or ensure the
`auth` context processor is active and you're using RequestContext.
--
DR.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
Dear group,
I run django 1.2 on windows on the development server.
I set up a login site via the standard django login view. The user is
then redirected to a site built from a base template. The view that
calls the base template is only available to logged-in users (via the
@login_required decorator) - otherwise, the user is redirected to the
login site. This part works.
However, when I try to access {{user.username}} from within the
template, I find that it is empty. is_authenticated returns false.
What am I doing wrong?
Gunnar
--
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.
While I haven't worked with formsets, this line doesn't look correct:
formset = ClientFormSet(request.POST, request.FILES,
queryset=Client.objects.get(pk=client_id))
mainly due to a parameter named queryset being passed a model object,
instead of a queryset of model objects. It would seem that you want
queryset=Client.objects.filter(pk=client_id) to achieve the same
result.
Then again, I could be wildly off.
--
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.
tanks !
the filter urlencode did the trick.
--
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.
Either its age - the scotch - or some combination of both, but I am
having problems with a SIMPLE formset. (its my first).
On my formset I get an AttributeError - 'Client' object has no
attribute 'ordered'... .but I dont have an attribute of that
anywhere I tried changing from a "get" to a "raw" but still
get a (similar) message.
My code is :
(models.py)
class Client(models.Model):
title = models.CharField(max_length=3, choices=TITLE_CHOICES)
firstname = models.CharField(max_length=50)
lastname = models.CharField(max_length=50)
mobilenumber = models.CharField(max_length=50)
phonenumber = models.CharField(max_length=50)
email = models.CharField(max_length=50)
street = models.CharField(max_length=50)
city = models.CharField(max_length=50)
state = models.CharField(max_length=10, choices=STATE_CHOICES)
class Meta:
ordering = ('lastname','firstname')
unique_together = ('firstname', 'lastname','mobilenumber')
def __unicode__(self):
return self.id
I have a forms.py containing
ClientFormSet = modelformset_factory(Client, extra=0, max_num=1)
In my view.py" I have the following... which is getting called and is
what generates the error
def c4(request, client_id=None):
if client_id == None:
if request.method == 'POST':
formset = ClientFormSet(request.POST, request.FILES)
if formset.is_valid():
formset.save()
clients = Client.objects.all()
return SortableGrid(request,
clients).render_to_response("mylibrary/real.html")
else:
formset = ClientFormSet(request.POST, request.FILES)
else:
if request.method == 'POST':
formset = ClientFormSet(request.POST, request.FILES,
queryset=Client.objects.get(pk=client_id))
if formset.is_valid():
formset.save()
clients = Client.objects.all()
return SortableGrid(request,
clients).render_to_response("mylibrary/real.html")
else:
formset = ClientFormSet(request.POST, request.FILES,
queryset=Client.objects.get(pk=client_id))
return render_to_response("4.html", {
"formset": formset,
})
My "4.html" contains
{{ formset.management_form }}
{% for form in formset.forms %}
{{ form.id }}
{{ form.id }}
{{ form.firstname }}
{{ form.lastname }}
{% endfor %}
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
100% fixed. I was calling save() on the form twice, once in form_capture and
once in form_errors.
:(
On Wed, Dec 8, 2010 at 12:34 PM, Sithembewena Lloyd Dube
wrote:
> 50% solved - I passed request.FILES into the form's constructor as
> indicated below:
>
> http://docs.djangoproject.com/en/1.2/topics/http/file-uploads/
>
> I then accessed the file as follows:
>
> attachment = request.FILES['attachment']
>
>
> Only problem left is to figure out why the form is posting twice. ideas
> please?
>
> Thanks.
>
>
> On Wed, Dec 8, 2010 at 12:02 PM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>> Hi all,
>>
>> I have a contact form that is supposed to save a message as well as a file
>> upload. When I use the admin site, I can save a contact record with a file
>> upload of any type.
>>
>> However, saving from the 'front end' of my web application causes some
>> strange behaviour - the file is not uploaded, and the contact record is
>> saved twice as seen from the admin site.
>>
>>
>> My code is as follows:
>>
>> BEGIN
>> CODE---
>> *html template:*
>>
>> > enctype="multipart/form-data">{% csrf_token %}
>> > width="100%">
>>
>> Message
>> {{ form.message }}
>>
>>
>> Upload
>> File:
>> {{ form.attachment }}
>>
>>
>> > value="Submit Request" />
>>
>>
>>
>>
>> *view*:
>>
>> @csrf_protect
>> def contact_us(request):
>> form = form_capture(request)
>> return render_to_response('front_end/standard_pages/contactus.html',
>> {'form': form, }, context_instance=RequestContext(request))
>>
>> *the form_capture function (extra module named functions.py - keeps all
>> my custom functions)*:
>>
>> def form_capture(request):
>> if request.method == 'POST':
>> form = ContactForm(request.POST)
>> if form.is_valid():
>>message = form.cleaned_data['message']
>>attachment = form.cleaned_data['attachment']
>>form.save()
>> else:
>> form = ContactForm()
>> return form
>>
>> *the form (forms.py):*
>>
>> class ContactForm(ModelForm):
>> class Meta:
>> model = Contact
>> message = forms.CharField(widget=forms.Textarea(attrs={'cols': 60,
>> 'rows': 10, 'class': 'mceNoEditor'}))
>> attachment = forms.FileField(required=False,
>> widget=forms.FileInput())
>>
>> *the Contact model (models.py):*
>>
>> class Contact(models.Model):
>>
>> message = models.TextField(max_length=500)
>> attachment = models.FileField(upload_to='attachments', blank=True)
>>
>> def __unicode__(self):
>> return self.message[:10] + '...'
>>
>> class Meta:
>> verbose_name_plural = "Contact Messages"
>>
>> END
>> CODE---
>>
>> Any ideas why saving a record from the contact form posts twice, and why
>> the file attachment is not uploaded?
>>
>> Thanks!
>> --
>> Regards,
>> Sithembewena Lloyd Dube
>>
>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
--
Regards,
Sithembewena Lloyd Dube
--
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.
On 8 déc, 10:13, Keats wrote:
> hi,
> How i can add it then ?
>
> i was thinking that the problem is "?" because :
It is. Please refer to the relevant RFC: the question mark is a
reserved character used to specify the beginning of a querystring. If
you want it to be part of the url itself, you do have to properly
quote it (using django.utils.http.urlquote or the corresponding
template tag).
> id="addReplyForm" name="addReplyForm">
> works perfectly any other characters in the topic_name part seems to
> work and since i'm only using : (.*) i didn't see how it could be an
> URL mismatch matter because for me (.*) means match everything ...
The url regexp is matched against the "path" part of the url - the
querystring is ignored at this point.
--
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.
50% solved - I passed request.FILES into the form's constructor as indicated
below:
http://docs.djangoproject.com/en/1.2/topics/http/file-uploads/
I then accessed the file as follows:
attachment = request.FILES['attachment']
Only problem left is to figure out why the form is posting twice. ideas
please?
Thanks.
On Wed, Dec 8, 2010 at 12:02 PM, Sithembewena Lloyd Dube
wrote:
> Hi all,
>
> I have a contact form that is supposed to save a message as well as a file
> upload. When I use the admin site, I can save a contact record with a file
> upload of any type.
>
> However, saving from the 'front end' of my web application causes some
> strange behaviour - the file is not uploaded, and the contact record is
> saved twice as seen from the admin site.
>
>
> My code is as follows:
>
> BEGIN
> CODE---
> *html template:*
>
> enctype="multipart/form-data">{% csrf_token %}
> width="100%">
>
> Message
> {{ form.message }}
>
>
> Upload File:
> {{ form.attachment }}
>
>
> value="Submit Request" />
>
>
>
>
> *view*:
>
> @csrf_protect
> def contact_us(request):
> form = form_capture(request)
> return render_to_response('front_end/standard_pages/contactus.html',
> {'form': form, }, context_instance=RequestContext(request))
>
> *the form_capture function (extra module named functions.py - keeps all my
> custom functions)*:
>
> def form_capture(request):
> if request.method == 'POST':
> form = ContactForm(request.POST)
> if form.is_valid():
>message = form.cleaned_data['message']
>attachment = form.cleaned_data['attachment']
>form.save()
> else:
> form = ContactForm()
> return form
>
> *the form (forms.py):*
>
> class ContactForm(ModelForm):
> class Meta:
> model = Contact
> message = forms.CharField(widget=forms.Textarea(attrs={'cols': 60,
> 'rows': 10, 'class': 'mceNoEditor'}))
> attachment = forms.FileField(required=False, widget=forms.FileInput())
>
> *the Contact model (models.py):*
>
> class Contact(models.Model):
>
> message = models.TextField(max_length=500)
> attachment = models.FileField(upload_to='attachments', blank=True)
>
> def __unicode__(self):
> return self.message[:10] + '...'
>
> class Meta:
> verbose_name_plural = "Contact Messages"
>
> END
> CODE---
>
> Any ideas why saving a record from the contact form posts twice, and why
> the file attachment is not uploaded?
>
> Thanks!
> --
> Regards,
> Sithembewena Lloyd Dube
>
--
Regards,
Sithembewena Lloyd Dube
--
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.
Hi all,
I have a contact form that is supposed to save a message as well as a file
upload. When I use the admin site, I can save a contact record with a file
upload of any type.
However, saving from the 'front end' of my web application causes some
strange behaviour - the file is not uploaded, and the contact record is
saved twice as seen from the admin site.
My code is as follows:
BEGIN
CODE---
*html template:*
{%
csrf_token %}
Message
{{ form.message }}
Upload File:
{{ form.attachment }}
*view*:
@csrf_protect
def contact_us(request):
form = form_capture(request)
return render_to_response('front_end/standard_pages/contactus.html',
{'form': form, }, context_instance=RequestContext(request))
*the form_capture function (extra module named functions.py - keeps all my
custom functions)*:
def form_capture(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
message = form.cleaned_data['message']
attachment = form.cleaned_data['attachment']
form.save()
else:
form = ContactForm()
return form
*the form (forms.py):*
class ContactForm(ModelForm):
class Meta:
model = Contact
message = forms.CharField(widget=forms.Textarea(attrs={'cols': 60,
'rows': 10, 'class': 'mceNoEditor'}))
attachment = forms.FileField(required=False, widget=forms.FileInput())
*the Contact model (models.py):*
class Contact(models.Model):
message = models.TextField(max_length=500)
attachment = models.FileField(upload_to='attachments', blank=True)
def __unicode__(self):
return self.message[:10] + '...'
class Meta:
verbose_name_plural = "Contact Messages"
END
CODE---
Any ideas why saving a record from the contact form posts twice, and why the
file attachment is not uploaded?
Thanks!
--
Regards,
Sithembewena Lloyd Dube
--
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.
hi,
How i can add it then ?
i was thinking that the problem is "?" because :
works perfectly any other characters in the topic_name part seems to
work and since i'm only using : (.*) i didn't see how it could be an
URL mismatch matter because for me (.*) means match everything ...
thanx.
--
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.
50 matches
Mail list logo