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.
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.
You want to use an aggregation function:
http://docs.djangoproject.com/en/dev/ref/models/querysets/#aggregation-functions
On Tue, Dec 7, 2010 at 11:14 AM, Jagdeep Singh Malhi <
singh.malh...@gmail.com> wrote:
> hi
>
> I want to use mysql Query :
> Select sum(field_name) FROM table_name WHERE some condition.
>
> Is it possible without using raw queries in Django ?
> if yes, please 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-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.
>
> How does that look when you are building an object list in the Q( )...
> style format? Where I am hung up is finding syntax examples of how to
> do the functional equivalent of a sql where not exists clause.
>
> Is there a way to do this without using .extra() and using just normal
> django?
>
>
Look here:
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects
Basically, you specify the keywords just as you would in regular field
lookups, and you can use &, |, and ~ to AND, OR, or COMPLEMENT (negate) your
results.
--
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.
To fire off an action (method) after an object is saved, you want to listen
for its signal.
Check out http://docs.djangoproject.com/en/dev/topics/signals/
On Mon, Dec 6, 2010 at 11:28 PM, commonzenpython
wrote:
> hey guys, im trying to get a script to run, like a view after a user
> in the admin interface checks a box and saves the object, is there any
> way of accomplishing this without having to rewrite the add_view, and
> edit_view ?
>
> --
> 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.
>
> Thanks, that's fine, but I was wondering if there was a more scalable
> way. I have more fields than just "description", so it would be nice
> if they could be all saved with one method call, so I don't have to
> maintain this code in case I change the model.
>
>
If you have multiple fields describing your image, and you are concerned
that more fields will be added/removed at a later time and don't want to
fiddle with your Image model fields, then it would probably be prudent to
factor out these fields to their own model, and hold a relationship (1-to-1,
probably) from the image model to the description model.
> > By the way, your overridden save() method looks a bit odd. It needs to
> call
> > save() on its superclass as well.
>
> But I do:
> models.Model.save(self)
>
> Isn't that what you meant?
>
You're correct in that you call the superclass, I looked over it too
quickly. However, the way you are doing it won't pass any of the args or
kwargs up to the superclass, and will probably give you problems. Look here
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methodsto
get an example.
> And how do I get that information provided by the user?
> Something like:
> Image i = ImageUploadDetailsForm.save(commit=False)
> ?
>
You get the info from the user by accessing the values in request.POST,
which is a dictionary-like object with all the POST parameters. If you are
using a ModelForm, you might be able to get some things "automagically", but
you can always access them in request.POST no matter how the form is set
up.
--
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 Mon, Dec 6, 2010 at 4:42 PM, bc wrote:
> Is there any simple way to use django authentication/authorization to
> control access to an existing (not django) cgi?
>
> I could use subprocess.Popen to invoke the cgi after checking
> authorization, but the environment needs to be set up to look like a
> cgi call (setting QUERY_STRING, etc.). Is there a better way?
>
>
I don't know if you could do some special trick with an HttpRequest or some
kind of redirect from one view to hit the cgi script with the automatically
created (HttpRequest) data. I'm guessing the answer is no or more trouble
than it would be worth, but that's just a guess.
I would say you really have two options.
1. Implement the script in Python, and bring it in under Django.
2. Craft your own Http Request header with Python's libraries and point it
to the cgi script.
> --
> 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.
Then yes, in the clean() method of your Galeria form, you could check the
number of fotos present and then raise a ValidationError if it is too many,
along with a custom message for the user.
Is that what you wish to do?
On Mon, Dec 6, 2010 at 5:18 AM, Daniel Carvalho <idn...@gmail.com> wrote:
> On 12/06/2010 03:05 AM, Wayne Smith wrote:
> > It's hard to say, because I don't know what kind of "validation" or
> business
> > logic regarding it you are trying to accomplish/employ.
> >
>
>
> suppose I want a validation like this:
>
> the number of fotos in a galeria should be limited to a number, which
> depends on the user that created it (OR, depends on some values that are
> in the galeria object)
>
>
>
> > However, if you are wanting to ensure you validate a foto during a
> gallery
> > save, why not call an overridden fotos.save() from your custom
> > galeria.save()?
> >
>
>
--
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.
>
> Okay, honestly I believe it will be easier to go from scratch. However
> I'd still like to ask, since the idea of having an almost-done admin
> interface is very neat.
>
>
>
As the other reply indicates, that is a very tall order for a beginner. The
admin interface is functional for editing, but not necessarily the
prettiest. The beauty of the admin interface lies in the heavy lifting it
does for you, and the fact that it is easily extendable--you can override
any of its templates to provide extra functionality and/or your own look and
feel, without having to re-invent the wheel.
I would advise to use it and learn to tweak it. Once you finish and look
back, I think you will find you are glad you did.
> --
> 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.
> After the second form is done and valid, I would like to save the
> information that comes to it to Image, in the same row that has the id
> I was passing.
>
> How can I do this?
>
>
>
image.description = information user provided
image.save()
By the way, your overridden save() method looks a bit odd. It needs to call
save() on its superclass as well.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
On Mon, Dec 6, 2010 at 7:00 AM, Quetzacotl wrote:
> Hello, i want to make function that wraps all things related to
> comments, so there should be part that gets comments from database and
> part that checks if comment was added. Then i can simply write just
> one line of code in view where i want comments. Problem is that after
> successful comment post, view should make redirect, and as we know to
> redirect you need to return response instance. That one thing doesnt
> let me make wrap function for my comments, because i cant return
> response after post. thought I can make IF statement that checks if
> return value is response instance or not. But this is 4 lines of code
> instead of one, is there any other way?
>
> --
>
I must be missing something; why can't you return a response after a post?
When I run into a problem that doesn't appear to be easily solved, I often
check to make sure that I am not trying to combine separate pieces of logic
that shouldn't be combined. If you have 2 different things that need to
happen that cannot normally happen together, then maybe they shouldn't be
combined. Generally speaking, Django discourages the implementation of
business logic in the template.
Just a thought...
> 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.
It's hard to say, because I don't know what kind of "validation" or business
logic regarding it you are trying to accomplish/employ.
However, if you are wanting to ensure you validate a foto during a gallery
save, why not call an overridden fotos.save() from your custom
galeria.save()?
On Sun, Dec 5, 2010 at 1:25 PM, Daniel Carvalho wrote:
> hi
>
> I have this models:
>
>
> models.py:
>
> class Galeria(models.Model):
>...
> class Foto(models.Model):
>...
>galeria = models.ForeignKey(Galeria, null=False)
>
>
> admin.py:
>
> class FotoInline(admin.StackedInline):
>model = Foto
> class GaleriaAdmin(admin.ModelAdmin):
>inlines = [FotoInline, VideoInline]
> admin.site.register(Galeria, GaleriaAdmin)
>
>
>
> When a galeria is saved in the django administration, I want to perform
> a validation that involves his fotos. ..
>
> They are edited at the same time because I use inline in the admin.
>
>
> But cannot do that in Galeria.save, nor GaleriaAdmin.save_model, nor in
> a postsave event from galeria, because at the time it is called the
> fotos have not been saved yet.
>
> Where should I do it the validation?
> Have to define a GaleriaForm and do something there?
>
>
--
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 might want to use some logic involving anonymous users. See here:
http://docs.djangoproject.com/en/dev/topics/auth/#anonymous-users
On Sun, Dec 5, 2010 at 2:29 PM, andy wrote:
> Well you don't have to make the foreign key field required, that way
> comments belonging to guest users can have a blank foreign key
>
> Possibly you could also create a default guest user that is assign to
> comments made by guest users. I generally having my application
> depending on the creation of some default record so I would probably
> go for the first option.
>
> On Dec 5, 3:14 pm, robos85 wrote:
> > Hi,
> > I need to create comments system. Either guests and logged users can
> > comment. How can I do that?
> > I want to make a Foreign Key to User model but then, how to add gust's
> > comemnts? I could make it in 2 separate tables, but it would be nice
> > to have it in 1 table.
> >
> > Any ideas?
>
> --
> 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.
You can just add the html to your template (like ).
On Dec 5, 9:01 am, jc wrote:
> I need this codehttp://paste.pocoo.org/show/300846/to print a
> newline *before* each heading (essentially, wrapping it to the
> next line).
> Create another loop to do this or is there an easier way?
> Thanks,
> J.
--
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.
Sure. Just override the clean method for the field, or the whole form if
you wish. The built-in "default" validation done by Django doesn't handle
any logic; it just makes sure the format and type of each field is
appropriate.
On Dec 4, 2010 1:44 PM, "refreegrata" wrote:
> ok, thanks for the answer. I have a final question. The other way is
> in the __init__ set initial values in hidden fields, but if the user
> (malicious) edit the value in some of this fields the form is invalid,
> and the form comeback, but with the values edited for the user and the
> error messages. Can I reset the initial values for the hidden fields
> before of return the form?
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-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.
You shouldn't need to. How are you rendering your fields in your template?
On Dec 4, 2010 1:21 PM, "Patrick" wrote:
> I have 2 fields in my model:
> listing.name and listing.amount
>
> listing.name shows up in the template but listing.amount does not. Do
> I have to convert it to unicode first?
>
> Thanks,
> Patrick
>
> --
> 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.
> So if a user enters mydomain.com/main1/page1 --> check if main1 exists
> in the database --> render a menu of all pages which are linked to
> main1 --> show page1
So, I take it that if the user enters the above, and main1 does not
exist in the db, then you will raise an error (probably 404)?
If so, then like I mentioned, it should suffice to do something like:
r'^(?P\w+)/(?P\w+)$', 'view_to_pass_to'
to match against. It will then call the view you specify, and pass
the kwargs main_obj and page_obj. You can then look up these two
slugs in your db, check if they exist, find all page_objs that link to
main_obj, etc.
--
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.
> I want to do something like:
>
> .default = MyModel.objects.get(field=True)
>
> and raise an exception if don't find in the table a row with a field =
> True, but I don't have idea if something like this can be done.
>
I'm not always real good at understanding what someone wants.
However, it sounds as though you want to build a dynamic form (some
fields set dynamically, in response to certain conditions), but NOT
have the user mess with these things. The ways you mention to keep
the fields out of the form are the normal ways, but if you are going
to build a dynamic form without doing it in the POST view, etc., you
would normally do it with a custom __init__ method for the form. But
since the fields have been excluded, I think this would put you back
into the problem of marking form fields as hidden or something.
This kinda gets to be a circular problem primarily because the
function of a form is to accept user input, not hide it. I'm sure you
can do it, but it really just becomes a case (in my opinion) of
trying to pound a square peg into a round hole.
If I understand you correctly, my advice would be to validate the data
in clean(), and then to handle the object lookup in a pre_save()
signal catcher (in the model) and bail from there if the value isn't
found.
> Thanks for read and sorry for my newbies questions.
No apologies; we're all just talking and learning here ;) I hope I've
been able to contribute to the overall conversation.
--
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.
> I think the only thing that's bugging me is that you have to include
> the whole views.py in your url conf. Just feels less graceful than
> having the dispatcher nab what it needs on demand. I'll get over it.
>
Yeah, it does feel less graceful, doesn't it? That said, there might
be a way, I just don't know it.
I wouldn't see why you couldn't do it, just like before (specify the
string name)--I just didn't recall seeing that example in the docs for
class based views. Then again, I'm just trying to get my boss to move
us over to 1.2, so I haven't really looked at trunk or projected 1.3
stuff yet (like the new views).
--
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 3, 2:47 pm, Andrew Willey wrote:
> Forgot to in mention the actual question from the subject.
>
> Is there a "blessed" way to use class-based views with named urls in
> the
>
> > url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view',
> > name='name_for_convenience')
>
Oh, I see ( I think ;) ). I don't know, but I am guessing no.
However, you could decorate the view and use the decorator as some
sort of dispatcher, although I am not sure that would really give you
what you want.
--
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 3, 1:46 pm, Andrew Willey wrote:
> Can someone point me in the right direction here?
>
> How does one use class-based generic views and named URLs?
>
> Example (doesn't work):
>
> > urls.py
> > urlpatterns += patterns('myapp.views',
> > (r'^location/$', MyGenericView.as_view()),
> > )
> > views.py
> > class MyGenericView(TemplateView):
> > template_name = 'example.html'
>
> Now, I can make that work if I did this instead in
>
> > urls.py
> > from myapp.views import *
> > urlpatterns += patterns('',
> > (r'^location/$', MyGenericView.as_view()),
> > )
>
> That approach just feels weird, am I doing it wrong or is that the new
> normal?
No, that looks right to me. You import the view in the second case,
which means you can pass it like an object, as you do.
--
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 3, 11:59 am, refreegrata wrote:
> Ok, with hidden fields. But if the user manually, with some tool,
> change the value, thats will be a problem. For my safety I must to use
> the hidden fields and still keep the clean methods to overwrite any
> possible editing over the fields value. Originally the idea of this
> post was search a way to prevent the double assign(in the init and the
> clean methods), but apparently isn't possible.
>
> Thanks for the answer.
It isn't possible because you are, in actuality, asking two questions:
1. How can I set the value of a field on the server w/o client
interaction, and
2. Ensure that the client doesn't do something malicious
Number one is something that you should take care of in your view or
model (__init__, perhaps), and number 2 is a validation issue.
Since you said you didn't want to handle it in your POST processing,
which is the only way you can set it once and take care of both issues
(because you're doing it at the end of the chain), you will have to do
it twice, no matter what method/idea/framework you use.
--
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 3, 11:13 am, oscar widjaya wrote:
> It's for mysql
> it still does not work. I tried it with the following sql statement
> "SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%'
Well, I assume that the double % at the end of your query is
unintentional, as I don't think it should be there, but I'm not an sql
guru.
I just know that when I was having to craft some custom sql a couple
of months ago (using Postgres) I had to toy with the formatting a bit
to get it working. I also had to make sure I passed everything as a
str, and not unicode.
Maybe someone else how knows sql better will come along.
--
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.
Are you seeing anything? I mean, is the rest of the template
rendering fine?
There are only two things that I notice: the extra dict you pass with
the template_object_name (why not put it in info_dict?), and while I'm
not fluent in spanish, are you iterating through the variable
'object_list'? That is the name of the list that will have your
queryset objects after the generic view is executed.
--
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 3, 10:47 am, owidjaya wrote:
> It says incorrect date value.
>
What database are you using? I'm wondering if this is an issue of
formatting the sql correctly. Did you read the snippet near the
bottom of the page I linked to? Try:
SELECT * FROM some_table WHERE some_date LIKE "%s" % '2010%'
--
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 3, 2:11 am, Rob wrote:
> I want to make main categories on my site like:
> /main1/page1
> /main2/page2
> /main3/page3
It sounds like you have 3 views, and each one can pick from a pool of
categories. If this is correct, all you need to do is enter a line
for each view (main#), and pass the category (page#) as a variable to
the view, which can then do the lookup. You will use something like:
r'^main1/\w+/$'
which will pass all characters matching the regex (here, alphanumeric
chars) to the view you specify as a positional arg. You can also pass
them as a kwarg. Read here:
http://docs.djangoproject.com/en/dev/topics/http/urls/
>
> Is there a way to do something like: (r'^(.*)/(.*)/$', view), (I know
> this doesn't work)
To do something like that, instead of wildcarding everything greedily,
just pass a range of characters and symbols you will not accept
(whitespace, etc.) by using [^don't_accept_these] in your regex.
--
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.
Turn autoescape off (http://docs.djangoproject.com/en/dev/ref/
templates/builtins/?from=olddocs#autoescape) or mark it as safe by
using the "safe" template filter tag (lower on the page).
--
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 should be able to do it just as you mention, passing the query
string to cursor.execute().
See
http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly
Have you tried this? Are you getting an error? If so, what is 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.
Well, it depends on how sensitive and dynamic my_field needs to be.
You could always pre-populate the form with my_field set to a value,
and mark its input type as hidden (if it is not sensitive).
If you are working with a ModelForm, you could use one of the methods
here:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form.
Lastly, you could do it in the view during your processing of
request.POST, as you mention. Doing it in one of the validation
methods like you mention _should_ work, but I usually like to keep my
clean methods validation-only (and not use them to manipulate data).
Wayne
--
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.
Well, I'm guessing that what is displayed is what the unicode method
returns for the model that the ForeignKey points to (can't remember
for sure offhand, but I know that the admin interface works that
way). Of course, it might also be changing the display because you're
putting it in a TextField instead of a ChoiceField.
The whole point of a ForeignKey is to store a relationship between two
objects from different models. I really don't see how you would be
gaining anything by having users edit this data via a TextField. If
you don't like the widget that a form uses by default to select the
other model instance, you can change that fairly easily.
--
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 2, 4:40 am, muzhig wrote:
> Hi! I need to resize and make a stamp on uploaded images and only then
> save a model.
> I have a procedure, that processes incoming File:
>
> def processUploadedImage(file):
> img = Image.open(file)
> downsampleUploadedimage(img)
> stampUploadedImage(img)
> img.save(file, "JPEG")
>
> I tried to process UploadedFile directly from request.FILES, before
> constructing and validating form:
>
> ...
> processUploadedImage(request.FILES['file'])
> form = ImageUpload(request.POST, request.FILES)
> if form.is_valid(): #it always fails here, is_valid returns
> False, if
> I process UploadedFile
> ...
> else:
> redirect('/failed')
> ...
>
> After it failed, I also tried to process it in my ImageUpload.save()
> method:
> class ImageUpload(forms.ModelForm):
> class Meta:
> model = Image
> fields = ["title", "file"]
>
> def save(self,user,commit=True,**params):
> image = forms.ModelForm.save(self,commit=False)#construct an
> instance from form fields
> processUploadedImage(image.file)
>
> ...another fields initialization, such as user,
> publication_date and
> so on...
>
> #save into db(if commit is True) and return model instance
> return forms.models.save_instance(self, image,
> commit,construct=False)
> but it fails, when processUploadedImage tries to save image into file.
> It trows IOError "Bad file descriptor"..
>
> I know that I can process image after it saved into db, but I dont
> want server to do unnecessary work:
> read full sized file, copy it into storage, then again open file in
> starage, process it, save...
>
> I want beautyfull solution :)
> Upload -> Process ->Construct model -> Save
This, to me, is a perfect use case for a signal, most likely
pre_save. I am still not sure if you wish to save the original or the
processed image in your model, but you can do either by moving any
processing code to a method that gets triggered right before Django
tries to save your model. You don't need to override the save()
method of your model, but you could do it there, too, if you wish.
However, it looks like you are trying to do it by overriding the
save() method of your ModelForm, which I would not do in this case,
although you could make it work. The data you are trying to
manipulate has nothing to do with the form itself, or other fields in
the form, and thus (I think) would be better to do in one of the other
places I mentioned above.
--
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 2, 8:15 am, Sithembewena Lloyd Dube wrote:
> Hi all,
>
> I have an admin site enabled for my Django project. For some reason, some
> records are no longer displayed (they were displayed just fine before).
>
> Tried restarting the dev server to no avail.
>
> Please see the attached screen dump? What could be causing this?
Have you made any recent changes? Have you overridden any admin
templates? Did you specify anything in a Blog Admin class?
--
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 2, 10:03 am, bnabilos <bnabi...@gmail.com> wrote:
> Hello,
>
> I'm using a ForeignKey in my model and a Charfield in my form, when I
> save data everything works well but when I try to edit something, I
> get the ForeignKey ID in the Charfield.
>
> There is a way to display the label instead of the ID when editing an
> entry ?
>
> Thank you
So, let me get this straight--you have a ForeignKey from one model to
another, and you are editing that field by letting users enter text?
If so, why? You should be using some type of choice field.
Wayne
--
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,
Django has en and en-gb installed as languages in it's core. If a
django project wishes to use other locales such as 'en-au' or any of
the others listed in the subject line, how would one go about this
given that a language cannot be used unless it is in the core?
Essentially, how does one go about adding these languages to the core.
en-au and en-nz can essentially be a copy of en-gb.
Regards,
Wayne
--
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.
What is the code that you are using to save instances of the model
with?
--
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.
> When i try and add a project in the admin i get the error: 'unicode'
> object has no attribute '_committed' . I'm quite certain it's an issue
> with the image field.
Well, not to be coy, but you have a unicode string somewhere whose
_committed value you are trying to access. Problem is, the unicode
string does not have this particular value/method.
That's what I'm guessing without seeing the code, anyway.
Wayne
--
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.
Well, IMO any way that works and you feel comfortable supporting is
"okay". I can tell you what I did, but I don't know if it's any
better.
If I understand you correctly, you want to bring up the options a user
made previously and start from there instead of a blank slate. What I
did to accomplish this was to make an ajax call to the server, and
look up whatever identifiable information I had (user, form, etc.).
If it was in the database, I returned a form built from the previous
instance. If not, I returned a blank form. It brings in some
javascript (which is obviously not a part of Django, but is a common
component of web apps), but it made things quite a bit more
straightforward, IMO.
You can differentiate between the different options/fields (if
necessary) by using some guaranteed unique identifier and building
your form by hand, which you already appear to be doing.
HTH,
Wayne
On Aug 10, 11:07 am, vcarney <vincecar...@gmail.com> wrote:
> I've got a form with a multi checkbox that contains static choices.
> Using the forms.MultipleChoiceField with the CheckboxSelectMultiple
> widget worked fine for display. However, when displaying an edit form,
> the checkboxes did not hold state (all items were unchecked). To
> handle this I created a custom widget based on CheckboxSelectMultiple
> with the following:
>
> class CustomCheckboxSelectMultiple(SelectMultiple):
> def render(self, name, value, attrs=None, choices=()):
> if value is None: value = []
> has_id = attrs and 'id' in attrs
> final_attrs = self.build_attrs(attrs, name=name)
> output = [u'']
> # Normalize to strings
> if (isinstance(value, basestring)):
> value = value.replace('{','')
> value = value.replace('}','')
> value = value.replace('"','')
> value = value.split(',')
> str_values = set([force_unicode(v) for v in value])
> for i, (option_value, option_label) in
> enumerate(chain(self.choices, choices)):
> # If an ID attribute was given, add a numeric index as a
> suffix,
> # so that the checkboxes don't all have the same ID
> attribute.
> if has_id:
> final_attrs = dict(final_attrs, id='%s_%s' %
> (attrs['id'], i))
> label_for = u' for="%s"' % final_attrs['id']
> else:
> label_for = ''
>
> cb = CheckboxInput(final_attrs, check_test=lambda value:
> value in str_values)
> option_value = force_unicode(option_value)
> rendered_cb = cb.render(name, option_value)
> option_label =
> conditional_escape(force_unicode(option_label))
> output.append(u'<label%s>%s %s' %
> (label_for, rendered_cb, option_label))
> output.append(u'')
> return mark_safe(u'\n'.join(output))
>
> def id_for_label(self, id_):
> # See the comment for RadioSelect.id_for_label()
> if id_:
> id_ += '_0'
> return id_
> id_for_label = classmethod(id_for_label)
>
> --
> My customizations are:
>
> if (isinstance(value, basestring)):
> value = value.replace('{','')
> value = value.replace('}','')
> value = value.replace('"','')
> value = value.split(',')
>
> --
> Is there a better way to do this in django?
--
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 for your hint. It worked out pretty well.
Wayne
On May 2, 4:06 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On May 2, 4:29 am, Wayne <wayneshen...@gmail.com> wrote:
>
> > Hi,
>
> > We are trying to customize Django admin change list displaying model
> > objects. We want to add two buttons (Change, delete) to each row of
> > the record, something very similar to "Add" and "Change" buttons on
> > application list beside the model name. Could somebody give us some
> > hint on this? The "list_display" can only take existing fields, but
> > not the extra buttons we want to add, right? We do not want to provide
> > user with batch admin actions option. That is why we want to add
> > action to each row. Drop down actions menu is not our design
> > preference.
>
> > Thanks for your help.
>
> > Wayne
>
> The docs explain how you can use arbitrary ModelAdmin methods in
> list_display, which will do what you
> want.http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#django.contri...
> --
> 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
> athttp://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.
Hi,
I am looking for the answer as well. I came across this tutorial with
some sample code.
http://lincolnloop.com/assets/Customizing_the_Django_Admin-EuroDjangoCon09.pdf
page 59.
However, I don't want to create new view, but just modify the display
urls. So if somebody could give any hint, that would be great.
Thanks,
Wayne
On May 4, 4:23 am, akonsu <ako...@gmail.com> wrote:
> hello,
>
> by default an admin url for a model looks like this:
>
> http:///admin///...
>
> is there a way to change it? for different models i need to have
> different url structure. say, i want to replace "/admin/ name>" with something else.
>
> ModelAdmin.get_urls()? the documentation is not very helpful for me. i
> do not understand how i can use get_urls(). in particular, i do not
> have any custom views in my admin. and the docs only explain how to
> use get_urls() to hook up views.
>
> thanks for any help
> konstantin
>
> --
> 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.
--
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,
We are trying to customize Django admin change list displaying model
objects. We want to add two buttons (Change, delete) to each row of
the record, something very similar to "Add" and "Change" buttons on
application list beside the model name. Could somebody give us some
hint on this? The "list_display" can only take existing fields, but
not the extra buttons we want to add, right? We do not want to provide
user with batch admin actions option. That is why we want to add
action to each row. Drop down actions menu is not our design
preference.
Thanks for your help.
Wayne
--
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 Colin,
>>> Or any other templating language that's a bit looser in allowing a bit
>>> of logic to mix in with the presentation layer?
>>
>> http://kid-templating.org/
>
> Hasn't kid been superseded by genshi?
Firstly I'll say that I hate answers which say "don't try to do what
you're doing" as much as the next person (really, I do) but...
My first experiences with the Django template system were I think
quite similar to yours in that initially felt that it was too simple
and restrictive. However, as I started focusing more and more on
separation of concerns the templating became less and less of a
problem.
I eventually found that I was almost always better off (usually from a
maintenance perspective) doing the things I felt I wanted to do in the
templates further up the pipeline instead.
--
Regards,
Wayne
Blog: http://www.wkoorts.com
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
Hi Karen,
Many thanks for your reply.
Now our business requirements do not allow either empty string or null
value for this particular charField column (name =
models.CharField(max_length=512, null=False, blank=False)). How do you
suggest we should configure this field so that we can enforce not null
condition in the oracle database by using syncdb? Currently, after
creating those tables we need to manually modify the column properties
in Oracle to make them not null. Or Django Oracle backend deliberately
ignores null=false for charField creation?
Wayne
On Feb 26, 8:47 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Fri, Feb 26, 2010 at 5:35 PM, Wayne <wayneshen...@gmail.com> wrote:
> > Hi,
> > I try to create tables using Django models in our test oracle
> > database. I define a model with one column like this: name =
> > models.CharField(max_length=512, null=False, blank=False). After
> > running python manage.py syncdb, I found that column 'name' in the
> > generated table still allows null value in the column definition. I
> > understand that null = false is the default option. And I verified
> > that for other types of Django fields, null = false or no such option
> > at all would generate columns that do not allow null values in the
> > database. Is there particular reason why null = false is not enforced
> > for charField?
>
> Yes. Oracle does not distinguish between null and an empty string. So
> null=False applied at the database level would mean that you also could not
> store the empty string in that field, which would be quite different from
> what you would see running the same code on most other databases, where the
> empty string is a valid value for a NOT NULL character field.
>
> The behavior is documented, see the note
> here:http://docs.djangoproject.com/en/dev/ref/models/fields/#null. The note is
> perhaps not as clear as it could be about when the empty string is allowed
> for a field. That's a property of the field type (for example, empty strings
> are allowed for CharField but not a DateField), and is not in any way tied
> to the value of the field's blank option. The blank option, as noted in its
> description, is used for validation and is not applied at the database
> level.
>
> Karen
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.
Has anyone created an example of how to incorporate a GeoRSS feed they
would be willing to share? I have seen this link,
http://code.djangoproject.com/ticket/6547
and understand that "feed_extra_kwargs" and "item_extra_kwargs" were
added to allow this but I am drawing a blank on exactly how to
subclass the base class in order to add a lat and lon point.
Wayne
--
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 try to create tables using Django models in our test oracle
database. I define a model with one column like this: name =
models.CharField(max_length=512, null=False, blank=False). After
running python manage.py syncdb, I found that column 'name' in the
generated table still allows null value in the column definition. I
understand that null = false is the default option. And I verified
that for other types of Django fields, null = false or no such option
at all would generate columns that do not allow null values in the
database. Is there particular reason why null = false is not enforced
for charField?
My Django version is 1.1.1, Python version is 2.6, and oracle server
is 10g release 2.
Many thanks for your help.
Wayne
--
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 about to develop an admin interface using Django framework for
several web applications . By design, those applications will be
decentralized, which means that they may use different databases and
reside on different servers and they will talk to each other via web
services. We have our LDAP server and we plan to use it for
authentication purpose. The authorization part for each application
will be handled locally by individual application. We want to
authenticate user only once for the access to multiple applications as
long as the log-in session does not expire.
What tools and packages Django can provide to realize our design? What
is the best strategy for the development?
Many thanks in advance for your help and time.
Wayne
--
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.
> I want to convert a given regular object to json object. i.e. I want
> to create a function which takes the class object as parameter and it
> should return the json object.
Have a look at the built-in Django "serializers" module:
http://docs.djangoproject.com/en/dev/topics/serialization/#topics-serialization
Regards,
Wayne
--
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.
I have a database model in which the datetime entry of an item is
stored as a DateTimeField(). This datetime is stored as UTC. In one of
my views, which displays details for each entry, I am converting and
formatting the UTC time to PST.
I just started using generic views and for
"django.views.generic.date_based.archive_month" there is the
"date_field" argument which indicates the name of the DateTimeField in
the QuerySet's model that the view should use.
Is there an easy way to format this date_field to my local time zone
i.e. PST? I have also tried using the "date" and "time" filters within
the template itself, however, those are still UTC.
Any pointers would be appreciated.
Wayne
--
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.
>> Anybody know of an suitable application for this?
>>
>
> FileFields and ImageFields are by default stored on disk, with just a pointer
> stored in the db. For more examples, take a look at David Larlet's
> django-storages (http://code.welldev.org/django-storages/wiki/Home) and
> Justin Driscoll's ImageKit
> (http://bitbucket.org/jdriscoll/django-imagekit/wiki/Home), both of which
> should give you at least a starting point. With ImageKit, for example, you
> create a "spec" for your image fields, and part of the spec is a means of
> determining the filesystem storage location (including a method you can
> define if you need to).
>
> ---Peter Herndon
Note that you can do storage like /yy/mm/dd natively in Django without addons.
-Wayne
--
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.
What do you mean by "top ten"?
On 29/01/2010, at 20:53, CCC wrote:
hi,
I have two models:user,group,and they are manytomany,
class User(model.Model):
name = models.CharField(max_length=20)
class Group(models.Model):
name = models.CharField(max_length=20)
users = models.ManytoManyField(User)
now i want to get the top ten users who have the groups
,thanks for advance!
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-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.
Hi,
Many thanks for your reply.
I did the test and it seemed that our network is working fine and I
could telnet to the directory with "Connected" feedback. What other
things we could try next?
Wayne
>
> Ralf: $ telnet ldap.example.com 636
> Trying 1.2.3.4...
> Connected to ldap.example.com.
> Escape character is '^]'.
>
--
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 for the prompt reply. Yes, unique=True was the problem. Now I
passed the "run syncdb" and new tables were created. However, I still
could not "contact LDAP". Could somebody help me with this? There
could be many reasons so I want to start with loggings for Django-LDAP-
Groups.
Thanks!
My settings:
LDAP_SERVER = 'directory.X'
# If using SSL use these:
LDAP_PORT = 636
LDAP_URL = 'ldaps://:636'
SEARCH_DN = ''
SEARCH_FIELDS = ['sn','cn','uid']
BIND_USER = 'XX'
BIND_PASSWORD = 'X'
CERT_FILE = 'XX'
AUTHENTICATION_BACKENDS = (
'ldap_groups.accounts.backends.eDirectoryGroupMembershipSSLBackend',
'django.contrib.auth.backends.ModelBackend',
)
The traceback:
Environment:
Request Method: POST
Request URL: http://localhost:8080/admin/
Django Version: 1.1
Python Version: 2.6.2
Installed Applications:
['ldap_groups',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'DjangoTests.TestAdmin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
wrapper
196. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
inner
185. return self.login(request)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
login
300. user = authenticate(username=username,
password=password)
File "C:\Python26\lib\site-packages\django\contrib\auth\__init__.py"
in authenticate
37. user = backend.authenticate(**credentials)
File "C:\Python26\lib\site-packages\ldap_groups\accounts\backends.py"
in authenticate
161. l = self.bind_ldap(settings.BIND_USER,
settings.BIND_PASSWORD)
File "C:\Python26\lib\site-packages\ldap_groups\accounts\backends.py"
in bind_ldap
154. l.simple_bind_s(username, password)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py" in
simple_bind_s
206. msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py" in simple_bind
200. return self._ldap_call
(self._l.simple_bind,who,cred,EncodeControlTuples
(serverctrls),EncodeControlTuples(clientctrls))
File "C:\Python26\lib\site-packages\ldap\ldapobject.py" in _ldap_call
96. result = func(*args,**kwargs)
Exception Type: SERVER_DOWN at /admin/
Exception Value: {'desc': "Can't contact LDAP server"}
--
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.
> I'm new in django and i'm searching a book :
> django 1.0 web site development PDF
>
> can u help me please !
> in http://my.softarchive.net/search/?q=django=0=0 I could not
> download it.
>
> Is there another way ?
Absolutely:
http://www.packtpub.com/django-1-0-website-development-2nd-edition
It's a great book and deserves to not be pirated.
Regards,
Wayne
--
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,
Sorry for the late reply. Here is more info.
Django Verstion: 1.1
Oracle Version:Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit
Production
cx_oracle for Python 2.6.
Thanks for the help.
Wayne
On Dec 18, 10:26 am, Peter Herndon <tphern...@gmail.com> wrote:
> On Dec 18, 2009, at 10:15 AM, Peter Herndon wrote:
>
>
>
> > On Dec 17, 2009, at 7:32 PM, Wayne wrote:
>
> >> Hi,
>
> > This error arises from an inconsistency between the behavior of Oracle and
> > the behavior of PostgreSQL, as Mike noted. It works under Postgres. I'll
> > check with the dev list and see if this behavior difference is known, and
> > whether the fix is to never use unique=True on a TextField (a bug in my
> > code), or something that needs to be smoothed over in the SQL generation
> > for Oracle specifically (a bug in the underlying Django behavior).
>
> Hi Wayne,
>
> Can you tell me the Django version, the version of cx_Oracle, and the Oracle
> version? If this has been fixed for certain versions, that would make this
> error a moot point. And the developers are certainly going to ask. :)
>
> Thanks,
>
> ---Peter
--
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 tried to use djando-ldap-groups but got some errors from database
configuration. Could somebody shed some light on the possible problems
of my set up?
Thanks,
Our LDAP server is Sun One Server and the site is running in the
windows environment.
The settings.py file:
LDAP_SERVER = 'directory.XXX.xx'
# If using SSL use these:
LDAP_PORT = 636
LDAP_URL = 'ldaps://xxx.xxx:636'
SEARCH_DN = 'ou=people,dc=x,dc=x'
SEARCH_FIELDS = ['sn','cn','uid']
BIND_USER = ''
sBIND_PASSWORD = 'xx'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
) .
The error message came from command: python manage.py syncdb
Creating table ldap_groups_ldapgroup
Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
362, in execute_manager
utility.execute()
File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 195,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 222,
in execute
output = self.handle(*args, **options)
File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 351,
in handle
return self.handle_noargs(**options)
File "C:\Python26\lib\site-packages\django\core\management\commands
\syncdb.py"
, line 78, in handle_noargs
cursor.execute(statement)
File "C:\Python26\lib\site-packages\django\db\backends\util.py",
line 19, in e
xecute
return self.cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\oracle
\base.py", line 4
34, in execute
raise e
cx_Oracle.DatabaseError: ORA-02329: column of datatype LOB cannot be
unique or a
primary key
--
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.
>> > remember that an app can do a lot more than provide views.
>>
>> Explain this one to me. AFAICS, its just http request/response all the way
>> down and this is basically done by getting a
>
> An app can expose views, indeed. It can also expose models - one of
> the most important parts of an application -, templatetags, filters,
> forms, fields, widgets etc. FWIW, the views are perhaps one of the
> less important thing an app has to offer - and obviously the most easy
> to factor out, cf genericviews. Models, OTHO, are really the core. If
> you end up writing most of your code in views, then you more than
> probably failed to identify what belongs to the model and what belongs
> to the views. The fact that "views" are a mandatory part of the
> request-response cycle doesn't mean they are the most important part
> of the app.
Can anyone point out a section in the docs (or anywhere else actually)
the Django "app" concept? I've had a look through the docs but
haven't been able to find anything specifically about that.
Regards,
Wayne
--
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 for your reply.
My situation is a little bit more tricky. I have table A and table B.
Table B has several columns, two of which are tableID and resourceID.
Table B is related to table A in the following way:
select * from table B where b.tableID= (table A) and b.resourceID=
(primary key of table A). There is no composite foreign key support in
Django and the database can not be changed. Is there a way to still
relate those two objects and display them in the Django provided
inline admin interface?
Wayne
--
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=.
Hi,
I am working with a legacy database which does not set foreign key
constraints at all between tables. I am wondering if I can still
create Inline admin interface by relating two objects through
different methods. If it is doable, what is the best way of doing it?
Thanks,
Wayne
--
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's been giving me a "502 Bad Gateway
>> nginx" for at least a couple weeks now.
I've been seeing that for a few months now when trying to visit the site.
Regards,
Wayne
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
>> Please refrain from posting messages with this tone to the Django mailing
>> lists.
>>
> I wholeheartedly agree.
> The Django community has a good reputation.
> Don't screw it up with your foul verbal attacks.
Surely it should be grounds for instant removal?
Regards,
Wayne
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
> hi everybody, We want to develop a Bussiness web site with Django framework,
> but we can't decide django's performance. So, would you list some
> large-scale web sites that used django for us?
Define "large-scale".
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
> Anyhow, the purpose of this email was just to ask the community what
> editor(s) they preferred to use with Django.
Assuming you mean text editor: jEdit (www.jedit.org).
Regards,
Wayne
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
> Nobody can help me with this?
If somebody:
a) Has the answer and,
b) Has the time and,
c) The inclination to provide the answer, then they will do so.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
Hi Jon,
The "python setup.py install" command copies the Django library files
to your Python's lib\site-packages directory. You can safely remove
the Django archive which you downloaded.
Regards,
Wayne
2009/8/17 Jonathan Zacsh <jza...@gmail.com>:
>
> please, can anyone help me out??
> --
> Jon
>
>
> On Sun, Aug 16, 2009 at 10:20 AM, jzacsh<jza...@gmail.com> wrote:
>> hello,
>>
>> i'm sorry - i just want to get started and I'm trying to figure out
>> something simple. I installed django last night and am wondering what
>> setup.py actually did.
>>
>> the reason i want to know is: what do i do with the folder of stuff
>> that I downloaded from the original tar.gz (I get the impression its
>> important, as when i tried to move it I had to use sudo)? so can I
>> delete it (when i ran setup.py, it looked like a lot of files were
>> copying... maybe it was copied elsewhere anyway so this one isn't
>> needed?)? I tried reading docs/intro/install.txt (didn't explain much
>> for this purpose) and i tried making sense of the code in setup.py
>> (turned out to be a bit over my head).
>>
>> I'm running Mac OS X 10.5.8
>> i'm also trying to teach myself python, so sorry if something here
>> might seem obvious.
>> and i know there is a useful docs folder in there, but i'm using
>> docs.djangoproject.com
>> (maybe someone wants to advise me: "django is gonna be WAY over your
>> head if you don't have a good grasp of python"?)
>>
>> thanks for any help! :)
>
> >
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
> I currently know zero Python and want to start a project with Django
> ASAP. I've got the opportunity through my work to either take a 5-day
> Python bootcamp or a Django bootcamp - not both.
I don't really think this is a useful question on its own. A more
appropriate question would be "How much programming experience do I
need?". If you have prior programming experience in another language
then I'm sure you'll find Python quick and easy to pick up. In that
case going through the tutorial and playing around with it in an
afternoon should be enough to prep you for a Django book or course.
If you have no programming experience at all then out of the two
options it would be better to take the Python one. Any pure Django
course would assume a certain amount of Python knowledge. But even if
you take a Python course you need to know if the particular course
assumes prior programming experience of some kind of is more of an
"Introduction to Programming Using Python". If you take a Django
course with no programming experience at all then you will be wasting
your time. If you have experience in some kind of programming and
then take a Django course with no Python experience then you might be
able to get by.
Regards,
Wayne
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
Hi Tony,
> @Wayne: Thanks for the welcome. Why are you using 2.5 for your new/
> large project instead of 2.6?
It just seems to be the "sweet spot" release at the moment. I just
found that a few of the libraries I had been using, even in the last
couple of months, had some kind of problem with anything over 2.5. I
really wanted to start using 2.6 but for some reason 2.5 seems to be
the most all-round compatible release of them all. Also it seems that
most shared hosting providers use 2.5 by default.
Regards,
Wayne
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---
Hi Tony,
> However, I'm nervous about the Python 3 situation. What if I start
> building a large project based on Django/Python 2.6, and then a year
> or two down the road the project starts limping because of all of the
> cool new Python 3 modules coming out? And I've got a bunch of Django/
> Python 2.6 code that needs to be ported?
First of all, welcome to the Python world, we'll do our best to make
you feel comfortable here.
You'll find that the Python crowd is very good at supporting legacy
versions. You'll see that you can even still download [1] Python
1.5.2 (April 1999!). That's not to say that your favourite libraries
will be available for such old versions, but many libraries still make
releases for at least as far back as Python 2.3. Also, I don't think
you'll find that Python 3.x will introduce anything so radically new
and innovative that it will severely limit what you can accomplish
with older releases. I'm working on a team starting a new (large)
project now which we are basing around Python 2.5.
Remember that Python has been around for a long time, since 1991, and
releases like 2.5, 2.6 etc. are extremely mature and by now all of the
common programming problems have already been encountered, solved and
accomodated in the core and standard libraries.
If you do decide to port your application to 3.x (think very carefully
about it first - make sure that any of the associated libraries you
require have mature 3.x releases) there are tools available to make
the job a lot easier, like the 2to3 [2] script.
[1] http://www.python.org/download/
[2] http://www.python.org/doc/2.6/library/2to3.html
HTH,
Regards,
Wayne Koorts
http://www.wkoorts.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
Hi,
> I need some support with something, i have the following boolean field
> but if you submit the form without choosing an answer it kicks back an
> error because i have the following IF Statment to make sure when it is
> selected other fields are mandatory. HEres the code.
Instead of this line:
if request.POST['Lived_Out_Uk'] == '1':
Use this:
if 'Lived_Out_Uk' in request.POST:
Regards,
Wayne Koorts
http://www.wkoorts.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
Hi Steve,
> We have an application where we periodically import data from an
> external vendor, and the process is mostly automated, but we need to
> review the data before having it go live.
>
> We were considering an option where we would run processes on another
> database, do the manual validation, and then replicate the DB changes
> to our production database (which would have the same schema).
I do exactly this with one of my sites. This is my scenario:
1. Main database table gets updated automatically every night (this
is a kind of data that can be automatically refreshed, but that should
be beside the point for this discussion). The data first goes into a
pending table on my dev server, which is exactly the same as the main
table, with "_pending" appended to the name.
2. The data is then dumped to a file using "psql" and sent via FTP up
to an equivalent pending table on the production server (via Python
script in my dev environment). There is a Python script set up on the
server to monitor a specific folder for a specific dump file name at
regular intervals, and if it finds it, imports it into the table also
with "psql", then deletes the dump file.
3. The data sits in the pending table on the production server until
I approve it via an admin interface which I have set up Django.
Basically there is a "DB Admin" area on the site which I have set up
which shows me four chunks of the data at various points in the table,
100 at the start, 100 at 1/4 through, 100 at 3/4 through and then 100
at the end. It also shows me the total number of records so that I
can do a quick visual integrity check.
4. There are "approve" and "reject" buttons at the bottom of the
approval page. If I click "approve" it moves the current live table
data into a backup table (the db admin area also has a restore
function) and moves the pending data into the live table using a raw
nested SQL SELECT statement via Django and then empties the pending
table. If I click "reject" it just empties the pending table.
These same general steps can be adjusted to accomodate more tables
etc. as per your requirements.
Hope this helps,
Regards,
Wayne Koorts
http://www.wkoorts.com
http://www.blazingpanther.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
> I'm in the process of implementing testing (both doc tests and unit
> tests) though I'm having some conceptual difficulty. I'm not sure how
> far to take the testing. I'm curious what people concider an
> appropriate level of testing.
Uh oh, be ready for a huge thread. This is one of those unending debates.
Basically:
- More thorough test coverage == more confidence as you know there is
less chance that when you break something it will go unnoticed.
- Creating complete test coverage and keeping it up to date takes a
lot of time, and sometimes the decision is made to use that time for
other things.
As with anything, there's a balance. It's very dependant on the
project and team involved.
Regards,
Wayne Koorts
http://www.wkoorts.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---
1 - 100 of 122 matches
Mail list logo