Re: Added-value over PHP?
On Feb 3, 1:39 am, Delifisek Tux wrote: > > A decent framework eats up your %50 of > cpu resource. For example that Uber Zend FW gives you 1/6 in a hello world > app comparing plain php. Why would you want to write a Hello World program in a framework? Try writing a very large app in a framework and then try using bare PHP. Compare how much longer and how many more bugs do you get using bare PHP. Compare how many SLOC it took in each. Which is easier to maintain? Caching can be used to recover speed. BN -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Next previous links from a query set / generi views
Yup, if you have non-null date/datetime fields on your model, each model will automatically get "get_next_by_FOO" and "get_previous_by_FOO" methods, where FOO is the name of the datetime field: http://docs.djangoproject.com/en/1.1/ref/models/instances/#django.db.models.Model.get_next_by_FOO Eric On Feb 7, 2010, at 2:34 AM, eaman wrote: Hello, I have a quite simple query set and a related generic views: http://dpaste.com/155494/ And template for generating a detail page of a photo. Is there an easy way to have a link to previous | next element in the template without manualy coding a view ? Somthing like a: {% if foto.next_item %} Next {% endif} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/django-users?hl=en . -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there a way to access a field's verbose_name from a object_list generic view template?
On Feb 6, 2010, at 2:53 AM, Atamert Ölçgen wrote: > On Saturday 06 February 2010 12:23:16 Dennis Kaarsemaker wrote: >> On do, 2010-02-04 at 11:01 -0800, Eric Chamberlain wrote: >>> I'm using the object_list generic view and it seems there should be a >>> way to pull the field verbose_name from the model, without having to >>> hard code the name in the template. >> >> model_class_or_instance._meta.verbose_name >> unicode(model_class_or_instance._meta.verbose_name_plural) >> > You can't access attributes that start with an underscore from templates. A > custom tag or filter should do it. > > Alternatively computed value of verbose_name can be passed to the view via > extra_context. Check the docs. > > What about the verbose_name and help_text of each field in the model? I want to use the verbose_name in a list view table column header. Is there a way to get the verbose_name from a QuerySet? -- Eric Chamberlain -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Reversed URLs problem
Hi folks, I'm having trouble with reversed urls when they are being called as template tags. I posted my question on Stack Overflow last week with no adequate responses. I'll copy it here (with slight modifications) for convenience. http://stackoverflow.com/questions/2189119/project-name-inserted-automatically-in-url-when-using-django-template-url-tag I have my urls named like so in my root urls.py file... ... url(r'^login/$', 'login', name='site_login'), ... This allows me to access /login at my site's root. I have my template tag defined like so... ... ... It works fine, except that Django automatically resolves that url as / myprojectname/login, not /login. Both urls are accessible. Only one is defined. Why is the projectname being inserted to the url automagically? This occurs for all url tags, not just this one. Thanks, Adam -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Callback method on session timeout
Does django have the ability to do a callback when a session time out occurs? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
dynamic dummy image generator for django
Hi there! I just release an small app that could be useful for some developers. The idea is from http://dummyimage.com/ I just ported to a reusable django app :) It's called the lorem ipsum for images. {% get_dummyimage_url 320 240 png as myimage %} You can see more usage examples here: http://dummyimage.rolandoespinoza.info/ And the source code here: http://github.com/darkrho/django-dummyimage Regards, -- Rolando Espinoza La fuente www.rolandoespinoza.info -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Pulling a user to save a form
No I am not, once the user is logged in I just want to pull the user from there...sort of like this if request.method == 'POST': instance = request.user goal = Goal(user=instance) form = GoalForm(request.POST, goal) if form.is_valid(): form.save() and i'm getting the following error still.cause i'm not setting the user_id on the front-end but only on the back-end. (1048, "Column 'user_id' cannot be null") Thanks for the quick responses so far. On Feb 6, 3:54 pm, Daniel Roseman wrote: > On Feb 6, 7:00 pm, kamilski81 wrote: > > > Basically I am doing the following: > > > u=User.objects.get(username="kamilski81") > > goal = Goal(user=u) > > form= GoalForm(request.POST, goal) > > > and get this error: > > > (1048, "Column 'user_id' cannot be null") > > > FROM THE front-end... > > > Kamil > > Are you actually displaying the 'user' field in your HTMLform > template? > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Pulling a user to save a form
On Feb 6, 7:00 pm, kamilski81 wrote: > Basically I am doing the following: > > u=User.objects.get(username="kamilski81") > goal = Goal(user=u) > form = GoalForm(request.POST, goal) > > and get this error: > > (1048, "Column 'user_id' cannot be null") > > FROM THE front-end... > > Kamil Are you actually displaying the 'user' field in your HTML form template? -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: satchmo customization experiences? customizing existing e-com vs. roll-your-own
You may get some more answers on the Satchmo list but I assume all those folks are on this list too. I'll attempt to provide some answers here because it's probably of interest to the broader community. Whenever I hear people talking about writing something from scratch, I think about these two articles - http://www.codinghorror.com/blog/archives/001284.html http://blog.bitquabit.com/2009/07/01/one-which-i-call-out-hacker-news/ First off, I realize Satchmo is nowhere near the same as stack overflow but the principal is the same. Satchmo has been under active development for almost 3 years and it's by no means complete and nowhere near perfect. That being said, it does do a lot & has a lot of thought put into how to balance ease of use and functionality with the ability to customize. There could be a lot of debate about how well we've managed to do it & reasonable people could disagree about our approach; but there is a fairly significant amount of work to start from scratch. In fact, if Satchmo seems too much overkill for your needs, then you might want to look at some of the alternatives (which I have no personal experience with) like: http://djwarehouse.org/wiki http://www.getlfs.com/ Or if you feel you need to write one from scratch, this is probably as good a place as any to start: http://django-ecommerce.blogspot.com/ Now, to answer your earlier question about how to customize Satchmo, a lot depends on what you actually need to do. Writing a custom shipping module or modifying the templates is trivial. If you need to yank out the entire product model and use something new then it might be more of a challenge. If you can discuss a bit more about the changes you would need to make, we can probably provide some more guidance on the relative difficulty of getting them done. -Chris On Sat, Feb 6, 2010 at 12:57 PM, snfctech wrote: > I'm building an order entry and tracking system for a Food Co-op for > their case and special orders. We don't need the system to be on-line > (at the moment), but many of the system requirements are already > present in many existing e-commerce solutions (product catalog/search, > order entry screens, order tracking/history, etc.) > > Initially, I was thinking of building the system from scratch using > web2py or Django. (The RoR Spree project looks pretty interesting, > too - but I'm already writing a product/customer ETL in Jython and > don't want to balance the two languages - both Python and Ruby are new > to me.) Web2py doesn't have any existing e-commerce project, so that > lead me to look at Django/Satchmo. I'm guessing the Satchmo > customization necessary is probably on the order of 20-30%. > > The question is whether that 20-30% customization is going to be more > of a headache than rolling my own clean order-entry and tracking > system with nothing extra I don't need. Has anyone had a similar > experience they can share? I would be especially interested in > anyone's experiences with customizing/extending Satchmo. > > Thanks in advance for any tips. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Pulling a user to save a form
Basically I am doing the following: u=User.objects.get(username="kamilski81") goal = Goal(user=u) form = GoalForm(request.POST, goal) and get this error: (1048, "Column 'user_id' cannot be null") FROM THE front-end... Kamil On Feb 5, 10:43 pm, Dylan Evans wrote: > user = User.objects.get(username__exact='bob') > Works fine for me, you may want to try get since it will throw an exception > if there is no matching user. Then you know the problem is elsewhere. > > > > On Sat, Feb 6, 2010 at 11:30 AM, kamilski81 wrote: > > I would like to save a form by doing the following: > > > #Goal has a User ForeignKey (django.contrib.auth.models.User) > > - > > class GoalForm(ModelForm): > > class Meta: > > model = Goal > > --- > > class Goal(models.Model): > > user = models.ForeignKey(User, editable=False) > > -- > > view.py => > > from django.contrib.auth.models import User > > . > > . > > QuerySetUser = User.objects.filter(username__icontains='myusername') > > goal = Goal(user=QuerySetUser[0]) > > form = GoalForm(request.POST, goal) > > . > > But i'm getting the error : > > (1048, "Column 'user_id' cannot be null") > > > Any idea how I can pull a user from the database and save a goal? Or > > set the user_id? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > "The UNIX system has a command, nice ... in order to be nice to the other > users. Nobody ever uses it." - Andrew S. Tanenbaum -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
satchmo customization experiences? customizing existing e-com vs. roll-your-own
I'm building an order entry and tracking system for a Food Co-op for their case and special orders. We don't need the system to be on-line (at the moment), but many of the system requirements are already present in many existing e-commerce solutions (product catalog/search, order entry screens, order tracking/history, etc.) Initially, I was thinking of building the system from scratch using web2py or Django. (The RoR Spree project looks pretty interesting, too - but I'm already writing a product/customer ETL in Jython and don't want to balance the two languages - both Python and Ruby are new to me.) Web2py doesn't have any existing e-commerce project, so that lead me to look at Django/Satchmo. I'm guessing the Satchmo customization necessary is probably on the order of 20-30%. The question is whether that 20-30% customization is going to be more of a headache than rolling my own clean order-entry and tracking system with nothing extra I don't need. Has anyone had a similar experience they can share? I would be especially interested in anyone's experiences with customizing/extending Satchmo. Thanks in advance for any tips. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Pulling a user to save a form
It pulls the User correctly, and there is an object there...but it won't let me store it on the front-end form, cause user_id is not set or something of that sort. On Feb 5, 10:43 pm, Dylan Evans wrote: > user = User.objects.get(username__exact='bob') > Works fine for me, you may want to try get since it will throw an exception > if there is no matching user. Then you know the problem is elsewhere. > > > > On Sat, Feb 6, 2010 at 11:30 AM, kamilski81 wrote: > > I would like to save a form by doing the following: > > > #Goal has a User ForeignKey (django.contrib.auth.models.User) > > - > > class GoalForm(ModelForm): > > class Meta: > > model = Goal > > --- > > class Goal(models.Model): > > user = models.ForeignKey(User, editable=False) > > -- > > view.py => > > from django.contrib.auth.models import User > > . > > . > > QuerySetUser = User.objects.filter(username__icontains='myusername') > > goal = Goal(user=QuerySetUser[0]) > > form = GoalForm(request.POST, goal) > > . > > But i'm getting the error : > > (1048, "Column 'user_id' cannot be null") > > > Any idea how I can pull a user from the database and save a goal? Or > > set the user_id? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > "The UNIX system has a command, nice ... in order to be nice to the other > users. Nobody ever uses it." - Andrew S. Tanenbaum -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Next previous links from a query set / generi views
Hello, I have a quite simple query set and a related generic views: http://dpaste.com/155494/ And template for generating a detail page of a photo. Is there an easy way to have a link to previous | next element in the template without manualy coding a view ? Somthing like a: {% if foto.next_item %} Next {% endif} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Added-value over PHP?
On 3 fév, 16:08, Javier Guerra wrote: > that means, a well-coded framework can be extensive, sophisticated, > even heavy; but still perform very quickly. Thanks much Javier for the feedback. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ModelAdmin.get_readonly_fields with ForeignKey's
On Sat, Feb 6, 2010 at 10:35 PM, Karen Tracey wrote: > On Sat, Feb 6, 2010 at 6:16 AM, Rishabh Manocha wrote: > >> [snip] >> While this works just fine, the one problem I'm having is that instead of >> showing the title of the book (i.e. - calling Book.__unicode__), the admin >> simply shows the primary key value of the Book. >> >> > Sounds like: > > http://code.djangoproject.com/ticket/12654 > > Which was fixed in r12366 just a few days ago. If you upgrade to the beta > release the problem should be fixed. > Yep - that did the trick. Thanks. > > Karen > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Best, R -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem setting up mysqldb 1.2.3c1 on Mac 10.5.8 Leopard
I had this same problem, i eventually abandoned building any of it manually and switched to macports: http://groups.google.com/group/django-users/browse_thread/thread/862ceed6f97acf1c/eeff8aa5fb16ca0c#eeff8aa5fb16ca0c. If you read the thread no one agrees with me, but its working great for me so far. Since I'm a noob as well, it could prove a mistake down the road. However I did fix the build problem before i abandoned it. I had to make some symbolic links so that /usr/local/mysql pointed to my actual install where mysql was installed. riuxjg:local jgreenaw$ ls -l /usr/local/mysql/ total 8 lrwxr-xr-x 1 root wheel 27 Jan 20 14:01 lib -> /opt/local/lib/ mysql5/mysql so something like this: cd /usr/local sudo ln -s opt/local/lib/mysql5/mysql mysql If you look in the build its actually looking for the _mysql.so file which is somewhere in your mysql install directory. hope it helps. On Feb 5, 7:40 am, monchi wrote: > Hi there, > > I'm a first time Django user, trying to set up Django on my Mac 10.5.8 > Leopard with MySQL from MAMP. > Is this actually possible? > > I managed to get the welcome message from Django install, so that's > working, I assume. > > Next, MySQL, I got this: > >>> import MYSQLdb > > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named MYSQLdb > > > I went and downloaded the mysql-python-1.2.3c1, unpacked it, tried to > build it, and got this error: > > > running build > running build_py > copying MySQLdb/release.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb > running build_ext > building '_mysql' extension > gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc > build/temp.macosx-10.5-i386-2.5/_mysql.o -L/Applications/MAMP/Library/ > lib/mysql -lmysqlclient_r -lz -lm -o build/lib.macosx-10.5-i386-2.5/ > _mysql.so > ld: library not found for -lmysqlclient_r > collect2: ld returned 1 exit status > ld: library not found for -lmysqlclient_r > collect2: ld returned 1 exit status > lipo: can't open input file: /var/folders/sE/sEdFajpBFXergJVaiXZyfU++ > +TI/-Tmp-//cc1NtAuY.out (No such file or directory) > error: command 'gcc' failed with exit status 1 > > > I also tried the older version, mysql-python-1.2.2, got the unsigned > error, commented out lines 37-39 as suggested by many, which worked, > but got this similar error: > > > running build > running build_py > copying MySQLdb/release.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb > running build_ext > building '_mysql' extension > gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused- > madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes - > DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe - > Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/Applications/ > MAMP/Library/include/mysql -I/System/Library/Frameworks/ > Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/ > temp.macosx-10.5-i386-2.5/_mysql.o -fno-omit-frame-pointer - > D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ - > DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL > gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc > build/temp.macosx-10.5-i386-2.5/_mysql.o -L/Applications/MAMP/Library/ > lib/mysql -lmysqlclient_r -lz -lm -o build/lib.macosx-10.5-i386-2.5/ > _mysql.so > ld: library not found for -lmysqlclient_r > collect2: ld returned 1 exit status > ld: library not found for -lmysqlclient_r > collect2: ld returned 1 exit status > lipo: can't open input file: /var/folders/sE/sEdFajpBFXergJVaiXZyfU++ > +TI/-Tmp-//ccV4OFgQ.out (No such file or directory) > error: command 'gcc' failed with exit status 1 > > > How can I get around the "ld: library not found for -lmysqlclient_r" > error? > What am I missing or doing wrong? > > Many have also suggested to use SQLite. At this rate I'm willing to > give it a try, though I would much prefer MySQL MAMP/XAMPP alternative > if it's possible at all. > > Thanks for your help, I'm looking forward to your advise. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Getting endless redirects when accessing root url
Hi everyone, I'm new to Django and tried to set up a little project using flatpages. Here's my url conf: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() from django.contrib.flatpages.views import flatpage urlpatterns = patterns('', (r'^/$', flatpage, { 'url' : 'home/' } ), (r'^admin/', include(admin.site.urls)), (r'', include('django.contrib.flatpages.urls')), ) But I can't access the root url (127.0.0.1:8000). The browser aborts because of to many redirects. When looking at the console output of "./ manage.py runserver" there are about 20 of this messages: [06/Feb/2010 16:47:38] "GET / HTTP/1.1" 302 0 What am I doing wrong? Thanks in advance! :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django_evolution evolve not found
No, I have no connection to South other than using and loving it. I used to do all my DB work manually, so having the Django ORM and South is like someone recognizing that and saying "Good work; we'll take it from here." Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: update with where clause constraints?
On Sat, Feb 6, 2010 at 8:55 AM, Malcolm Box wrote: > 2010/2/5 Jared Smith > >> My use case is that I'll have multiple users trying to update a set of >> objects and I want to make sure that any user committing a change has >> knowledge of the existing state. I was going to model that with a version >> number so an update would look like: >> > > Maybe I'm missing something, but this sounds like the canonical use of > ETags. Provide an Etag with the read, then when the update comes in check > if the ETag matches what is calculated for the current state of the DB. > > If it does, let the update through. If not, then force the user to retry > based on the new state. > Note anything done like this in Django app code is liable to run into multi-thread/multi-process race conditions. A typical production deployment environment will have multiple threads and/or processes handling requests simultaneously. Thus current state of the DB when a request is received is not necessarily going to be the same as current state of the DB by the time the request processing thread gets around to actually making the update -- one request processing thread could have already passed the point of accepting an update but not quite gotten around to making the change in the DB when a 2nd request processing thread decides it's also OK to accept an update. Last one to actually issue the update wins, the other thread's update is lost. Using an atomic SQL UPDATE with a WHERE clause specifying the version requirement, which is what QuerySet update() allows, pushes the responsibility for dealing with this race condition onto the DB. The DB will ensure that only one of the threads gets to make the update, and the Django app code can know which it is based on the result of the update() call. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ModelAdmin.get_readonly_fields with ForeignKey's
On Sat, Feb 6, 2010 at 6:16 AM, Rishabh Manocha wrote: > [snip] > While this works just fine, the one problem I'm having is that instead of > showing the title of the book (i.e. - calling Book.__unicode__), the admin > simply shows the primary key value of the Book. > > Sounds like: http://code.djangoproject.com/ticket/12654 Which was fixed in r12366 just a few days ago. If you upgrade to the beta release the problem should be fixed. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
how to do object lookup using hour ,minute
hi I am a beginner with python and django and am writing my first application.I need to retrieve some objects of my model class created at different minutes in an hour.The class stores a datetime value in a 'creationtime' ( DateTimeField )and have an associated 'subject' string which can get repeated in many objects(ie object has one to many relation with subject).Only the 'creationtime' is unique for an object. How can I get a unique object using MyModel.objects. get()? When I checked the lookup docs ,it says it cannot do lookup on hour or minute ,but only on year,month,day.. Also I want to display the details of a single object.Do I need to create a unique slug? Is it possible to create a slug from DateTimeField 's value? (The prepopulated_fields in ModelAdmin doesn't accept DateTimeField and ForeignKey ..so I am not sure if I can use it in slug field). Also, how should I create the get_absolute_url for the class? If someone can give any pointers -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Flat file application for binary data?
On Feb 5, 2010, at 1:27 PM, Peter Herndon wrote: > FileFields and ImageFields are by default stored on disk, with just a pointer > stored in the db. For more examples, take a look at David Larlet's > django-storages (http://code.welldev.org/django-storages/wiki/Home) and > Justin Driscoll's ImageKit > (http://bitbucket.org/jdriscoll/django-imagekit/wiki/Home), both of which > should give you at least a starting point. With ImageKit, for example, you > create a "spec" for your image fields, and part of the spec is a means of > determining the filesystem storage location (including a method you can > define if you need to). > Looking at the django-storages code gave me some useful ideas. Thanks, Peter. John -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Flat file application for binary data?
On Feb 5, 2010, at 12:36 PM, Mike Ramirez wrote: > It's built in. > > http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ > > http://docs.djangoproject.com/en/dev/ref/files/storage/ > > Between those two docs, you should be able to do everything you want. AFAIK, > no file uploads are stored directly in the database, though there is a model > behind it, it stores the path,. > I know about those, and they don't do what I'm looking for. At least, not as I understand them. I'm looking at the next architectural level up. For example, creating an md5 or sha1 hash directory under a file root, where file uploads can be organized in /mm/dd folders. And providing the linkage from the user account in the SQL db, to their binary file directory. I was hoping someone else had packaged this kind of support for binary-objects-stored-in-files in a nice and purty application. :-) I'll chew on this more. Maybe a custom storage system backend is the way to go. (http://tinyurl.com/yjh7st4) John -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: update with where clause constraints?
2010/2/5 Jared Smith > My use case is that I'll have multiple users trying to update a set of > objects and I want to make sure that any user committing a change has > knowledge of the existing state. I was going to model that with a version > number so an update would look like: > Maybe I'm missing something, but this sounds like the canonical use of ETags. Provide an Etag with the read, then when the update comes in check if the ETag matches what is calculated for the current state of the DB. If it does, let the update through. If not, then force the user to retry based on the new state. Cheers, Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Site wide configuration in admin
El 06/02/10 10:11, Matt escribió: > I'd like to provide site wide configuration settings in the admin > panel. > > I'd like users to be able to edit things like the front page text and > specify a featured event (represented by a model). > > How can this be achieved? > Try livesettings: http://bitbucket.org/bkroeze/django-livesettings/overview/ -- Gonzalo Delgado -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Site wide configuration in admin
Hi all I'd like to provide site wide configuration settings in the admin panel. I'd like users to be able to edit things like the front page text and specify a featured event (represented by a model). How can this be achieved? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Sort by attribute not in database
On 5 Feb, 21:21, Peter Herndon wrote: > Never forget, Django is Python. One way to do what you need would be to > implement the __cmp__ special method on your Computer class. Then, if you > make e.g. a list out of the results of your QuerySet, you can call sort() on > the list, and you're done. > > The downside is that you need to make a list of your QuerySet, which may > require quite a bit of memory, depending on the number of objects returned. > > The reason you can't order_by something that's not in the database is that > the order_by method is SQL and is executed in the database as part of the > query. The reason you can't sort() a queryset is that it's a generator, not > a list, so it only lazily instantiates your model objects. > Just the ticket. Many thanks Peter. I was doing a list comprehension along the lines of list = [ x for x in Computer.objects.all() ] which seemed to work, but your __cmp__ method looks much nicer. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ModelAdmin.get_readonly_fields with ForeignKey's
Hi Guys, I was trying to use the newly introduced ModelAdmin.get_readonly_fields method to mark a OneToOne relation as read only - something along the lines of: models.py: class Book(models.Model): title = models.CharField(max_length = 50) ... def __unicode__(self): return '%s' % self.title class BookInventory(models.Model): ... book = models.OneToOneField(Book) def __unicode__(self): return '%s' % self.book admin.py: class BookInventoryAdmin(admin.ModelAdmin): def get_readonly_fields(self, request, obj = None): if obj is not None: return ['book'] else: return [] While this works just fine, the one problem I'm having is that instead of showing the title of the book (i.e. - calling Book.__unicode__), the admin simply shows the primary key value of the Book. This issue was bug #342 in Django Trac - [1] - and was fixed in changeset 11965 - [2]. Does anyone have any ideas about how to get the title of the book to show up in the admin page for BookInventory, instead of it's primary key value? Thanks in advance, Rishabh [1] - http://code.djangoproject.com/ticket/342 [2] - http://code.djangoproject.com/changeset/11965 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there a way to access a field's verbose_name from a object_list generic view template?
On Saturday 06 February 2010 12:23:16 Dennis Kaarsemaker wrote: > On do, 2010-02-04 at 11:01 -0800, Eric Chamberlain wrote: > > I'm using the object_list generic view and it seems there should be a > > way to pull the field verbose_name from the model, without having to > > hard code the name in the template. > > model_class_or_instance._meta.verbose_name > unicode(model_class_or_instance._meta.verbose_name_plural) > You can't access attributes that start with an underscore from templates. A custom tag or filter should do it. Alternatively computed value of verbose_name can be passed to the view via extra_context. Check the docs. -- Saygılarımla, Atamert Ölçgen -+- --+ +++ www.muhuk.com mu...@jabber.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-app user clashes with python-module user
thanks mike & jeff. this very much solves my problem. regards, patrick On 6 Feb., 06:14, newspaper-django-lackey wrote: > Naming conflicts are a consistent issue brought up on the boards. I've > had issues several times where an app name conflicted with a core > Python library, Pluggable, or library extension. Generally the process > I follow for apps, both personally created and pluggable, is to put > them not directly on the python path but one layer off then modify the > import statements of the app to deal with the extra layer. This > affords me the option to specify which parent folder my app is in > therefore separating it from other folders that might have the same > name. For instance All of my personal apps might be in the mysite > folder while pluggables are kept in the addons folder. These two > folders are added to the PYTHONPATH either by sys or through wsgi. > Imports of a view within those folders would be mysite.user.views > rather than user.views limiting the possibility for conflict. There > are times when this isn't worth the trouble because a very complicated > pluggable wants to be on the path and changing all of the import > statements feels like a burden, but I've also spent hours trying to > get a dateutil library to work only to find out that there is a naming > conflict with another library, which hides the one I want. > > hope this helps. > > jeff > > On Feb 4, 3:17 am, patrickk wrote: > > > our hosting-provide told me that I should rename my django-app "user" > > to something else, because there´s a python-module "user" and with > > using user.urls (within our url configuration), we do get an error. > > my question is, if this is the correct way to solve this problem. so > > far, I´ve never noticed that there are restrictions to django app- > > names (and I guess there aren´t). > > we didn´t have this problem with our previous hosting-provider and > > before I´m going to rename my app (for several websites), I´d like to > > know if the problem is caused by the "wrong" app-name or if it´s a > > server setup problem. > > > regards, > > patrick > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there a way to access a field's verbose_name from a object_list generic view template?
On do, 2010-02-04 at 11:01 -0800, Eric Chamberlain wrote: > I'm using the object_list generic view and it seems there should be a > way to pull the field verbose_name from the model, without having to > hard code the name in the template. model_class_or_instance._meta.verbose_name unicode(model_class_or_instance._meta.verbose_name_plural) -- Dennis K. The universe tends towards maximum irony. Don't push it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: When does syncd create new tables
On do, 2010-02-04 at 11:31 -0800, Joakim Hove wrote: >c) I tried to recreate the tables with "./manage.py syncdb" - > but to no avail, nothing happened? syncdb only creates new tables and does not modify the schema of existing ones. > Any tips on what I am doing wrong greatly appreciated. ./manage.py sqlreset will give you the SQL you need to wipe and recreate tables, a project like south will help you maintain table changes without destroying. -- Dennis K. The universe tends towards maximum irony. Don't push it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.