Re: how to cut and paste image into django app

2009-10-23 Thread kmike

No, my code doesn't do that, sorry for not expressing this clear.

Here is the example of drag-n-drop images upload:

http://www.appelsiini.net/2009/10/drag-and-drop-file-upload-with-google-gears

And here is the corresponding API documentation:

http://code.google.com/intl/ru/apis/gears/api_desktop.html

On 24 окт, 03:22, Margie Roginski <margierogin...@yahoo.com> wrote:
> Thanks everyone for all of your comments - I've been off looking at
> these various choices, learning a bit about java/flash this morning.
> I was not able to gethttp://www.radinks.com/upload/dnd.phpto work.
> It seems that even with the demo I have access privilege issues.
> Ariel, when you run the demo are you able to see your dropped files in
> the demo area?  I get a message about the names of the files uploaded,
> and some stuff like this "Files have not been saved, please edit
> upload.php to match your configuration".  Anyway, just curious if it
> works for you or if you didn't try it.
>
> Javier - I took a look athttp://swfupload.org/and that is indeed
> very nice looking.  I have not used flash yet so I think I will take
> this as an opportunity to figure out what that can do for me and try
> using it.
>
> Kmike - the gears thing seems promising but I am frankly still having
> trouble figuring out what it does.  Does your code actually upload
> files via drag and drop?  I will try downloading your code and see if
> I can figure it out from that, just haven't had a chance yet.
>
> Anyway, thanks to all of your for your insights. It seems like not
> having this functionality is a huge impediment in making a web app
> look and feel like a desktop app. I'm trying to write a web app that
> will allow people to manage and discuss their tasks associated with
> chip design, and my users' first response is always "Can I drag and
> drop my images like I do with Outlook?".  It is amazing to me that we
> are so far from having an easy solution for this in the web app world,
> I have to believe all of the social networking sights would love to
> have drag and drop images.
>
> Ok, so I will continue diving into your various suggestions for
> now ... thanks!
>
> Margie
>
> On Oct 23, 11:50 am, Javier Guerra <jav...@guerrag.com> wrote:
>
>
>
> > On Fri, Oct 23, 2009 at 1:29 PM, Ariel Nunez <ingenieroar...@gmail.com> 
> > wrote:
> > > I found this while googling: "drag and drop upload":
>
> > >http://www.radinks.com/upload/dnd.php
>
> > > Seems to use a combination of Java (applet) + PHP (server) and is not
> > > open source.
>
> > i tried this one several years ago.  unfortunately, can't recommend
> > it.  even with corporate clients, it's a nightmare to keep the applet
> > with enough access privileges to read the dropped files.  almost any
> > small update on the client machine, and the Java system asked (again)
> > to authorize it.  i have yet to find a single user that could
> > understand what it was asking, and why.  and once it's disabled on a
> > machine, it's very hard to enable again.
>
> > the server doesn't have to be PHP, in fact it's usually FTP.  the PHP
> > part is mostly to set the options for the  tag
>
> > --
> > Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to cut and paste image into django app

2009-10-23 Thread kmike

Google Gears can also be used in order to implement drag-n-drop image
uploading. I beleive it is the easiest way because it only involves
some javascript programming.

You can also do other nice things with Google Gears (resize images
client-side, for example; check http://bitbucket.org/kmike/gearsuploader/
for ready solution).

On 24 окт, 00:29, Ariel Nunez <ingenieroar...@gmail.com> wrote:
> Hi Margie,
>
> I found this while googling: "drag and drop upload":
>
> http://www.radinks.com/upload/dnd.php
>
> Seems to use a combination of Java (applet) + PHP (server) and is not  
> open source.
>
> But it seems to prove it is possible. Just perhaps not with simple  
> HTML + JS.
>
> Regards,
>
> Ariel.
>
> On Oct 23, 2009, at 9:28 AM, Javier Guerra wrote:
>
>
>
>
>
> > On Thu, Oct 22, 2009 at 11:54 PM, Margie Roginski
> > <margierogin...@yahoo.com> wrote:
> >>  They want to use
> >> an windows app called mwsnap to basically snap images from their
> >> desktop, then ctrl-v to copy the image into my django app.
>
> > is there any web app that does this?  AFAICT, all use some upload
> > button (maybe augmented with flash libraries, like the great one from
> >http://swupload.org/)
>
> > --
> > Javier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Interesting code abstraction Challenge

2009-10-23 Thread kmike

Maybe you don't have enough information to make an abstraction right
now. If so I suggest to actually implement several API's in a dumb
way. After that it'll be clear what are the differences and what are
the common parts so making a good abstraction will be easier.

On 23 окт, 11:06, Jason Beaudoin  wrote:
> Why hello there,
>
> I have been thinking over this system design for quite a while now,
> and I'm still a bit unsure of the sensible way to properly (and
> sufficiently) abstract the system - the django-way, so to speak. I am
> very interested in what other folks have to say - maybe I have been
> thinking about this too much, maybe I haven't crossed paths with the
> techniques you would use, but I imagine that while a little
> challenging, this is still a common situation.
>
> Please share your crazy, genius ideas, reading tips, code snippets, etc  : )
>
> Here is the general setup:
>
> Client Servers <---> The Application in Question <---> Partner Applications
>
> The main role of the webapp is to serve as a proxy application to many
> other partner web applications - we receive requests from client
> servers, work out the processing with one or more of our partner
> applications, and return the results to the client server. All data
> communication is done via predefined APIs, and each API is different..
> we define the API our client servers use to send/receive requests to
> us, we follow the APIs as defined by our partners to communicate with
> their applications. In this way, our client servers are connected to
> many similar applications through our one webapp.
>
> Several baseline "rules", if you will:
>
>  - The application receives specially formatted requests for
> processing (via POSTs).
>  - As stated, all requests are formatted as defined by our, or our
> partner, APIs.
>  - All incoming requests will need to be re-formatted before passing
> on, as each API is different.
>  - Some communication is handled via passing XML around, others aren't.
>  - A few situations require additional user interaction
>
> The Challenge, or Where I'm caught up:
>
> The end points are easy, as the APIs need to be followed.
> Re-formatting a request from our API to a partner's - and vice versa -
> isn't really a problem either.. (if I wanted to do this the crappy
> way, this could be written out for each conversion, but there are 10 -
> 20 conversions). The challenge I am trying to figure out is how to
> abstract the re-formatting process to eliminate code duplication, as
> our API and each partner API will be similar (in an abstract way).
>
> What's difficult is that each API is different enough that it isn't a
> straight up a --> b field name translation, the conversion mechanism
> has to be pretty dynamic. To put specifics on it, differing field
> names are one thing, but the APIs differ in the information they
> require (field types, so to speak) - for example: additional fields
> for some APIs, or a field in one API may be a combination of others in
> another API, etc.
>
> What I have in mind so far:
>
>  - For each partner, define the list of fields required
>  - Define translations for each field, with 3 parts: our field name
> (or data source), the partner's field name, and a translation function
> (with the appropriate conversion algorithm if necessary).
>  - When a partner has a field that doesn't have an equivalent in our
> system, define a function for generating the field's value.
>  - Once we've converted the information, format the data as either XML
> or ready for a URLencode to POST
>
> Questions:
>
> Am I on the right track here?
> Should I be thinking about this differently?
> How do I tie these translations into a generic process, with generic
> code, leaving the specifics to these translation functions?
> How the hell would you set this up? Even if I'm on the right path
> here, I'm having difficulty envisioning the python code behind all of
> this..
>
> All ideas, feedback, input, comments, etc welcome!!
>
> Regards,
>
> ~Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two cache-related questions

2009-10-07 Thread kmike

> appropriate cache_prefix function

oops, key_prefix, not cache_prefix :)

On 8 окт, 01:35, kmike <kmik...@googlemail.com> wrote:
> 1. Maybe you can use django's Vary support 
> (http://docs.djangoproject.com/en/dev/topics/cache/#using-vary-headers
> ). This
> will work if you have language preferences in http headers. If you
> only set language cookie (or store language preferences in sessions)
> then you can usehttp://bitbucket.org/kmike/django-view-cache-utils/
> for that (writing appropriate cache_prefix function).
>
> 2. Functions (from the same django-view-cache-utils app) that removes
> page from cache based on page's url (and
> possibly key_prefix):
>
> http://bitbucket.org/kmike/django-view-cache-utils/src/tip/view_cache...
>
> On 8 окт, 00:11, Christophe Pettus <x...@thebuild.com> wrote:
>
>
>
> > Chatting with a client last night, two Django cache-related questions  
> > came up...
>
> > 1. Is there any convenient way of using the @cache_page decorator  
> > while caching separate versions by language using the Localization  
> > facilities?  It seems that it will cache the first access, and return  
> > it regardless of language.
>
> > 2. Is there a way of invalidating the cache, for example if the  
> > underlying database gets an update?
>
> > Thanks!
> > --
> > -- Christophe Pettus
> >     x...@thebuild.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
-~--~~~~--~~--~--~---



Re: Two cache-related questions

2009-10-07 Thread kmike

1. Maybe you can use django's Vary support (
http://docs.djangoproject.com/en/dev/topics/cache/#using-vary-headers
). This
will work if you have language preferences in http headers. If you
only set language cookie (or store language preferences in sessions)
then you can use http://bitbucket.org/kmike/django-view-cache-utils/
for that (writing appropriate cache_prefix function).

2. Functions (from the same django-view-cache-utils app) that removes
page from cache based on page's url (and
possibly key_prefix):

http://bitbucket.org/kmike/django-view-cache-utils/src/tip/view_cache_utils/__init__.py#cl-59

On 8 окт, 00:11, Christophe Pettus <x...@thebuild.com> wrote:
> Chatting with a client last night, two Django cache-related questions  
> came up...
>
> 1. Is there any convenient way of using the @cache_page decorator  
> while caching separate versions by language using the Localization  
> facilities?  It seems that it will cache the first access, and return  
> it regardless of language.
>
> 2. Is there a way of invalidating the cache, for example if the  
> underlying database gets an update?
>
> Thanks!
> --
> -- Christophe Pettus
>     x...@thebuild.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
-~--~~~~--~~--~--~---



Re: Two cache-related questions

2009-10-07 Thread kmike

1. Maybe you can use django's Vary support (http://
docs.djangoproject.com/en/dev/topics/cache/#using-vary-headers). This
will work if you have language preferences in http headers. If you
only set language cookie (or store language preferences in sessions)
then you can use http://bitbucket.org/kmike/django-view-cache-utils/
for that (writing appropriate cache_prefix function).

2. Function that removes page from cache based on page's url (and
possibly key_prefix):
http://bitbucket.org/kmike/django-view-cache-utils/src/tip/view_cache_utils/__init__.py

On 8 окт, 00:11, Christophe Pettus <x...@thebuild.com> wrote:
> Chatting with a client last night, two Django cache-related questions  
> came up...
>
> 1. Is there any convenient way of using the @cache_page decorator  
> while caching separate versions by language using the Localization  
> facilities?  It seems that it will cache the first access, and return  
> it regardless of language.
>
> 2. Is there a way of invalidating the cache, for example if the  
> underlying database gets an update?
>
> Thanks!
> --
> -- Christophe Pettus
>     x...@thebuild.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
-~--~~~~--~~--~--~---



Re: Django comments

2009-10-06 Thread kmike

It seems that django's comments system isn't exactly what your want.
It is quity easy to write your specialised comments app, one solution
is to just write your own.

Second solution solution is:

1. Attach comments to your page model, not paragraph.
2. Add paragraph_id field to comment model.
3. Customize comments form to include (hidden?) paragraph_id field
4. Use {% regroup %} template tag in templates for comment rendering.
5. Write your own render_comment_form template tag which accepts
additional paragraph_id parameter and constructs form taking this
parameter in account. If it's not sufficient, write your versions of
necessery template tags (or just don't use them, theay are not
required for comments app to work).


On 6 окт, 00:38, cirip <cir...@gmail.com> wrote:
> Mike,
>
> Thanks. Well I understand that I can add extra field. That's not my
> problem. My problem is that I want to be able to add comment without
> having to create an instance of the object that comments refers to.
> For example for render the form I shall use:
>
> {% get_comment_count for config.commenttarget 'paragraph_14' as
> comment_count %}
>
> Model config.commenttarget exists, but there is no data in that table.
> However, I can read comments and get count etc.
>
> When it comes to rendering entry form
>
> {% render_comment_form for paragraph %}
>
> I need to create paragraph object to render the form. I don't wan to
> create paragraph object in the database for each paragraph that I want
> to comment on. I mean I could try to create object paragraph and never
> persist it and it all might magically work.
>
> All I want is comments without any referential integrity with just one
> extra field - paragraph id that I could use to query comments for that
> particular paragraph.
>
> Thanks again,
>
> Tomas
>
> On Oct 3, 11:28 am, kmike <kmik...@googlemail.com> wrote:
>
>
>
> > If you want additional field (paragraph_id) in Comment model you can
> > create your own model as decribed here:
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#ref...
>
> > On 3 окт, 01:46, cirip <cir...@gmail.com> wrote:
>
> > > Hi,
>
> > > I am just reading aboutdjangocommentsframework that I planned to
> > > use.
>
> > > As I learned so far you have to have object to whichcommentsbelong
> > > in the database as well. Let's say I just want to havecomments
> > > related to some paragraph on my page without having to create record
> > > for each paragraph that I want to comment on and I would like to use
> > > paragraph id as the key to identify thecomments.
>
> > > Thanks,
>
> > > Tomas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to customize the default comments form from contrib.comments

2009-10-03 Thread kmike

Define custom form:

class NoEmailCommentForm(CommentForm):
def __init__(self, *args, **kwargs):
super(NoEmailCommentForm, self).__init__(*args, **kwargs)
self.fields['email'].required = False

Then put

def get_form():
return NoEmailCommentForm

in your comment customization app's __init__.py

Then set COMMENTS_APP = 'your_comments_app'

And then just don't render email and url fields in templates.

On 4 окт, 01:49, Guillermo  wrote:
> Hi,
>
> Specifically, I don't want to require users to enter their email
> addresses or an url.
>
> Regards,
>
> Guillermo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django comments

2009-10-03 Thread kmike

If you want additional field (paragraph_id) in Comment model you can
create your own model as decribed here:

http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#ref-contrib-comments-custom

On 3 окт, 01:46, cirip  wrote:
> Hi,
>
> I am just reading about django comments framework that I planned to
> use.
>
> As I learned so far you have to have object to which comments belong
> in the database as well. Let's say I just want to have comments
> related to some paragraph on my page without having to create record
> for each paragraph that I want to comment on and I would like to use
> paragraph id as the key to identify the comments.
>
> Thanks,
>
> Tomas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Populating an ImageField

2009-10-03 Thread kmike

If you have one default logo then maybe the 'right' way is to use
'default' parameter of ImageField?

On 3 окт, 22:07, Nan  wrote:
> Nope, but I finally found what seems to be the "right" way to do this
> (copies the file to the appropriate upload_to location, etc):
>
> from django.core.files.base import File
> def create_a_company(name, logo_path):
>     company = Company()
>     company.name = name
>     logo_file = open(logo_path)
>     company.logo = File(logo_file)
>     company.save()
>
> On Oct 2, 10:15 pm, akonsu  wrote:
>
>
>
> > did you try
>
> > company.logo = relative_path
>
> > ?
>
> > On Oct 2, 4:45 pm, Nan  wrote:
>
> > > OK, this seemed to work:
>
> > > def create_a_company(name, logo_path):
> > >     company = Company()
> > >     company.name = name
> > >     relative_path = path_relative_to_media_root(logo_path)
> > >     company.logo.name = relative_path
> > >     company.save()
>
> > > Thank you!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I require login before accessing FormWizard forms?

2009-10-02 Thread kmike

My solution was

urlpatterns += patterns('',
url(r'^my_wizard/$', login_required(MyWizard().__call__),
name='my_wizard'),
)

On 2 окт, 18:11, JimR  wrote:
> After much searching, I found the answer that I was looking for -
> using the login_required decorator directly in the URLconf, then
> adding a subclass of __name__ to the FormWizard class.
>
>  (r'^contact/$', login_required(ContactFormWizard([ContactFormPartOne,
> ContactFormPartTwo])))
>
> but since it complains it can't find the __name__ attribute since it's
> a class, add the following method to the FormWizard subclass:
>
> def __name__(self):
>       """When using decorators, Django tries to get the name of the
> function and since we're a class, we'll fail. So add this method to
> compensate."""
>      return 'OrderFormWizard'
>
> On Sep 30, 8:04 am, JimR  wrote:
>
>
>
> > OK, so I've searched the group and the Internet looking for the answer
> > to this questions, and the common answer seems to be "wrap theformwizardin 
> > a view."  But I don't see any examples of how to do
> > this.  I currently have theformwizardembedded in the URLconf, and my
> > attempt at "wrapping theformwizardin a view" still enables a user to
> > directly access that URL without first logging in.  Can someone post
> > an example of "wrapping aformwizardin a view" that would require a
> > user to login before getting to those forms?
>
> > Another question - Is there a way to add a "login required" setting to
> > a URL pattern
>
> > Here's what I've done:
>
> > URLconf:
> > ...
> > (r'^(?P\d+)/register_player/$',RegistrationWizard
> > ([PlayerInfoForm, SportForm, UniformForm, AddressForm, VolunteerForm,
> > InsuranceForm, PaymentTypeForm])),
>
> > (r'^(?P\d+)/signup/$', 'wagdogs.registration.views.signup'),
> > ...
>
> > View:
> > @login_required()
> > def signup(request, org_id):
> >         return HttpResponseRedirect('/registration/%s/register_player/' %
> > org_id)
>
> > Thanks,
> > Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom linking of models in many-to-one relationship

2009-09-27 Thread kmike

This looks like django's generic relations ('Content types' in
documentation).
`select_related` for generic related models is not supported in
django. So you should retreive all Notes associated with Account
manually. If there are several Accounts you still can fetch all data
in 2 queries using 'id__in' queries (example:
http://bitbucket.org/kmike/django-generic-images/src/tip/generic_utils/managers.py#cl-122).

On 28 сен, 09:17, triman <john.ple...@gmail.com> wrote:
> I have a model that can be attached to a variety of different models,
> based on the value of a column.  Is there any way to map this
> relationship in Django?  If not, is there a way to automatically do
> post-fetch processing where I could populate it?
>
> Here is a example:
>
> class Note(models.Model):
>     owner_id = models.IntegerField() #this is the FK of the related
> object
>     owner_type = models.CharField(max_length=40) # this can either be
> "Account" or "Ticket"
>     note = models.TextField()
>
> class Account(models.Model)
>     name = models.CharField(max_length=40)
>     ...
>
> class Ticket(models.Model)
>     subject = models.CharField(max_length=120)
>     ...
>
> So basically, we can attach Notes to either Account or Ticket.  The
> "owner_id" field will be the primary key of the object being attached
> to.  The "owner_type" will be either "Account" or "Ticket".  When
> retrieving an Account, I want to also return all the Notes associated
> with it.  I don't care about going the other direction in the
> relationship
>
> Is there any way to do this with the Django mappings?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: remove fields from django.contrib.comments

2009-09-21 Thread kmike

You can remove fields from templates (from html). They indeed should
be removed if you don't want them :)
Then we face a problem: some of CommentForm fields are marked as
required. The solution is to subclass CommentForm and set this flag to
False:

class NoEmailForm(CommentForm):
def __init__(self, target_object, data=None, initial=None):
super(NoEmailForm, self).__init__(target_object, data,
initial)
self.fields['email'].required = False




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



Re: capacity planning (server sizing) for Apache+Django+PostgreSQL

2009-09-21 Thread kmike

Try using smth. like siege (http://freshmeat.net/projects/siege/ ,
home page seems to be broken) to check how many requests per second
can your app handle. Then add more django processes/threads in your
mod_wsgi config (or more fastcgi processes, or smth. else) and test
again. Measure memory and CPU consumption. If you app is memory bound
then you'll know at least how much memory (=django processes) is
needed for assumed load.

Usually even 256MB Xen VPS is enough for most small and medium sites
if there are not millions of SQL queries per each page request.


On 21 сен, 21:28, Jan Ostrochovsky  wrote:
> Hello,
>
> are there some calculators or best practises or other tools/methods,
> how to size server hardware for Django applications from assumed load
> (concurrent users, etc.)?
>
> Thanks in advance for any advice.
>
> Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: carrying value from ForeignKey

2009-08-16 Thread kmike

I mean smth. like
lambda: self.content.text


On 16 авг, 20:41, Ali Rıza Keleş  wrote:
> Hello,
>
> I want to carry value as default from one model to another.
>
> For example:
>
> class Text(models.Model):
>     text = models.TextField(blank = True)
>     name = models.SlugField(db_index=True, unique=True)
>
> class News(models.Model):
>     content = models.ForeignKey(Text, blank = True, null = True,
> defaut=)
>     text = models.SlugField(db_index=True, unique=True)
>
> I want to set content's default value as Text's text value. What can I
> put here instead of **?
>
> Thank you..
>
> --
> Ali Rıza
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: carrying value from ForeignKey

2009-08-16 Thread kmike

You can override `save` method or maybe provide callable ***,
smth. like

default=lambda: self.text

but i haven't test it.

On 16 авг, 20:41, Ali Rıza Keleş  wrote:
> Hello,
>
> I want to carry value as default from one model to another.
>
> For example:
>
> class Text(models.Model):
>     text = models.TextField(blank = True)
>     name = models.SlugField(db_index=True, unique=True)
>
> class News(models.Model):
>     content = models.ForeignKey(Text, blank = True, null = True,
> defaut=)
>     text = models.SlugField(db_index=True, unique=True)
>
> I want to set content's default value as Text's text value. What can I
> put here instead of **?
>
> Thank you..
>
> --
> Ali Rıza
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Application decoupling - project architecture question

2009-08-08 Thread kmike

I wrote a simple app that may be useful for avatar management:
http://bitbucket.org/kmike/django-generic-images/wiki/Home
It's similar to django-tagging in aspect that images can be attached
to any model using generic relations and then fetched in a few sql
queries.
Avatar-uploading view example can be found in another app
(upload_main_image view):
http://bitbucket.org/kmike/django-photo-albums/wiki/Home
However it is easy to write your own view or extend your
editProfileForm.

On 8 авг, 00:29, Andrin Riiet <c7r.s...@gmail.com> wrote:
> Thanks for your replies,
>
> I read the book and indeed I found what I needed.
>
> For anyone who happens to read this and is wondering the same thing,
> here's how it goes:
>
> You extend the base form class (eg editProfileForm), add the avatar
> field to it and you use the new form class by passing it as parameter
> to the view function that displays it ( the view functions should be
> designed to accept such parameters). You pass the correct values for
> the parameters in the urlconf.
> And you can decouple the form handling code by putting it all in the
> form.save() method (as opposed to the view function) - that way when
> you extend the base form you can extend the form handling code as
> well.
>
> Thanks everyone,
>
> Andrin
>
> On Aug 7, 5:08 pm, grElement <ang...@andyet.net> wrote:
>
>
>
> > There is a good tutorial on this in Practical Django Projects
>
> >http://www.amazon.com/Practical-Django-Projects-Pratical/dp/1590599969
>
> > It goes a bit more into theory that I found helpful.
>
> > On Aug 6, 8:07 am, Andrin Riiet <c7r.s...@gmail.com> wrote:
>
> > > Hi, I'd like to shed some light on the "the right way" to make
> > > applications in django by an example and a few questions.
>
> > > Let's say that I have a 'users' application (acting as "user profiles"
> > > on the built-in user authentication system) and I want to add an
> > > avatar image feature to it.
> > > I'd like to have the avatars in a separate application in case my next
> > > project doesn't require them (this is the right way to do things i
> > > guess?)
>
> > > Now I want to have the user to be able to upload an avatar image in
> > > the "edit profile" form. The default edit-profile form is defined in
> > > my 'users' application of course. I'd like to "add" the avatar feature
> > > (form field) to it somehow. - This is part 1 of the problem
>
> > > The 2nd part is in the form handling: the request object is going to
> > > contain form field values from 2 different applications, none of which
> > > should be responsible for processing the other's forms.
>
> > > Obviously the 'avatars' application is dependent on the 'users'
> > > application but the 'users' application should be oblivious of the
> > > avatars...
>
> > > How would I go about doing that?
>
> > > Andrin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Application decoupling - project architecture question

2009-08-08 Thread kmike

I wrote a simple app that may be useful for avatar management:
http://bitbucket.org/kmike/django-generic-images/wiki/Home

It's similar to django-tagging in aspect that images can be attached
to any model using generic relations and then fetched in a few sql
queries.

Avatar-uploading view example can be found in another app
(upload_main_image view):
http://bitbucket.org/kmike/django-photo-albums/wiki/Home

However it is easy to write your own view or combine it with profile
editing view.

On 8 авг, 00:29, Andrin Riiet <c7r.s...@gmail.com> wrote:
> Thanks for your replies,
>
> I read the book and indeed I found what I needed.
>
> For anyone who happens to read this and is wondering the same thing,
> here's how it goes:
>
> You extend the base form class (eg editProfileForm), add the avatar
> field to it and you use the new form class by passing it as parameter
> to the view function that displays it ( the view functions should be
> designed to accept such parameters). You pass the correct values for
> the parameters in the urlconf.
> And you can decouple the form handling code by putting it all in the
> form.save() method (as opposed to the view function) - that way when
> you extend the base form you can extend the form handling code as
> well.
>
> Thanks everyone,
>
> Andrin
>
> On Aug 7, 5:08 pm, grElement <ang...@andyet.net> wrote:
>
>
>
> > There is a good tutorial on this in Practical Django Projects
>
> >http://www.amazon.com/Practical-Django-Projects-Pratical/dp/1590599969
>
> > It goes a bit more into theory that I found helpful.
>
> > On Aug 6, 8:07 am, Andrin Riiet <c7r.s...@gmail.com> wrote:
>
> > > Hi, I'd like to shed some light on the "the right way" to make
> > > applications in django by an example and a few questions.
>
> > > Let's say that I have a 'users' application (acting as "user profiles"
> > > on the built-in user authentication system) and I want to add an
> > > avatar image feature to it.
> > > I'd like to have the avatars in a separate application in case my next
> > > project doesn't require them (this is the right way to do things i
> > > guess?)
>
> > > Now I want to have the user to be able to upload an avatar image in
> > > the "edit profile" form. The default edit-profile form is defined in
> > > my 'users' application of course. I'd like to "add" the avatar feature
> > > (form field) to it somehow. - This is part 1 of the problem
>
> > > The 2nd part is in the form handling: the request object is going to
> > > contain form field values from 2 different applications, none of which
> > > should be responsible for processing the other's forms.
>
> > > Obviously the 'avatars' application is dependent on the 'users'
> > > application but the 'users' application should be oblivious of the
> > > avatars...
>
> > > How would I go about doing that?
>
> > > Andrin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: checking if db schema and model match

2009-08-05 Thread kmike

That's a question about database migration. Django doesn't have built-
in solution for that.
Try using South (http://bitbucket.org/andrewgodwin/south/overview/),
it is a very good db migration app. I suggest using development
version because (based on my experience) it is more robust than last
official release (0.5).

On 5 авг, 18:28, Sam Lai  wrote:
> I hope this hasn't been asked before; had a quick look through the
> archives and docs but couldn't find anything.
>
> Is it possible to get django (e.g. via manage.py) to CHECK if the db
> schema and model match? I don't want it to change anything, just to
> tell me if there is a mismatch, and what that is.
>
> I thought syncdb did this, but it doesn't seem to. I think this would
> be quite useful to have, and could pre-empt errors later on when
> non-existent fields are used in views etc.
>
> Sam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cache and multple languages

2009-08-05 Thread kmike

Hi,
I've recently create an app for advanced view caching. It allow pages
to be cached based on anything in request, specific cookies for
example.
Please check http://bitbucket.org/kmike/django-view-cache-utils/wiki/Home

If you have any questions about it feel free to ask.

On 5 авг, 20:11, cwurld <chuck.c.mar...@gmail.com> wrote:
> Hi,
>
> I have been successfully running a multi-language site for a while
> now. The users language pref is stored (along with other data) in a
> cookie.
>
> Recently, I have been trying to cache some of the more common and
> processor intensive views. Since the language code is not in the url,
> I can't figure out how to cache pages based on language.
>
> I looked in to the vary_on_header decorator, but I do not see how to
> get that to work since the cookies vary on lots of stuff in addition
> to language and I doubt I can get my users to change the Accept-
> Language attribute in the request header.
>
> Any ideas?
>
> Thanks,
> Chuck

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