Re: Displaying attribute from foreign key in admin
> I also get an error when I try 'parent.name'. Try just 'parent'. It will display whatever is coming out of your model by default (in the __str__() or __unicode__() method). That will probably do it for you, but you can access the other information if you write a method for it: class Child(model.models): parent = ForeignKey(Parent) def parent_name(self): return str(self.parent.name) class admin: list_display('id', 'parent_name') --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding an extra INNER JOIN
On Wed, 2008-04-23 at 22:30 -0700, jonknee wrote: > I have four models that I want to combine into one report. The manual > SQL is pretty easy, three INNER JOINS. I just can't figure out how to > get the ORM to do it. I'm using the auth app with a custom profile > model and that seems to be the issue, since the User model doesn't > have a foreignkey to the Profile model, that data isn't showing up in > my QuerySet. Look at the 'tables' and 'where' parameters to the extra() method on querysets. Regards, Malcolm -- A conclusion is the place where you got tired of thinking. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: two column unique index?
On Wed, 2008-04-23 at 22:19 -0700, Tim Saylor wrote: > I have two columns in my database that must be, as a pair, unique > throughout all the rows. Googling tells me I want a two column unique > index. From the docs it looks like unique_together is what I want, > but that looks like it makes the two columns unique from each other > within the row. Is there a way to do what I want? Thanks! It sounds like you want 'unique_together'. That specifies tuples of columns that are unique as a tuple amongst all the rows in the table. So if unique_together = [('first', 'second', 'third')] Then for each tuple formed from the attributes ('first', 'second', 'third'), there can only be one occurrence in the table. There is no default way in Django's ORM notation to say that 'first' must be unique amongst itself and amongst the 'second' values, etc. That would require adding a constraint using raw SQL. Regards, Malcolm -- Borrow from a pessimist - they don't expect it back. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
two column unique index?
I have two columns in my database that must be, as a pair, unique throughout all the rows. Googling tells me I want a two column unique index. From the docs it looks like unique_together is what I want, but that looks like it makes the two columns unique from each other within the row. Is there a way to do what I want? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Relating two objects in a model with eachother
On Wed, 2008-04-23 at 11:49 -0700, kalve wrote: > Hi, > > I have got a Person model, and I need create a spouse field. > > When editing Jane, I need to be able to John as her spouse. Jane > cannot have more than one spouse, and only one person can have Jane as > spouse. The relation needs to be symmetrical. > > I have tried both ManyToOne and ForeignKey, but I don't seem to be > able to grok this. Thinking about the data constraints, it's really a many-to-many relation where each column in the intermediate table is unique. That is, a Person model is joined to itself with a many-to-many key via an intermediate database table that stores the pairs of ids of the related models. Each id is only allowed to appear once in that table. There's an extra constraint that anything appearing in the first column cannot appear in the second column (so you can't add John->Jane and Jane->John). Out of the box, you can't do this in Django. However, you can get very close and then add the additional database constraint manually using raw SQL. For example, you could create the many-to-many key manually, using the standard technique in [1]. Or you could wait for #6095 to land in trunk and use that eventually (which is mostly just syntactic sugar for the technique in [1], so don't let that block your development). You can then specify the unique constraint on the intermediate fields, but you will have to add the check constraint to enforce uniqueness between the columns manually. [1] http://www.djangoproject.com/documentation/models/m2m_intermediary/ Regards, Malcolm -- Despite the cost of living, have you noticed how popular it remains? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Show diff between fresh and running database schema
On Wed, 2008-04-23 at 17:18 +0200, Thomas Guettler wrote: > Malcolm Tredinnick schrieb: > > On Wed, 2008-04-23 at 15:37 +0200, Thomas Guettler wrote: > > > >> Hi, > >> > >> has some one a script to show the difference between the > >> running database and one which get created by syncdb? > >> > >> > >> > > This sounds like it would be really difficult (complex) to make it work > > correctly. The output from a database tool is going to include stuff > > that you don't necessarily care about (e.g. constraints that are > > auto-created with names in some cases), the table ordering may well be > > different, > The ordering of the columns is why I needed the diff in my case! No, I said the ordering of the tables, not the ordering of the columns. The order that Django creates the tables isn't necessarily going to be the order they are output by pg_dump. Also, if you add a new table to a database, is it possible the order of the tables as output by pg_dump will change? What I'm trying to get at here is that I think that a general solution needs to be much more aware of things than just the output. It needs to actually understand the output and known how to relate like things to like. For all the database backends it supports, and that's why it's harder than it looks. Regards, Malcolm -- I intend to live forever - so far so good. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: filtering in ModelChoices not working
replying to myself On 23-Apr-08, at 2:28 PM, Kenneth Gonsalves wrote: > class Ingredientrecform(forms.ModelForm): > """ > Form to add Ingredients. > """ > def __init__(self,pageid, *args, **kwargs): > super(Ingredientrecform, self).__init__(*args, **kwargs) > self.pageid = pageid > ingredient = forms.ModelChoiceField > (queryset=Ingredient.objects.extra( > where=["""id not in (select ingredient_id from > web_recipeingredient\ > where recipe_id = %s)""" % self.pageid])) it should be self.fields['ingredient'] and not 'ingredient' -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and CSS
Rodney Topor wrote: Is there something strange about using CSS with Django? When I make my templates refer to external CSS files, the appearance of the template changes, but not the way the CSS file says it should? Is there something special I need to know about this? Nothing that I am aware of. It might help if you are able to paste a short snippet of the HTML and relevant CSS is that not appearing how you think it should. Regards -Darryl signature.asc Description: OpenPGP digital signature
Re: trying to edit the geodjango wiki page
I believe you need to go to the 'settings' page and enter a name and email address first. Cheers -D Tyler Erickson wrote: What do I need to do to edit the following page? http://code.djangoproject.com/wiki/GeoDjango It lets me enter edit mode and preview the changes, but when I try to submit the change I get: "500 Internal Server Error (Submission rejected as potential spam)" signature.asc Description: OpenPGP digital signature
Django and CSS
Is there something strange about using CSS with Django? When I make my templates refer to external CSS files, the appearance of the template changes, but not the way the CSS file says it should? Is there something special I need to know about this? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
trying to edit the geodjango wiki page
What do I need to do to edit the following page? http://code.djangoproject.com/wiki/GeoDjango It lets me enter edit mode and preview the changes, but when I try to submit the change I get: "500 Internal Server Error (Submission rejected as potential spam)" --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: I'm not getting URL's. Help!
Awesome. Thanks for clearing that up for me. On Apr 22, 4:12 pm, Michael <[EMAIL PROTECTED]> wrote: > Thanks. It was something in your models. > > Django can't just magically figure out what url you want besed on the same > function. Look at the way that you return the get_absolute_url: > > def get_absolute_url(self): > return ('django.views.generic.list_detail.object_detail', (), { 'slug': > self.slug, }) > > This function is the EXACT same as the one in your precincts models. How is > Django supposed to know which is which. > > You need to somehow differentiate the names of your url conf. So you can in > your urls name the url like: > > urlpatterns += patterns('django.views.generic.list_detail', >(r'(?P[\w-]+)/$', 'object_detail', election_detail_info, > 'election_detail'), > ) > > and then in your election models: > def get_absolute_url(self): > return ('election_detail', (), { 'slug': self.slug, }) > > 2008/4/22 jeffself <[EMAIL PROTECTED]>: > > > > > Here's the elections model: > > class Election(models.Model): > >uuid = UUIDField(primary_key=True, editable=False) > >election_name = models.CharField(max_length=100, unique=True) > >slug = models.SlugField(prepopulate_from=("election_name",), > > unique=True) > >election_date = models.DateField() > > >class Meta: > >ordering = ('-election_date',) > > >class Admin: > >list_display = ('election_name', 'election_date') > >list_per_page = 20 > > >def __unicode__(self): > >return self.election_name > > >def get_absolute_url(self): > >return ('django.views.generic.list_detail.object_detail', (), > >{ 'slug': self.slug, }) > >get_absolute_url = permalink(get_absolute_url) > > > Here's the precincts model: > > class Precinct(models.Model): > >precinct_number = models.CharField(max_length=4, blank=True) > >precinct_name = models.CharField(max_length=100) > >slug = > > models.SlugField(prepopulate_from=("precinct_number","precinct_name",),) > >precinct_location = models.CharField(max_length=100) > >precinct_address = models.CharField(max_length=100) > >precinct_photo = models.ImageField(upload_to="images/ > > precincts",blank=True) > >precinct_map = models.ImageField(upload_to="images/precincts/ > > maps",blank=True) > >precinct_status = models.BooleanField("Active",default=True) > > >class Meta: > >ordering = ('precinct_number',) > >unique_together = [("precinct_number", "precinct_name")] > > >class Admin: > >list_display = > > ('precinct_number','precinct_name','precinct_status') > >list_display_links = ('precinct_number', 'precinct_name') > >list_filter = ('precinct_status',) > >list_per_page = 20 > >search_fields = > > ('precinct_name','precinct_location','precinct_address') > >fields = ( > >(None, { > >'fields': (('precinct_number', 'precinct_name'), > > 'slug', 'precinct_location', > > 'precinct_address', 'precinct_status') > >}), > >('Media', { > >'classes': 'collapse', > >'fields': ('precinct_photo','precinct_map') > >}) > >) > > >def __unicode__(self): > >return '%s %s' % (self.precinct_number, self.precinct_name) > > >def get_absolute_url(self): > >return ('django.views.generic.list_detail.object_detail', (), > >{ 'slug': self.slug, }) > >get_absolute_url = permalink(get_absolute_url) > > > On Apr 21, 9:39 pm, Michael <[EMAIL PROTECTED]> wrote: > > > You interested in answering the first part of my post? I can't really > > help > > > you with information like this... > > > > 2008/4/21 jeffself <[EMAIL PROTECTED]>: > > > > > I don't think thats it because if I reverse the order of the url's in > > > > the root urls.py file and put precincts before elections, then > > > > precincts items work correctly but the election items point to > > > > precincts rather than elections. > > > > > On Apr 21, 3:52 pm, Michael <[EMAIL PROTECTED]> wrote: > > > > > How are you getting the URL? Is there something in your models that > > is > > > > > defining the absolute URL? or are you using the Revese lookup? > > > > > > Chances are because they are just copies of one another that you > > forgot > > > > to > > > > > change one of the files and they still have the get_absolute_url > > > > referring > > > > > to the elections one, > > > > > > Michael > > > > > > On Mon, Apr 21, 2008 at 12:48 PM, 小龙 <[EMAIL PROTECTED]> wrote: > > > > > > Show me -- Settings.py > > > > > > > 2008/4/21, jeffself <[EMAIL PROTECTED]>: > > > > > > > > I've got a project that contains two apps (elections and > > precincts). > > > > > > > My root urls.py looks like this: > > > > > > > from django.conf.urls.defaults import * > > > > > > > urlpatterns = patterns('', > > > > > > >
Re: django searching/checking for user
Gotcha, sorry about that, didn't quite get what was being asked. You can do a full text search in your database or implement some external software for search. Also if you have a field that you want items to be alike for you can always bounce off the database for items like that. I have implemented various forms of search and am right now of the opinion that my sites won't have too many hits to justify bouncing my searches off of google or yahoo. Those might be too generic for you, you might need to look into writing some custom code, but searching through the text of one model to find something similar should be fairly easy especially if you don't mind using some database power. I can't say I know anything speficially Django to accomplish this, so you are probably going to have to look for something else. Anyone else have any ideas? On Wed, Apr 23, 2008 at 6:11 PM, Aljosa Mohorovic < [EMAIL PROTECTED]> wrote: > > On Apr 23, 8:32 pm, Michael <[EMAIL PROTECTED]> wrote: > > If you have auth and sessions working right in Django you can access a > > logged in user from the request (request.user) and user in auth if you > have > > AUTH_PROFILE_MODULE [1] in your settings you can get the profile from > the > > thanks for info, but i think i didn't explain that i already have a > working django site and i'm actually trying to enable users to search > for other users and also looking for site-wide search solution. > > Aljosa > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Announcing the Django Dash!
Apparently the design can be done before the dash: This is pretty straightforward. Your team’s hands stay off the keyboard until the Dash officially begins. You’re allowed paper mockups and design but no code. Now, wether that design can be done be someone that's not part of the core team, I don't know. E. On Apr 23, 8:15 pm, "Jorge Vargas" <[EMAIL PROTECTED]> wrote: > I'm a bit concern about that. my main development team is composed of > 3 people one back one designer and one that takes care the the first > two not killing each other. looking at the ratings it seems that if we > take one of our 3 people out then we'll lose many points. and chance > to get 3? maybe by popular demand?On Wed, Apr 23, 2008 at 11:25 AM, Eric > <[EMAIL PROTECTED]> wrote: > > > I see that you can have a team of two, does that include a designer? > > > On Apr 14, 2:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > Jonathan, > > > > I consider those to be utility libraries (unlikely to comprise your > > > entire app) and should be fine for use. You may want to document what > > > versions you will be using to package with your project/application so > > > that the judges can replicate. > > > > Daniel > > > > On Apr 13, 7:46 pm, Jonathan Lukens <[EMAIL PROTECTED]> wrote: > > > > > What about Python libraries like PIL or ReportLab? > > > > > On Apr 11, 10:42 pm, "Daniel Lindsley" <[EMAIL PROTECTED]> wrote: > > > > > > We'd like to announce the firstDjangoDash > > > > > (http://www.djangodash.com/) to the community.DjangoDashis a web > > > > > application building competition forDjangodevelopers. The gist is > > > > > that you and (optionally) one other person can form a team and have > > 48 > > > > > hours to crank out a fullDjangoapplication. Your application will > > > > > then be pitted against others for bragging rights (and hopefully some > > > > > prizes). > > > > > > == > > > > > > What IsDjangoDash? > > > > > A 48 hour, start-to-finish race to produce the bestDjango-based web > > > > > application you can. Mostly for fun/bragging rights but we're working > > > > > on upping the ante. > > > > > > Who Can Compete? > > > > > Anyone but myself and (hopefully) three other judges, though this is > > > > > subject to change depending on popularity. > > > > > > When Is It? > > > > > We'll be hosting theDashon May 31 - June 1, 2008. > > > > > > Where? > > > > > We're running this over the web, so you can be anywhere you like. > > > > > Coffee shop, work (though we're not responsible for the ramifications > > > > > of that one), at home, wherever you can find internet access and > > > > > power. > > > > > > How Can I Compete? > > > > > First, please peruse the rules and judging information > > athttp://www.djangodash.com/. We will be opening registration for teams > > > > > on May 3, 2008. You're not allowed to start anything but ideas and > > > > > paper mockups until the competition begins on May 31, 2008. > > > > > > Why? > > > > > It's a chance to test yourself and push your limits. A chance to show > > > > > people what you're capable of. Maybe some exposure. But mostly > > because > > > > > we've found competitions like this to be a lot of fun. > > > > > > == > > > > > > More details can be found athttp://www.djangodash.com/. We will keep > > > > > it updated as things develop. If you're interested in competing in > > theDash, we'd appreciate if you'd fill out the mini-email form on the > > > > > front page so we can get an idea of how many people are interested. > > > > > > How can I help out? > > > > > TheDashis really missing two things right now. First, we'd like to > > > > > have three fair judges signed on to help judge the apps once the > > > > > competition is over. Second, we're looking for sponsors who can > > > > > provide prizes as awards. No minimum/maximum dollar value is > > > > > required/requested. More details on this can be found > > athttp://www.djangodash.com/sponsors/. > > > > > > Thanks and hope to see some of you competing! > > > > > > Daniel Lindsley > > > > > Toast Drivenhttp://www.toastdriven.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.
On Apr 23, 10:29 pm, Jay <[EMAIL PROTECTED]> wrote: > In the django docs I see that you can easily make a foreign key by > referencing the model: > > manufacturer = models.ForeignKey('production.Manufacturer') > > ...but it feels like maybe stepping outside the "django way." You can also just import the model itself from the other app and use it directly. This works just fine as long as you don't need cross references, i.e. app A importing app B importing app A. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.
I was thinking along the same lines-- it's more of a single, big app than a bunch of portables. And I was worried about models.py becoming too unwieldy. Thanks a lot! On Apr 23, 4:38 pm, "Erik Vorhes" <[EMAIL PROTECTED]> wrote: > There's nothing wrong with parceling out models across different apps. > And unless you're planning on distributing each app separately, don't > worry about cross-app dependencies. > > In this case, I'd encourage you to--since you'll probably want to do > more than just book-related stuff with your people. (The same could be > said about the books.) > > Another reason to have 2 apps for these models is overall growth of > models.py. The more code that's there, the harder it becomes to edit. > (I'm in the process of parceling out a bunch of models myself. Don't > give yourself that headache!) > > E > > > > On Wed, Apr 23, 2008 at 3:29 PM, Jay <[EMAIL PROTECTED]> wrote: > > > I'm working on a project which for the purposes of this conversation > > we could say is about authors writing and sharing books. > > > My tendency is to want to make an app called "people" and an app > > called "books," as these are two different models in my mind. A > > person has certain attributes which would be defined in the "person" > > model, and the book has certain attributes which would be defined in > > the "book" model. > > > For some reason it's weirding me out to put these in the same app. I > > think because seeing tables like people_book or books_person doesn't > > feel right. I imagine something more like: > > > books_book > > books_genre > > people_person > > people_group > > people_person_contacts > > > But I need to make the link between the author (person) and the book. > > In the django docs I see that you can easily make a foreign key by > > referencing the model: > > > manufacturer = models.ForeignKey('production.Manufacturer') > > > ...but it feels like maybe stepping outside the "django way." > > > I know there's no definitive answer, but at what point do you > > typically decide that something belongs in it's own app? Is it > > typical to dump everything into a single app? > > -- > portfolio:http://textivism.com/ > blog:http://erikanderica.org/erik/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: mod_python or fcgi
On Apr 24, 12:57 am, Rufman <[EMAIL PROTECTED]> wrote: > Hey > > I was wondering: Is Django faster and stabler using mod_python or > fcgi? > > I read that mod_python can be a memory hog...what are the concrete > advantages of using fcgi or mod_python for that matter? That mod_python can be a memory hog is a bit of a myth. Yes it does have a base level memory consumption which is a bit more than necessary, but complaints about mod_python being really fat actually stem mostly from having a Python installation that didn't provide a shared library for Python. Lack of a shared library results in Python static library being incorporated in mod_python Apache module. When that was then loaded, because address relocations had to be performed, it became process local memory, thus adding a few MB to size of process. If shared library for Python is correctly used, this doesn't occur. As a result, the per process memory requirements of mod_python and fastcgi aren't that much different when looked at in the greater scheme of things, in as much as your actual Django application is chewing up 40-60MB of memory where as mod_python and fastcgi will be a lot less than that. In other words, be more worried about how much memory your Django application is chewing up rather than the hosting mechanism. That all said, mod_wsgi is possibly a better choice than both. This is because in its mode where it works like mod_python it has less base level memory overhead than mod_python. On top of that it also supports a mode which gives similar properties to fastcgi. Thus mod_wsgi can do what both of these other systems do in the one package. The mod_wsgi package also has less performance overheads, although like with memory, the real bottleneck is your Django application, plus any database accesses. Other things you need to consider are whether you use Apache prefork or worker MPM. With prefork you will have a lot more instances of your fat Django application, thus overall memory usage is more. You should therefore look at whether your application is multithread safe and use worker MPM instead, or use mod_wsgi daemon mode with a single or small number of multithread processes. Graham --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'dict' object has no attribute 'autoescape'
On Wed, Apr 23, 2008 at 6:59 PM, falcon <[EMAIL PROTECTED]> wrote: > 94. if (context.autoescape and not isinstance(output, > SafeData)) or isinstance(output, EscapeData): Right there's your problem. you've ended up passing a plain dictionary someplace where Django was expecting you to pass an instance of Context. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Calling self.related_object.save() from self.save() ???
On Wed, Apr 23, 2008 at 11:09 AM, Don Spaulding <[EMAIL PROTECTED]> wrote: > > > > On Apr 22, 11:24 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > On Tue, 2008-04-22 at 13:47 -0700, Don Spaulding wrote: > > > > [...] > > > > > I try to do something like this: > > > > > order = Order() > > > order.save() > > > order.items.create(price=Decimal("5.00")) > > > order.total #gives me 0 > > > order.save() > > > order.total #gives me the correct order.total > > > > > My guess is that even though I've saved the item before calling > > > order.save(), the order objects still doesn't know that the new item > > > is related to it. Anybody know if this is expected behavior? > > > > Yes, it is expected. As Jorge noted, the "order" instance is a snapshot > > of the data at one moment in time, not a live update. > > > Thanks Malcolm and Jorge. I didn't understand Jorge's response the > first couple times I read it, but now it seems a bit clearer. > sry for that sometimes I sound confusing. > I can accept that the item's self.order is stale in Item.save(). But > my use case is still "Every time I add an item to an order, the > order's total needs updated". How can I force the order to hit the DB > again to find all of its (freshly) related objects? I believe the only way is how you are doing it. now let me ask a question why you need that? can't this be done in the controller? are you updating the price total many times per call? why not do it all in memory and then save ones? if you take all that out of the model and into the controller (maybe even a function) you could do something like this. new_order = Order() new_order.total = sum(new_order.items.all()) order.save() or I'm missing something? > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
'dict' object has no attribute 'autoescape'
Hi, A year or two ago I created a small web application in django. I've now brought it out of retirement and am trying to get it up and running with the latest svn trunk code. I realize there have been many changes to django in the mean time, however, the error I am getting just doesn't make sense to me. According to google, there is a bug ticket which mentions this error message but I don't understand what it is saying. I get the following error when I try to go to a django based webpage: AttributeError at /report/1/ 'dict' object has no attribute 'autoescape' (/report/1/ is a path I have set up with template, etc.) If any one can make sense of the following errors, please take a look: Environment: Request Method: GET Request URL: http://192.168.4.239:8000/report/1/ Django Version: 0.97-pre-SVN-7435 Python Version: 2.4.3 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.humanize', 'kublai.reports'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Template error: In template unknown source, error at line 1 Caught an exception while rendering: 'dict' object has no attribute 'autoescape' 1 : hello world, {{yo}} Traceback: File "/usr/lib/python2.4/site-packages/django/template/debug.py" in render_node 71. result = node.render(context) File "/usr/lib/python2.4/site-packages/django/template/debug.py" in render 94. if (context.autoescape and not isinstance(output, SafeData)) or isinstance(output, EscapeData): Exception Type: AttributeError at /report/1/ Exception Value: 'dict' object has no attribute 'autoescape' --- What is the error? What do I need to start looking at? If you are looking for an internship in the New York area, as long as you are comfortable with databases, unix environment, python and django, email me :) Your first job will be to get this running :) Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Announcing the Django Dash!
I'm a bit concern about that. my main development team is composed of 3 people one back one designer and one that takes care the the first two not killing each other. looking at the ratings it seems that if we take one of our 3 people out then we'll lose many points. and chance to get 3? maybe by popular demand? On Wed, Apr 23, 2008 at 11:25 AM, Eric <[EMAIL PROTECTED]> wrote: > > I see that you can have a team of two, does that include a designer? > > > > On Apr 14, 2:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > Jonathan, > > > > I consider those to be utility libraries (unlikely to comprise your > > entire app) and should be fine for use. You may want to document what > > versions you will be using to package with your project/application so > > that the judges can replicate. > > > > Daniel > > > > On Apr 13, 7:46 pm, Jonathan Lukens <[EMAIL PROTECTED]> wrote: > > > > > What about Python libraries like PIL or ReportLab? > > > > > On Apr 11, 10:42 pm, "Daniel Lindsley" <[EMAIL PROTECTED]> wrote: > > > > > > We'd like to announce the firstDjangoDash > > > > (http://www.djangodash.com/) to the community.DjangoDashis a web > > > > application building competition forDjangodevelopers. The gist is > > > > that you and (optionally) one other person can form a team and have 48 > > > > hours to crank out a fullDjangoapplication. Your application will > > > > then be pitted against others for bragging rights (and hopefully some > > > > prizes). > > > > > > == > > > > > > What IsDjangoDash? > > > > A 48 hour, start-to-finish race to produce the bestDjango-based web > > > > application you can. Mostly for fun/bragging rights but we're working > > > > on upping the ante. > > > > > > Who Can Compete? > > > > Anyone but myself and (hopefully) three other judges, though this is > > > > subject to change depending on popularity. > > > > > > When Is It? > > > > We'll be hosting theDashon May 31 - June 1, 2008. > > > > > > Where? > > > > We're running this over the web, so you can be anywhere you like. > > > > Coffee shop, work (though we're not responsible for the ramifications > > > > of that one), at home, wherever you can find internet access and > > > > power. > > > > > > How Can I Compete? > > > > First, please peruse the rules and judging information > athttp://www.djangodash.com/. We will be opening registration for teams > > > > on May 3, 2008. You're not allowed to start anything but ideas and > > > > paper mockups until the competition begins on May 31, 2008. > > > > > > Why? > > > > It's a chance to test yourself and push your limits. A chance to show > > > > people what you're capable of. Maybe some exposure. But mostly because > > > > we've found competitions like this to be a lot of fun. > > > > > > == > > > > > > More details can be found athttp://www.djangodash.com/. We will keep > > > > it updated as things develop. If you're interested in competing in > theDash, we'd appreciate if you'd fill out the mini-email form on the > > > > front page so we can get an idea of how many people are interested. > > > > > > How can I help out? > > > > TheDashis really missing two things right now. First, we'd like to > > > > have three fair judges signed on to help judge the apps once the > > > > competition is over. Second, we're looking for sponsors who can > > > > provide prizes as awards. No minimum/maximum dollar value is > > > > required/requested. More details on this can be found > athttp://www.djangodash.com/sponsors/. > > > > > > Thanks and hope to see some of you competing! > > > > > > Daniel Lindsley > > > > Toast Drivenhttp://www.toastdriven.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Avoiding the ThreadLocals hack - anything new in NewForms-Admin?
How about this: Set your model's user field so editable=False Sub-class ModelAdmin Override its `save_add` method, setting form.data['user'] = request.user then calling the super method --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Q query question
> I'm experimenting (so far without success) with a bunch of ways to try > to turn a chain into a queryset. If anybody has any tips, I will be > grateful. Ok, got it, I think - using the idiom from this snippet: http://www.djangosnippets.org/snippets/26/ (My problem was using the chain to populate the choices for a ChoiceField.) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django searching/checking for user
On Apr 23, 8:32 pm, Michael <[EMAIL PROTECTED]> wrote: > If you have auth and sessions working right in Django you can access a > logged in user from the request (request.user) and user in auth if you have > AUTH_PROFILE_MODULE [1] in your settings you can get the profile from the thanks for info, but i think i didn't explain that i already have a working django site and i'm actually trying to enable users to search for other users and also looking for site-wide search solution. Aljosa --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: UnicodeDecodeError when rendering template
.96 is not unicode enabled, if you need to handle unicode strings you will need to use SVN. On Apr 23, 4:23 pm, "Boris Ozegovic" <[EMAIL PROTECTED]> wrote: > On 4/23/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > Are you using .96 or SVN? > > 0.96 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: UnicodeDecodeError when rendering template
On 4/23/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Are you using .96 or SVN? 0.96 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: UnicodeDecodeError when rendering template
Are you using .96 or SVN? On Apr 23, 3:56 pm, "Boris Ozegovic" <[EMAIL PROTECTED]> wrote: > I am getting UnicodeDecodeError, 'ascii' codec can't decode byte 0xc4. > I using utf-8 in forms.py, and also, my template is saved as UTF-8. > And it doesn't work. Any ideas? > > This is part of my forms.py > > -- > # -*- coding: utf-8 -*- > > CHOICES1 = ( > ('child', 'Dječja'), > ('general', 'Opća'), > ) > > class NewExamForm(forms.Form): > anamnesis = forms.ChoiceField(choices=CHOICES1, > widget=forms.RadioSelect()) > -- > > And this is par of my template: > > Tip anamneze:{{ form.anamnesis }} --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
UnicodeDecodeError when rendering template
I am getting UnicodeDecodeError, 'ascii' codec can't decode byte 0xc4. I using utf-8 in forms.py, and also, my template is saved as UTF-8. And it doesn't work. Any ideas? This is part of my forms.py -- # -*- coding: utf-8 -*- CHOICES1 = ( ('child', 'Dječja'), ('general', 'Opća'), ) class NewExamForm(forms.Form): anamnesis = forms.ChoiceField(choices=CHOICES1, widget=forms.RadioSelect()) -- And this is par of my template: Tip anamneze:{{ form.anamnesis }} --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: At what point does a model get its own app? Wigging as I try to adjust to the Django way.
There's nothing wrong with parceling out models across different apps. And unless you're planning on distributing each app separately, don't worry about cross-app dependencies. In this case, I'd encourage you to--since you'll probably want to do more than just book-related stuff with your people. (The same could be said about the books.) Another reason to have 2 apps for these models is overall growth of models.py. The more code that's there, the harder it becomes to edit. (I'm in the process of parceling out a bunch of models myself. Don't give yourself that headache!) E On Wed, Apr 23, 2008 at 3:29 PM, Jay <[EMAIL PROTECTED]> wrote: > > I'm working on a project which for the purposes of this conversation > we could say is about authors writing and sharing books. > > My tendency is to want to make an app called "people" and an app > called "books," as these are two different models in my mind. A > person has certain attributes which would be defined in the "person" > model, and the book has certain attributes which would be defined in > the "book" model. > > For some reason it's weirding me out to put these in the same app. I > think because seeing tables like people_book or books_person doesn't > feel right. I imagine something more like: > > books_book > books_genre > people_person > people_group > people_person_contacts > > But I need to make the link between the author (person) and the book. > In the django docs I see that you can easily make a foreign key by > referencing the model: > > manufacturer = models.ForeignKey('production.Manufacturer') > > ...but it feels like maybe stepping outside the "django way." > > I know there's no definitive answer, but at what point do you > typically decide that something belongs in it's own app? Is it > typical to dump everything into a single app? > > > -- portfolio: http://textivism.com/ blog: http://erikanderica.org/erik/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MultiValueField Question
As above, I have this working now. Any suggestions on wrapping individual items in items from a multivaluefield in tds? Thanks. -jsnyder --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
At what point does a model get its own app? Wigging as I try to adjust to the Django way.
I'm working on a project which for the purposes of this conversation we could say is about authors writing and sharing books. My tendency is to want to make an app called "people" and an app called "books," as these are two different models in my mind. A person has certain attributes which would be defined in the "person" model, and the book has certain attributes which would be defined in the "book" model. For some reason it's weirding me out to put these in the same app. I think because seeing tables like people_book or books_person doesn't feel right. I imagine something more like: books_book books_genre people_person people_group people_person_contacts But I need to make the link between the author (person) and the book. In the django docs I see that you can easily make a foreign key by referencing the model: manufacturer = models.ForeignKey('production.Manufacturer') ...but it feels like maybe stepping outside the "django way." I know there's no definitive answer, but at what point do you typically decide that something belongs in it's own app? Is it typical to dump everything into a single app? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: python-ldap: searching without specifying an OU?
This fixed it! http://peeved.org/blog/2007/11/20/ By adding this line after 'import ldap', I was able to search from the root level without specifying an OU: ldap.set_option(ldap.OPT_REFERRALS, 0) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Relating two objects in a model with eachother
Hi, I have got a Person model, and I need create a spouse field. When editing Jane, I need to be able to John as her spouse. Jane cannot have more than one spouse, and only one person can have Jane as spouse. The relation needs to be symmetrical. I have tried both ManyToOne and ForeignKey, but I don't seem to be able to grok this. Any suggestions? -- Thomas / kalve --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Reusing a child block in an inherited template
Hi, I'm wondering if the following is possible with django templates. I would like to override a given parent block, while maintaining the contents of it's child block: base.html: {% block firstblock %} Bla bla bla {% block secondblock %} ble ble ble {% endblock %} {% endblock %} inherited.html: {% extends "base.html" %} {% block firstblock %} this is being overriden {% block secondblock %} {{ block.super }} {% endblock %} {% endblock %} I have a case similar with this one, which is not working as I thought it would ( {{ block.super }} is outputting nothing, instead of the value from the parent template). Might I be doing something wrong or is this the expected behavior? thanks, Filipe Correia --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django searching/checking for user
If you have auth and sessions working right in Django you can access a logged in user from the request (request.user) and user in auth if you have AUTH_PROFILE_MODULE [1] in your settings you can get the profile from the user with the function get_profile() [1] http://www.djangoproject.com/documentation/settings/#auth-profile-module look at this page for documentation: http://www.djangoproject.com/documentation/authentication/ And specifically here for extending the user model: http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users On Wed, Apr 23, 2008 at 1:23 PM, Aljosa Mohorovic < [EMAIL PROTECTED]> wrote: > > i was wondering if there is django related solution for searching/ > checking if user (django.contrib.auth + profile) exists or to retrieve > similar results? > > so if i have: > search_for = request.POST['search_for'] > > do i split search_for and basically do sql LIKE search through table > fields or is there some other/better solution? > what about pylucene/lucene or something similar? > when to use simple sql search and when some search engine software? > > Aljosa > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FilePathField and get_FIELD_url
Nice one! That's better than implementing a new field because I am using FilePathField in one model only --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FilePathField and get_FIELD_url
And you don't even need to import os there (oops) On Wed, Apr 23, 2008 at 1:53 PM, Michael <[EMAIL PROTECTED]> wrote: > Add this to your model: > > def get_FILE_url(self): > import os > from django.conf import settings > return '/' + str(self.FILE).split(settings.MEDIA_ROOT)[-1] > > tadah you have your method without rewriting django fields > > > > On Wed, Apr 23, 2008 at 1:22 PM, [EMAIL PROTECTED] < > [EMAIL PROTECTED]> wrote: > > > > > You could either do that, or just add a method to your model, both > > would employ the same logic, it's just a question of reusable vs. time > > to implement. > > > > On Apr 23, 12:17 pm, skam <[EMAIL PROTECTED]> wrote: > > > Okay, that's a valid reason, but I really want these files to be into > > > MEDIA_ROOT and get file's absolute url using a get_FIELD_url method. > > > Is subclassing the field and implementing contribute_to_class method a > > > good idea? > > > > > > On 23 Apr, 18:47, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > > wrote: > > > > > > > FilePathField can refer to any location on your system, there is no > > > > reason to believe it is below the MEDIA_ROOT. > > > > > > > > > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FilePathField and get_FIELD_url
Add this to your model: def get_FILE_url(self): import os from django.conf import settings return '/' + str(self.FILE).split(settings.MEDIA_ROOT)[-1] tadah you have your method without rewriting django fields On Wed, Apr 23, 2008 at 1:22 PM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > You could either do that, or just add a method to your model, both > would employ the same logic, it's just a question of reusable vs. time > to implement. > > On Apr 23, 12:17 pm, skam <[EMAIL PROTECTED]> wrote: > > Okay, that's a valid reason, but I really want these files to be into > > MEDIA_ROOT and get file's absolute url using a get_FIELD_url method. > > Is subclassing the field and implementing contribute_to_class method a > > good idea? > > > > On 23 Apr, 18:47, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > > FilePathField can refer to any location on your system, there is no > > > reason to believe it is below the MEDIA_ROOT. > > > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FTP upload of files threw django
[EMAIL PROTECTED] wrote: Hello All, I've been working on a quality control portal that uses some features of django. The application is now completely running but the upload of large data files is quit slow. I've been looking around how to speed things up and the only thing i saw was using ftp upload instead of the http file upload. I want to incorporate this feature in the existing frontend, is there something in the newforms library that already covers some of this ? If not is it possible to put the ftp upload under the file selection box created by the newforms library. I've never heard of using an http form to handle an ftp file upload. If an http form can do it, you can have your templates spit it out. If you do end up doing ftp upload, django won't be what handles it, as it is run through your http server. are there any snippets around that show how to use the ftp upload from a webapplication ? I haven't even found anything that says how to do it with straight html. Good luck! Jeff Anderson signature.asc Description: OpenPGP digital signature
django searching/checking for user
i was wondering if there is django related solution for searching/ checking if user (django.contrib.auth + profile) exists or to retrieve similar results? so if i have: search_for = request.POST['search_for'] do i split search_for and basically do sql LIKE search through table fields or is there some other/better solution? what about pylucene/lucene or something similar? when to use simple sql search and when some search engine software? Aljosa --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FilePathField and get_FIELD_url
You could either do that, or just add a method to your model, both would employ the same logic, it's just a question of reusable vs. time to implement. On Apr 23, 12:17 pm, skam <[EMAIL PROTECTED]> wrote: > Okay, that's a valid reason, but I really want these files to be into > MEDIA_ROOT and get file's absolute url using a get_FIELD_url method. > Is subclassing the field and implementing contribute_to_class method a > good idea? > > On 23 Apr, 18:47, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > FilePathField can refer to any location on your system, there is no > > reason to believe it is below the MEDIA_ROOT. > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FilePathField and get_FIELD_url
Okay, that's a valid reason, but I really want these files to be into MEDIA_ROOT and get file's absolute url using a get_FIELD_url method. Is subclassing the field and implementing contribute_to_class method a good idea? On 23 Apr, 18:47, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > FilePathField can refer to any location on your system, there is no > reason to believe it is below the MEDIA_ROOT. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FilePathField and get_FIELD_url
FilePathField can refer to any location on your system, there is no reason to believe it is below the MEDIA_ROOT. On Apr 23, 11:14 am, skam <[EMAIL PROTECTED]> wrote: > It seems that get_FIELD_url accessor method is not available while > using FilePathField into my models. > Is there any reason why it hasn't been implemented? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FilePathField and get_FIELD_url
It seems that get_FIELD_url accessor method is not available while using FilePathField into my models. Is there any reason why it hasn't been implemented? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Search with Stemming, Accents and Entities
I am implementing an academic publications database, and am looking for a search solution. I need at the very least Stemming and Accented Characters support (i.e.: searching for "alvarez" returns "álvarez" and v.v.). Some of the fields have a tinymce editor, so the data is stored with html entities. It would be very nice to be able to also search in these fields (i.e.: searching for 'alvarez' returns a record that contains 'lvarez'). Recommendations for apps or 3rd party engines or personal experience implementing something like this is very welcome. Using trunk + MySQL. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best practices for sending bulk (+4000) mail in Django / Python
On Thu, 24 Apr 2008 00:11:02 +1000, "Malcolm Tredinnick" <[EMAIL PROTECTED]> said: > Another possibility is to use some sort of queueing system or service so > that the emails are inserted into the queue and then sent over an > extended period of time. django-mailer is intended to be used for exactly this. It's not usable yet, but could always do with more people driving it to completion. See http://code.google.com/p/django-mailer/ James -- James Tauber http://jtauber.com/ journeyman of somehttp://jtauber.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best practices for sending bulk (+4000) mail in Django / Python
I haven't send near 8000 messages yet, but what I did was a combination of what Malcom suggested. I setup a model to queue the messages (pickled email.MIMEMultipart) with a priority, and a cron that runs occasionally to dump N messages per mx domain over time so the mailing trickles out. to the local mailserver that actually does the sending. Since the connection to the local mailserver is done once and messages are batched it should eliminate the overhead of sending one by one. Then for bounce detection, import from Mailman and let it check the POP3 account of the sending account. I was really surprised at how easy it was. Python has all of the mail stuff build in, and Mailman adds the bounce detection just by importing its module. My point is don't be afraid to roll your own solution, its not hard at all. For example the pop3 check/bounce detection which might seem complicated is just a few lines of code: def check_pop3_bounces(server,user,password): messages=[] s=poplib.POP3(server) s.user(user) s.pass_(password) resp, items, octets = s.list() bounced=Set() # items will be a list of 'MSG ID, SIZE' for item in items:#[:5]: id,size=item.split() resp,text,octets = s.retr(id) text = string.join(text, "\n") file = StringIO.StringIO(text) message=email.message_from_file(file) addr=BouncerAPI.ScanMessages('somename',message) s.dele(id) # delete it, we'll forward non-junk if isinstance(addr,BouncerAPI._Stop): pass # junk message elif addr: for a in addr: bounced.add(a) else: valid_messages.append(message) s.quit() return bounced,valid_messages --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Announcing the Django Dash!
Yes. That's including a designer. I base this on his mention of the team sketching out the site design. -justin On Wed, Apr 23, 2008 at 11:25 AM, Eric <[EMAIL PROTECTED]> wrote: > > I see that you can have a team of two, does that include a designer? > > On Apr 14, 2:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > Jonathan, > > > > I consider those to be utility libraries (unlikely to comprise your > > entire app) and should be fine for use. You may want to document what > > versions you will be using to package with your project/application so > > that the judges can replicate. > > > > Daniel > > > > On Apr 13, 7:46 pm, Jonathan Lukens <[EMAIL PROTECTED]> wrote: > > > > > What about Python libraries like PIL or ReportLab? > > > > > On Apr 11, 10:42 pm, "Daniel Lindsley" <[EMAIL PROTECTED]> wrote: > > > > > > We'd like to announce the firstDjangoDash > > > > (http://www.djangodash.com/) to the community.DjangoDashis a web > > > > application building competition forDjangodevelopers. The gist is > > > > that you and (optionally) one other person can form a team and have > 48 > > > > hours to crank out a fullDjangoapplication. Your application will > > > > then be pitted against others for bragging rights (and hopefully > some > > > > prizes). > > > > > > == > > > > > > What IsDjangoDash? > > > > A 48 hour, start-to-finish race to produce the bestDjango-based web > > > > application you can. Mostly for fun/bragging rights but we're > working > > > > on upping the ante. > > > > > > Who Can Compete? > > > > Anyone but myself and (hopefully) three other judges, though this is > > > > subject to change depending on popularity. > > > > > > When Is It? > > > > We'll be hosting theDashon May 31 - June 1, 2008. > > > > > > Where? > > > > We're running this over the web, so you can be anywhere you like. > > > > Coffee shop, work (though we're not responsible for the > ramifications > > > > of that one), at home, wherever you can find internet access and > > > > power. > > > > > > How Can I Compete? > > > > First, please peruse the rules and judging information athttp:// > www.djangodash.com/. We will be opening registration for teams > > > > on May 3, 2008. You're not allowed to start anything but ideas and > > > > paper mockups until the competition begins on May 31, 2008. > > > > > > Why? > > > > It's a chance to test yourself and push your limits. A chance to > show > > > > people what you're capable of. Maybe some exposure. But mostly > because > > > > we've found competitions like this to be a lot of fun. > > > > > > == > > > > > > More details can be found athttp://www.djangodash.com/. We will keep > > > > it updated as things develop. If you're interested in competing in > theDash, we'd appreciate if you'd fill out the mini-email form on the > > > > front page so we can get an idea of how many people are interested. > > > > > > How can I help out? > > > > TheDashis really missing two things right now. First, we'd like to > > > > have three fair judges signed on to help judge the apps once the > > > > competition is over. Second, we're looking for sponsors who can > > > > provide prizes as awards. No minimum/maximum dollar value is > > > > required/requested. More details on this can be found athttp:// > www.djangodash.com/sponsors/. > > > > > > Thanks and hope to see some of you competing! > > > > > > Daniel Lindsley > > > > Toast Drivenhttp://www.toastdriven.com/ > > > -- Justin Lilly Web Developer/Designer http://justinlilly.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Announcing the Django Dash!
I see that you can have a team of two, does that include a designer? On Apr 14, 2:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Jonathan, > > I consider those to be utility libraries (unlikely to comprise your > entire app) and should be fine for use. You may want to document what > versions you will be using to package with your project/application so > that the judges can replicate. > > Daniel > > On Apr 13, 7:46 pm, Jonathan Lukens <[EMAIL PROTECTED]> wrote: > > > What about Python libraries like PIL or ReportLab? > > > On Apr 11, 10:42 pm, "Daniel Lindsley" <[EMAIL PROTECTED]> wrote: > > > > We'd like to announce the firstDjangoDash > > > (http://www.djangodash.com/) to the community.DjangoDashis a web > > > application building competition forDjangodevelopers. The gist is > > > that you and (optionally) one other person can form a team and have 48 > > > hours to crank out a fullDjangoapplication. Your application will > > > then be pitted against others for bragging rights (and hopefully some > > > prizes). > > > > == > > > > What IsDjangoDash? > > > A 48 hour, start-to-finish race to produce the bestDjango-based web > > > application you can. Mostly for fun/bragging rights but we're working > > > on upping the ante. > > > > Who Can Compete? > > > Anyone but myself and (hopefully) three other judges, though this is > > > subject to change depending on popularity. > > > > When Is It? > > > We'll be hosting theDashon May 31 - June 1, 2008. > > > > Where? > > > We're running this over the web, so you can be anywhere you like. > > > Coffee shop, work (though we're not responsible for the ramifications > > > of that one), at home, wherever you can find internet access and > > > power. > > > > How Can I Compete? > > > First, please peruse the rules and judging information > > > athttp://www.djangodash.com/. We will be opening registration for teams > > > on May 3, 2008. You're not allowed to start anything but ideas and > > > paper mockups until the competition begins on May 31, 2008. > > > > Why? > > > It's a chance to test yourself and push your limits. A chance to show > > > people what you're capable of. Maybe some exposure. But mostly because > > > we've found competitions like this to be a lot of fun. > > > > == > > > > More details can be found athttp://www.djangodash.com/. We will keep > > > it updated as things develop. If you're interested in competing in > > > theDash, we'd appreciate if you'd fill out the mini-email form on the > > > front page so we can get an idea of how many people are interested. > > > > How can I help out? > > > TheDashis really missing two things right now. First, we'd like to > > > have three fair judges signed on to help judge the apps once the > > > competition is over. Second, we're looking for sponsors who can > > > provide prizes as awards. No minimum/maximum dollar value is > > > required/requested. More details on this can be found > > > athttp://www.djangodash.com/sponsors/. > > > > Thanks and hope to see some of you competing! > > > > Daniel Lindsley > > > Toast Drivenhttp://www.toastdriven.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GeoDjango: distance between PointFields problem
> > (1) What geographic fields are in your model, what type are they > > (e.g., PointField, etc.), and their SRID. > > A plain PointField, e.g.: ``location = PointField()``. I > believeGeoDjangodefaults to WGS84 for the SRID. > > > (2) The geometry type of the parameter you're passing to `distance`, > > and its SRID. > > A PointField from that same model containing lat/long pairs obtained > from the Google geocoder. > OK, so my first guess at what's going on is incorrect. You're calculating distances from one geodetic point to another -- this means that the units for both points are in degrees. Typically, the `distance` GeoQuerySet method returns values that are in the coordinate system of the field (e.g., if my field is SRID=32140, then the values returned are in meters because that is the unit used by the coordinate system). However, this is undesirable for geodetic coordinate systems because distances in units of degrees depend on your location -- for example, take a look at the spacing of longitude lines on a globe they get closer together at the poles and are farthest apart at the equator. Having distances returned in degrees is not optimal for humans who think in units of meters or miles which stay the same no matter where you're at. Thus, when using a geodetic coordinate system, such as WGS84 (the default, aka SRID=4326), a spherical distance calculation method is used instead which returns _meters_ (i.e., the PostGIS `distance_spheroid` function is used instead of `distance`). The large values may be due to the fact that they are large values to begin with -- it is ~2,029,313 meters from Chicago to Salt Lake City. At some point I wish the distance values would be `Distance` objects rather than number values, but at this point it would require a lot of internal hacking on internal Django ORM components I'll put off to another day. Just to be clear, there is only one PointField in the model, right? I ask because GeoQuerySet methods operate, by default, on the first geographic field encountered in the model -- if you have more than one geographic field then you may have to explicitly specify it in the first parameter (`qs = MyModel.objects.distance('point_field2', pnt)`). If you still think you're getting bogus values set up an example model and data set that exhibit the problem so that I can examine more closely. > So now that you know more about my setup, how would I find the > distance between two users in a model? from django.contrib.gis.measure import D # `Distance` object. qs = User.objects.distance(user1.point) for u in qs: print u, D(m=u.distance).mi # Printing out distance in miles. > Do you know of any simple-language introductions to working with GIS? > The best I've seen so far is the link below. That's a good link. Sticking with the projected vs. geographic topic, here are some other good resources: [1] "Map Projections", http://www.progonos.com/furuti/MapProj/CartIndex/cartIndex.html [2] "Coordinate Systems: PROJ.4, EPSG and OGC WKT", http://www.foss4g2006.org/contributionDisplay.py?contribId=139=42=1 Frank Warmerdam's FOSS4G 2006 presentation -- I can't recommend this one highly enough. [3] "The State Plane Coordinate System", http://welcome.warnercnr.colostate.edu/class_info/nr502/lg3/datums_coordinates/spcs.html Helps demystify state plane coordinate systems -- if working with US data you'll encounter it one of these projections sooner or later. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Q query question
On Apr 23, 9:00 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Complex Q-object combinations on trunk do have a few problems (bugs). It > turns out to be quite hard to get all the combinations working > correctly. This is one of the areas that development of the > queryset-refactor branch has devoted a lot of time to fixing, so things > will improve in trunk very soon (or you can try out your code on the > branch). Thanks, Malcolm. I want some features from queryset_refactor and some from newforms_admin, but none of them urgently (yet), so I think I'll work around the bug and wait. Looks like this is working in *most* cases (see below), and maybe simpler anyway: part1 = InventoryItem.objects.filter(product=self, onhand__gt=0) part2 = InventoryItem.objects.filter(product=self, inventory_date__range=(weekstart, thisdate), planned__gt=0, onhand__exact=0, received__exact=0) return itertools.chain(part1, part2) The itertools.chain works fine in situations where I just iterate thru the items. But in one case, I really need to return a queryset. (Tried turning the chain into a plain list, that did not work.) I'm experimenting (so far without success) with a bunch of ways to try to turn a chain into a queryset. If anybody has any tips, I will be grateful. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Show diff between fresh and running database schema
Malcolm Tredinnick schrieb: > On Wed, 2008-04-23 at 15:37 +0200, Thomas Guettler wrote: > >> Hi, >> >> has some one a script to show the difference between the >> running database and one which get created by syncdb? >> >> >> > This sounds like it would be really difficult (complex) to make it work > correctly. The output from a database tool is going to include stuff > that you don't necessarily care about (e.g. constraints that are > auto-created with names in some cases), the table ordering may well be > different, The ordering of the columns is why I needed the diff in my case! I use psycopg2 copy_to and copy_from to dump some data from the production database into the test database. This failed, because the ordering changed. > I'm not > sure that comparing the output of one tool with the output of an > entirely different tool to check for differences is going to be a robust > solution. > Both files are created with the same tool: pg_dump -s. The diff of both files helped me to find the solution. Thank you Malcolm for your great work! Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
mod_python or fcgi
Hey I was wondering: Is Django faster and stabler using mod_python or fcgi? I read that mod_python can be a memory hog...what are the concrete advantages of using fcgi or mod_python for that matter? any ideas/tips, thanks Stephane --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Auto fill the form field???
This will get you started. The JS and the views needed are pretty easy. http://www.willarson.com/blog/?p=37 On Apr 23, 8:42 am, laspal <[EMAIL PROTECTED]> wrote: > Hi, > I have a form with the following field. > > 1)Title > 2)Descriptions > 3) No of person > 3) Drop down box containing the previous filled form title.. > > Now my question is how to auto fill the form field when a user choose > any title from the drop down box. > > I am doing that so that user can choose any title from the drop down > box and form field get auto fill from the previous value.. Now the > user can edit any field according to his requirement. > > So my question is does django gives any tool for this or do I have to > write java script for it..??? > > thanks... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best practices for sending bulk (+4000) mail in Django / Python
On Wed, 2008-04-23 at 07:03 -0700, gorans wrote: > Hi, > > I've been sending out email to a list of around 8000 people on a > monthly basis using django and was wondering whether there is a way to > optimise the process. > > Currently, I open a mail connection [ mail_connection = > SMTPConnection(fail_silently=True) ] and then loop through each > message calling the .send() method. > > however, this takes about 2 seconds per message which is ridiculous! Not to mention that with that many messages, there are going to be errors -- some permanent, some transient. Django's email system isn't designed to be a mass mailer on that scale. It's a whole other class of problem. > Is there are better way to do mass emailing to our subscribers? One immediate possibility that jumps to mind is to set up some mailing list software. Django sends email to the mailing list address and it then goes out to everybody. You'll need to configure things so that other people cannot post to the list, etc, but that's just a matter of configuration. If you use mailman (written in Python; well tested in production settings), you could fairly easily write some code to synchronise the mailman subscription list with whatever database table you are currently using to store the subscribers, I suspect. Another possibility is to use some sort of queueing system or service so that the emails are inserted into the queue and then sent over an extended period of time. Regards, Malcolm > > Cheers > > Goran > > > > -- I've got a mind like a... a... what's that thing called? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: can't save m2m fields using MyModel.objects.create(**kwargs) ?
On Wed, 2008-04-23 at 06:51 -0700, sector119 wrote: > Hi All > > Can I save m2m fields using MyModel.objects.create(**kwargs) ? If > kwargs contains 'm2m_field': [Ob1, Obj2, Obj3]. No. You need to save an object before it can be used in a many-to-many relation and create() is just a synonym for initialisation + save(). Regards, Malcolm -- The hardness of butter is directly proportional to the softness of the bread. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to use ImageField to save images to dynamic path
I'm not clear how it could be. Could you please explain it in detail? Many thanks! /BRs On Apr 23, 1:34 pm, "Eric Liu" <[EMAIL PROTECTED]> wrote: > Why don't you set 'images/' as a variant.then you can change it dynamically > > 2008/4/23, Rishabh Manocha <[EMAIL PROTECTED]>: > > > > > Yea, I don't think the method I described would work for directories > > (or at-least I can't figure out how). It does, however, work if you > > want to add something to a filename before saving it. The code I use > > is: > > > request.FILES['resume']['filename'] = request.POST['empid'] + "_" + > > request.FILES['resume']['filename'] > > > Best, > > > R > > > On Tue, Apr 22, 2008 at 5:52 PM, PENPEN <[EMAIL PROTECTED]> wrote: > > > > How do you mean of changing request.FILES there itself? > > > I tried to add the directory to request.FILES but failed. Django > > > ignored the directory and savethe image to the MEDIA_ROOT not > > > MEDIA_ROOT/images. > > > > class Thing(models.Model): > > > photo = models.ImageField( > > > upload_to='images/', blank=True, null=True) > > > > class ThingForm(ModelForm): > > > class Meta: > > > model = Thing > > > > def thing_add(request): > > > if request.method == 'POST': > > > if 'photo' in request.FILES: > > > request.FILES['photo']['filename'] = > > > ''.join(['test/',request.FILES['photo']['filename']]) > > > form = ThingForm(request.POST, request.FILES) > > > if form.is_valid(): > > > form.save() > > > else: > > > form = ThingForm() > > > > return render_to_response('iuv.html', {'form': form}) > > > > On Apr 21, 3:19 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > > > > I don't know if this answers your specific question, but this is > > being > > > > worked on, apparently -http://code.djangoproject.com/ticket/5361. > > > > > I had a similar requirement, where I wanted to dynamically append a > > > > model field to the filename before saving it. I ended up getting the > > > > model field's value from request.POST in the view, and changing > > > > request.FILES there itself. > > > > > Best, > > > > > R > > > > > On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote: > > > > > > I defined such a model: > > > > > > class Thing(models.Model): > > > > > photo = models.ImageField( > > > > >upload_to='images/', blank=True, null=True) > > > > > > Here is the form for this model: > > > > > class ThingForm(ModelForm): > > > > > class Meta: > > > > > model = Thing > > > > > > Now it could handle the image upload request and save images to > > > > > MEDIA_ROOT/images/ directory. > > > > > > My question is how to change theupload_tovalue dynamicly in the > > > > > > view. For example, I can get the user name in the view level, and I > > > > > want to save the image to that user's directory, e.g. 'avatar/ > > > > > username/'. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Show diff between fresh and running database schema
On Wed, 2008-04-23 at 15:37 +0200, Thomas Guettler wrote: > Hi, > > has some one a script to show the difference between the > running database and one which get created by syncdb? > > Up to now, I used the output of sqlall before and after > a model change. But it would be better to do the > diff of the running database. > > Up to now I do it like this: > > pg_dump -s databasename > running.schema > ./manage.py test myapp # Hit ctrl-c after test database was created. > pg_dump -s test_databasename > test.schema > diff test.schema running.schema > > Maybe something like this be implemented as new management command ... This sounds like it would be really difficult (complex) to make it work correctly. The output from a database tool is going to include stuff that you don't necessarily care about (e.g. constraints that are auto-created with names in some cases), the table ordering may well be different, models don't necessarily include all the fields in a database table... there's a whole maze of things that could be different. I'm not sure that comparing the output of one tool with the output of an entirely different tool to check for differences is going to be a robust solution. I think your current approach is a lot safer, since you at least understand the expected differences. Regards, Malcolm -- Experience is something you don't get until just after you need it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Running Tests: Stop at first error
On Wed, 2008-04-23 at 15:06 +0200, Thomas Guettler wrote: > Hi, > > if one unittest fails at the database level, often all following tests > fail with this error: >execute SQL failed: current transaction is aborted, commands ignored > until end of transaction block It's something that would be nice to fix, but it's not necessarily trivial. There was a discussion on django-dev about it a couple of months (maybe less) back, although it got a bit side-tracked by confusing cursor management in requests vs. cursor management in tests. > Is there a way to stop after the first failing test? No, there isn't. Regards, Malcolm -- Everything is _not_ based on faith... take my word for it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Q query question
On Wed, 2008-04-23 at 06:03 -0700, bobhaugen wrote: > Replying to myself with more clues: > > I see the problem: > > For this filter statement: > items = InventoryItem.objects.filter( > Q(inventory_date__range=(weekstart, thisdate), received__exact=0) > | > Q(onhand__gt=0)) > > ,,, the SQL generated looks like this: > SELECT > "orders_inventoryitem"."id","orders_inventoryitem"."producer_id","orders_inventoryitem"."product_id","orders_inventoryitem"."inventory_date","orders_inventoryitem"."planned","orders_inventoryitem"."received","orders_inventoryitem"."onhand" > FROM "orders_inventoryitem" WHERE > (("orders_inventoryitem"."inventory_date" BETWEEN 2008-04-21 AND > 2008-04-23 OR "orders_inventoryitem"."received" = 0.00 OR > "orders_inventoryitem"."onhand" > 0.00)) ORDER BY > "orders_inventoryitem"."product_id" ASC, > "orders_inventoryitem"."producer_id" ASC, > "orders_inventoryitem"."inventory_date" ASC'} > > So the SQL ORs all of the Q clauses, and does not separate the Q > clause that I thought should have been ANDed. Complex Q-object combinations on trunk do have a few problems (bugs). It turns out to be quite hard to get all the combinations working correctly. This is one of the areas that development of the queryset-refactor branch has devoted a lot of time to fixing, so things will improve in trunk very soon (or you can try out your code on the branch). Without spending too much time on it, though, it looks like your intuition about how Q-objects should work is pretty much correct and the SQL construction is just not behaving itself. Regards, Malcolm -- Borrow from a pessimist - they don't expect it back. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Language code as part of URL
Panos, Thanks for the links. I checked the conversation and the blog post, by they address issues I've already solved. What I'm really struggling with is the reverse() problem and how to cleanly move the language activation logic from middleware (Django's default mechanism) to the URL resolver. Wrt the language_id/language-code choice, I went for language codes and haven't run into any performance problems. I didn't quite understand when a complex join involving the language code would be needed and how that would make any significant difference in performance. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
can't save m2m fields using MyModel.objects.create(**kwargs) ?
Hi All Can I save m2m fields using MyModel.objects.create(**kwargs) ? If kwargs contains 'm2m_field': [Ob1, Obj2, Obj3]. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Show diff between fresh and running database schema
Hi, has some one a script to show the difference between the running database and one which get created by syncdb? Up to now, I used the output of sqlall before and after a model change. But it would be better to do the diff of the running database. Up to now I do it like this: pg_dump -s databasename > running.schema ./manage.py test myapp # Hit ctrl-c after test database was created. pg_dump -s test_databasename > test.schema diff test.schema running.schema Maybe something like this be implemented as new management command ... Any volunteers? Since pg_dump is only available for postgres, you would need something like for other DBs, too. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Language code as part of URL
Andrew, Thanks for your thoughts! > If the content is ultimately the same and you're simply offering > translations you don't want to put the language code before the > resource in the URL. Ie you don't want /fi/second/example/ because the > hierarchy implies that for a different country it's actually a > different object. My preferred approach for translations is /second/ > example,fi/ (comma seperated as outlined > inhttp://tools.ietf.org/html/rfc3986#page-23). > This says to users that they're viewing the same resource but in a > different language. I've previously read and understood the reasoning behind the comma approach. At that time I still chose the language code as URL prefix, mainly because I felt it offers better usability and clearer URLs. For my eyes the ,fi suffix resembles the annoying .php? foo=bar=123672436 cruft still seen on many sites. But I acknowledge that there's a problem in the hierarchy logic. Anyway, the comma suffix approach doesn't fit well with Django's stock language handling, either. Django assumes the language is set and stored in the session in a separate view, which redirects back to actual content. When the language code is part of the URL, no redirection is done and the language is set as part of URL parsing. It could be done in a middleware, but I don't like that approach since middleware is unaware of the URL hierarchy and differences in language code handling between parts of the hierarchy. I'll take a look at the discussion Panos pointed out and see if any silver bullets are presented 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
I think the key here is the fact that Django is very scalable. When something starts going wrong with your system, Django has the tools available to figure out where the bottle necks are and it is quite simple. In the past I have hit bottlenecks with mod_python. That was easy to fix by switching to Wsgi and optimizing my sites with memcached. I have also had issues with databases, which is easy enough to figure out what calls are the heaviest, cache them better and possibly replicate my databases when I have to. If you anticipate to build sites as large as the Washington Post and Pownce then you know that Django's code is very usable, modular when you need to customize and verbose when you need to debug. Right now there are a lot of options for frameworks, personally I have found nothing that matches the stability, features and customizable as Django. Also nothing beats python IMHO. The key is here, everyone doesn't have the same needs so you need to be prepared to optimize your own settings. The core Django code is sleek, simple and unassumptious and rightly so. The contrib apps you might find you'll need to customize a lot and Django makes that real easy to do. That isn't always the case with frameworks... My $0.02 On Wed, Apr 23, 2008 at 8:50 AM, Chris Hartjes <[EMAIL PROTECTED]> wrote: > On Wed, Apr 23, 2008 at 6:04 AM, bcurtu <[EMAIL PROTECTED]> wrote: > > > > > > > But, turning back to my question... Can you tell these sites with > > thousands or hundreds of thousands hits per minute? Ok, let's leave > > apart their stats... Any big name on the internet? slashdot? twitter > > is RoR... > > > > I think you should worry about building something first, then worry about > whether or not it can handle huge amounts of traffic. If you are getting > thousands or hundreds of thousands of hits per minute then (a) you are doing > better than 99.999% of the web applications out there and (b) will be > creating custom solutions to your particular scaling problems. Twitter is > built on Rails, but has been heavily modified to meet their specific needs. > It wouldn't surprise me if Pownce was the same way. > > Before people get on my case, understand I'm not advocating doing no > planning at all in terms of thinking about scalability. I'm advocating > actually building something simple and to open standards as to make it > easier to scale out your app when the time comes. > > On this topic, any good tutorials on handling query caching and output > caching in Django? Those are two things I would build into any sort of web > app right from the beginning. > > -- > Chris Hartjes > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Running Tests: Stop at first error
Hi, if one unittest fails at the database level, often all following tests fail with this error: execute SQL failed: current transaction is aborted, commands ignored until end of transaction block Is there a way to stop after the first failing test? Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Q query question
Replying to myself with more clues: I see the problem: For this filter statement: items = InventoryItem.objects.filter( Q(inventory_date__range=(weekstart, thisdate), received__exact=0) | Q(onhand__gt=0)) ,,, the SQL generated looks like this: SELECT "orders_inventoryitem"."id","orders_inventoryitem"."producer_id","orders_inventoryitem"."product_id","orders_inventoryitem"."inventory_date","orders_inventoryitem"."planned","orders_inventoryitem"."received","orders_inventoryitem"."onhand" FROM "orders_inventoryitem" WHERE (("orders_inventoryitem"."inventory_date" BETWEEN 2008-04-21 AND 2008-04-23 OR "orders_inventoryitem"."received" = 0.00 OR "orders_inventoryitem"."onhand" > 0.00)) ORDER BY "orders_inventoryitem"."product_id" ASC, "orders_inventoryitem"."producer_id" ASC, "orders_inventoryitem"."inventory_date" ASC'} So the SQL ORs all of the Q clauses, and does not separate the Q clause that I thought should have been ANDed. On the other hand, this single Q query properly generates ANDed clauses: items = InventoryItem.objects.filter( Q(inventory_date__range=(weekstart, thisdate), received__exact=0)) The SQL: SELECT "orders_inventoryitem"."id","orders_inventoryitem"."producer_id","orders_inventoryitem"."product_id","orders_inventoryitem"."inventory_date","orders_inventoryitem"."planned","orders_inventoryitem"."received","orders_inventoryitem"."onhand" FROM "orders_inventoryitem" WHERE ("orders_inventoryitem"."inventory_date" BETWEEN 2008-04-21 AND 2008-04-23 AND "orders_inventoryitem"."received" = 0.00) ORDER BY "orders_inventoryitem"."product_id" ASC, "orders_inventoryitem"."producer_id" ASC, "orders_inventoryitem"."inventory_date" ASC'} So is the first generated SQL a bug? Or am I still missing something? (And still hunting for a better (or any clean) way to accomplish my goal...) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
On Wed, Apr 23, 2008 at 6:04 AM, bcurtu <[EMAIL PROTECTED]> wrote: > > > But, turning back to my question... Can you tell these sites with > thousands or hundreds of thousands hits per minute? Ok, let's leave > apart their stats... Any big name on the internet? slashdot? twitter > is RoR... > I think you should worry about building something first, then worry about whether or not it can handle huge amounts of traffic. If you are getting thousands or hundreds of thousands of hits per minute then (a) you are doing better than 99.999% of the web applications out there and (b) will be creating custom solutions to your particular scaling problems. Twitter is built on Rails, but has been heavily modified to meet their specific needs. It wouldn't surprise me if Pownce was the same way. Before people get on my case, understand I'm not advocating doing no planning at all in terms of thinking about scalability. I'm advocating actually building something simple and to open standards as to make it easier to scale out your app when the time comes. On this topic, any good tutorials on handling query caching and output caching in Django? Those are two things I would build into any sort of web app right from the beginning. -- Chris Hartjes --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
You can also have a look at www.djangosites.org , it lists some sites running django. Revver (www.revver.com), a video-sharing site is one of them. On Wed, Apr 23, 2008 at 12:23 PM, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > > > On 23-Apr-08, at 3:34 PM, bcurtu wrote: > > > But, turning back to my question... Can you tell these sites with > > thousands or hundreds of thousands hits per minute? Ok, let's leave > > apart their stats... Any big name on the internet? slashdot? twitter > > is RoR... > > you could take a look at the djangobook - there is a chapter/appendix > on big sites using django with interviews of the people running the > sites. > > -- > > regards > kg > http://lawgon.livejournal.com > http://nrcfosshelpline.in/code/ > > > > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: No module named views, Django tutorial
> I had my project in an apache directory so maybe it has something to > do with permissions. Quoted from the Django Tutorial: If your background is in PHP, you’re probably used to putting code under the Web server’s document root (in a place such as /var/www). With Django, you don’t do that. It’s not a good idea to put any of this Python code within your Web server’s document root, because it risks the possibility that people may be able to view your code over the Web. That’s not good for security. Put your code in some directory outside of the document root, such as / home/mycode. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Q query question
I'm trying to retrieve all Inventory Items whose onhand quantity is greater than zero, OR (whose date is within a specified range AND whose received quantity is zero). InventoryItems have three relevant fields for this query: onhand, inventory_date, and received. I currently have only 2 inventory items, only one of which matches the desired criteria. If I specify the following two separate queries, I get the correct results from each query: 1. items = InventoryItem.objects.filter(Q(onhand__gt=0) ) ...correctly returns an empty list (currenly no items have onhand quantities). 2. items = InventoryItem.objects.filter( Q(inventory_date__range=(weekstart, thisdate), received__exact=0)) ...correctly returns a list containing one item. If I put the clauses together like this: items = InventoryItem.objects.filter( Q(onhand__gt=0) | Q(inventory_date__range=(weekstart, thisdate), received__exact=0)) ...I do not get the expected result (one item), but rather 2 items, including one that violates both clauses. But if I put these clauses together like this (omitting the date range): items = InventoryItem.objects.filter( Q(onhand__gt=0) | Q(received__exact=0)) ...I get the correct result. So I assume I do not understand something about either this clause: Q(inventory_date__range=(weekstart, thisdate), received__exact=0) or how to combine it into a larger set of filter clauses with an OR. I thought it was ANDing the first part with the last part, and that is how it seems to act on its own. But it behaves differently when combined in a larger filter with an OR. So what am I missing? Or, is there a better way to accomplish my goal? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Quick question about qs-rf and queries using distinct and order_by on foreign key fields
> There's nothing in the queryset-refactor branch that's really "work in > progress" any longer (at least not committed to the tree). So please > open a ticket with a short example so that this doesn't get forgotten. Thanks Malcolm - I've opened a ticket for it now (number #7070). Regards, Matt --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FTP upload of files threw django
Hello All, I've been working on a quality control portal that uses some features of django. The application is now completely running but the upload of large data files is quit slow. I've been looking around how to speed things up and the only thing i saw was using ftp upload instead of the http file upload. I want to incorporate this feature in the existing frontend, is there something in the newforms library that already covers some of this ? If not is it possible to put the ftp upload under the file selection box created by the newforms library. are there any snippets around that show how to use the ftp upload from a webapplication ? Any help or pointers in the right direction would be greatly appreciated. Thanks in advance, Richard Mendes --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Categorize and List if Item Exists
andy baxter wrote: > you want a tag that would let you write an include file like: > > {% for category in categorybranch %} > sorry that should be {% for category in categorybranch.sub_cats %} > (print category name here) > {% include "self.html" with categorybranch=category %} > {% for product in categorybranch.products %} > (print product name here) > {% endfor %} > {% endfor %} > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
On 23-Apr-08, at 3:34 PM, bcurtu wrote: > But, turning back to my question... Can you tell these sites with > thousands or hundreds of thousands hits per minute? Ok, let's leave > apart their stats... Any big name on the internet? slashdot? twitter > is RoR... you could take a look at the djangobook - there is a chapter/appendix on big sites using django with interviews of the people running the sites. -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
2008/4/23 bcurtu <[EMAIL PROTECTED]>: > But, turning back to my question... Can you tell these sites with > thousands or hundreds of thousands hits per minute? Ok, let's leave > apart their stats... Any big name on the internet? slashdot? twitter > is RoR... Pownce (http://pownce.com/) is built with Django. -- Jabber : [EMAIL PROTECTED] Skype : Guillaume.Lederrey Projects : * http://rwanda.ledcom.ch/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
Malcom, you're right in many points... I'm trying to identify the possible bottle-necks of the system, and hopefully, if we follow the "share nothing" architecture and the best practices I won't have many problems. The site is not that complex, the only point of danger could be a recommendation engine. But, turning back to my question... Can you tell these sites with thousands or hundreds of thousands hits per minute? Ok, let's leave apart their stats... Any big name on the internet? slashdot? twitter is RoR... Thnaks!! On 23 abr, 11:51, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-04-23 at 02:13 -0700, bcurtu wrote: > > May you enumerate the largest django sites (apart from WSJ)? Do you > > know traffic stats of these sites? I'm building a big site, with > > potentially lots of traffic and I'm a bit afraid what I can expect... > > There are at least two problems with your question. Firstly, that type > of information is often commercially confidential. Secondly (and more > importantly for your case), "large" isn't a well-defined term. > > Performance depends on things like database size (the number of records > that are accessed to produce the pages), number of different sorts of > pages (which affects cachability), number of page views, number of > active users (if you're doing per-user customisation) and probably a > bunch of other things I can't think of off the top of my head. > > There are known examples of sites doing thousands of page views per > minute, other sites with users in the hundreds of thousands and possibly > more and yet other sites querying many gigabytes of data. At those > levels, you have to put some effort into performance, no matter what you > are using, but no problem is insurmountable. Keep an eye on performance > as you are developing, don't prematurely optimise, since many decisions > require the functionality to be known first, but do be prepared to try > out a few alternatives in various situations. > > If you have concrete performance problems, feel free to post a > description of the type of problem here. Best to have some measurements > to hand first, though, since optimisation is rarely productive when you > have to guess as to the significance of any particular feature. > > Regards, > Malcolm > > -- > A clear conscience is usually the sign of a bad > memory.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Largest django sites?
On Wed, 2008-04-23 at 02:13 -0700, bcurtu wrote: > May you enumerate the largest django sites (apart from WSJ)? Do you > know traffic stats of these sites? I'm building a big site, with > potentially lots of traffic and I'm a bit afraid what I can expect... There are at least two problems with your question. Firstly, that type of information is often commercially confidential. Secondly (and more importantly for your case), "large" isn't a well-defined term. Performance depends on things like database size (the number of records that are accessed to produce the pages), number of different sorts of pages (which affects cachability), number of page views, number of active users (if you're doing per-user customisation) and probably a bunch of other things I can't think of off the top of my head. There are known examples of sites doing thousands of page views per minute, other sites with users in the hundreds of thousands and possibly more and yet other sites querying many gigabytes of data. At those levels, you have to put some effort into performance, no matter what you are using, but no problem is insurmountable. Keep an eye on performance as you are developing, don't prematurely optimise, since many decisions require the functionality to be known first, but do be prepared to try out a few alternatives in various situations. If you have concrete performance problems, feel free to post a description of the type of problem here. Best to have some measurements to hand first, though, since optimisation is rarely productive when you have to guess as to the significance of any particular feature. Regards, Malcolm -- A clear conscience is usually the sign of a bad memory. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Avoiding the ThreadLocals hack - anything new in NewForms-Admin?
I was reading this page http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser and was wondering how the advice on avoiding the hack applied to my own use case. I am using the ThreadLocals hack to get the current user in a model when overriding the save() method. Therefore I can't pass in the user as I can't control how save() is called. On a higher level my goal is to limit the Admin changelist to only show the objects associated with the current user. I am using NewForms-Admin so was hoping that there are new ways to achieve this but after a bit of head scratching and source-code reading nothing has leapt out at me. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Largest django sites?
May you enumerate the largest django sites (apart from WSJ)? Do you know traffic stats of these sites? I'm building a big site, with potentially lots of traffic and I'm a bit afraid what I can expect... Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
filtering in ModelChoices not working
hi, this is my code snippet: class Ingredientrecform(forms.ModelForm): """ Form to add Ingredients. """ def __init__(self,pageid, *args, **kwargs): super(Ingredientrecform, self).__init__(*args, **kwargs) self.pageid = pageid ingredient = forms.ModelChoiceField (queryset=Ingredient.objects.extra( where=["""id not in (select ingredient_id from web_recipeingredient\ where recipe_id = %s)""" % self.pageid])) class Meta: model = Recipeingredient exclude = ('rank','recipe') the problem is that all the ingredients get displayed in the choice dropdown and not only the ingredients that pass the test in the queryset. Where am I going wrong? -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Auto fill the form field???
On 23-Apr-08, at 1:12 PM, laspal wrote: > So my question is does django gives any tool for this or do I have to > write java script for it..??? you will have to write javascript for it -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Auto fill the form field???
Hi, I have a form with the following field. 1)Title 2)Descriptions 3) No of person 3) Drop down box containing the previous filled form title.. Now my question is how to auto fill the form field when a user choose any title from the drop down box. I am doing that so that user can choose any title from the drop down box and form field get auto fill from the previous value.. Now the user can edit any field according to his requirement. So my question is does django gives any tool for this or do I have to write java script for it..??? thanks... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---