Multiple django version on developer machine
Hi all, While I have a number of django apps develop for Django 1.1 ... I also want to use Django 1.2 for my new project. How can I have multiple version of Django in my machine where my apps will be instructed either to use 1.1 or 1.2 Thanks, James -- 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.
Calling remote API
hi all, It will be my first time to create django app that requires calling remote API. As far as I know django has no built in support for this. I only way I know is URLLIB2, any good library for this purpose, which easily send your request as get this parameters and also easily parse the return results which could be xml or json? thanks, James -- 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.
django orm & sqlalchemy
Hi, I have read somewhere else that there is a plan of making sqlalchemy to work with django. My concern is while sqlalchemy is the more complete orm, but it lack validation which is something django's own orm has, am I right? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
one model per file
Hi, I am following the official tutorial of django, and found out that several model are define in a single file. I just wonder if we could have one model per file? or can be as flexible as X no of models in file A and Y no of models in file B and so on. If this is allowed, how to we name the files? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
regex in url
hi, urlpatterns = patterns('', (r'^polls/$', 'mysite.polls.views.index'), (r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'), (r'^polls/(?P\d+)/results/$', 'mysite.polls.views.results'), (r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'), ) I am very new to django as well as python. how is it that ?P seems to be ignore by the regex function? I can't see any explanation in django's documentation. is this something magic or hack my django? Thanks james --~--~-~--~~~---~--~~ 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: regex in url
Yes I am looking for the explanation of ?P syntax, is this something related to python's regex or django's own regex. thanks james On Jul 17, 11:57 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/17/07, james_027 <[EMAIL PROTECTED]> wrote: > > > I am very new to django as well as python. how is it that ?P > > seems to be ignore by the regex function? I can't see any explanation > > in django's documentation. is this something magic or hack my django? > > What do you mean by ignored? Are you getting some unexpected > behaviour, or are you looking for an explanation of the ?P > syntax? > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: regex in url
hi kenneth, thanks a lot, i think should be looking at official python doc more than the dive into python. cheers, james On Jul 17, 12:47 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 17-Jul-07, at 9:36 AM, james_027 wrote: > > > Yes I am looking for the explanation of ?P syntax, is this > > something related to python's regex or django's own regex. > > python > > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django ORM is very cool.
hi, i just starting to read http://www.djangoproject.com/documentation/model-api/ http://www.djangoproject.com/documentation/db-api/ I have some experience with other ORM, I think django's orm is really cool. Here are the things that I like that really makes Django's ORM a clean design. manager's concept filter chaining select_related() The most important is it seems to be easy to use the ORM even on existing database. The mapping seems to be easy. Is there any plan to make Django ORM available as a stand alone ORM which can be use in other application development. This could increase django's user can they can use the model with several application interface besides the web interface. cheers, james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
default behavior of django.middleware.transaction.TransactionMiddleware
hi, If I use django.middleware.transaction.TransactionMiddleware, is @transaction.commit_on_success the default behavior? or I should always call on the python decorators? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
session question
hi, sorry for this stupid question ... does django's session only work when cookies are enabled? 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 -~--~~~~--~~--~--~---
Django's User authentication
hi, is this use for the django admin features only? or I can use it for my own app? if yes, do I make it suitable for my application? Thanks james --~--~-~--~~~---~--~~ 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's User authentication
what if I need additional fields or methods for my apps? Do i inherit it or edit the user class? Thanks james On Jul 18, 3:45 pm, Przemek Gawronski <[EMAIL PROTECTED]> wrote: > > is this use for the django admin features only? or I can use it for my > > own app? if yes, do I make it suitable for my application? > > Sure you can, tak a look at: > > http://www.djangoproject.com/documentation/authentication/#how-to-log... > > Przemek > -- > AIKIDO TANREN DOJO - Poland - Warsaw - Mokotow - Ursynow - Natolin > info:http://www.tanren.pl/phone: +4850151 email: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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's User authentication
Thanks Jason for sharing this one. cheers, james On Jul 18, 9:07 pm, [EMAIL PROTECTED] (Jason F. McBrayer) wrote: > james_027 <[EMAIL PROTECTED]> writes: > > what if I need additional fields or methods for my apps? Do i inherit > > it or edit the user class? > > The standard approach is > here:http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model > > However, also have a look at this > approach:http://groups.google.com/group/django-developers/browse_thread/thread... > > It does require writing a context processor and a middleware, but they > are very small and simple, and they greatly simplify the use of your > user object in your views and templates. > > -- > +---+ > | Jason F. McBrayer[EMAIL PROTECTED] | > | If someone conquers a thousand times a thousand others in | > | battle, and someone else conquers himself, the latter one | > | is the greatest of all conquerors. --- The Dhammapada| --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
context processor question
Hi, As I understand context are data we can use in our templates, and the purpose of context processor is instead of doing something like c = Context({ 'latest_poll_list': latest_poll_list, }) or return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list}) the commonly use data will automatically available, do I get it right? Thanks james --~--~-~--~~~---~--~~ 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: context processor question
Hi Jeremy, I am a bit lost ... where do I apply that? Isn't that I just call the variable name/dict key in the template? Thanks james On Jul 19, 11:18 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote: > ... > > > the commonly use data will automatically available, do I get it right? > > Yes. Just keep in mind that you need to use RequestContext rather > than Context in order for context processors to be applied. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django foreignkey
hi, I have a model with a field models.ForeignKey(), with manage.py validate I check if my code are right, then run manage.py syncdb. When I was checking the tables generated I don't see any foreign key created? Is there something wrong? where should I check? I am using django 0.96, mysql 5 on winxp Thanks james --~--~-~--~~~---~--~~ 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 foreignkey
Hi Nathan, I did manage.py syncdb with the table still not existing. I did manage.py sqlall myapps when saw that the foreign key was not created. here is my actual source code. from django.db import models from django.contrib.auth.models import User as AdminUser # Create your models here. DEPARTMENTS = ( ('HRD', 'HRD'), ('ACT', 'Accounting'), ('PUR', 'Purchasing'), ('LOG', 'Logistics'), ('PRO', 'Production'), ('MKG', 'Marketing'), ('EXP', 'Export'), ('ITD', 'IT'), ) LEVELS = ( ('SM', 'Senior Manager'), ('MR', 'Manager'), ('SP', 'Supervisor'), ('ST', 'Staff'), ) class User(models.Model): """KSK Employee accounts to use this application""" user = models.ForeignKey(AdminUser) department = models.CharField(maxlength=3, choices=DEPARTMENTS) level = models.CharField(maxlength=3, choices=LEVELS) Thanks james On Jul 19, 2:56 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > manage.py syncdb won't add new fields to the database if the table > already exists. You'll have to do this yourself. See manage.py sqlall > for some help. > > Otherwise, if you have: user = models.ForeignKey(User), then look for > a field named user_id in your table. > > > Nathan Ostgard > > On Jul 18, 9:57 pm, james_027 <[EMAIL PROTECTED]> wrote: > > > hi, > > > I have a model with a field models.ForeignKey(), with manage.py > > validate I check if my code are right, then run manage.py syncdb. When > > I was checking the tables generated I don't see any foreign key > > created? Is there something wrong? where should I check? > > > I am using django 0.96, mysql 5 on winxp > > > Thanks > > james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
login() method conflict
hi, i've been trying to get started with django and i am stock in this problem and found out that there's a conflict in login() method. here is my view code from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response from django.contrib.auth import authenticate, login def index(request): if not request.user.is_authenticated(): return render_to_response('login.htm', {'from':request.path}) return render_to_response('index.htm') def login(request): if request.method == 'POST': user = authenticate(username=request.POST['username'], password=request.POST['password']) if user is not None: if user.is_active: #return HttpResponse('user authenticated') fixlogin(request, user) return HttpResponseRedirect('/main/') else: return HttpResponse('user not active') else: return HttpResponse('authenticate fail') return render_to_response('login.htm') The problem is an error saying login() method accept only one parameter, where I follow this documentation (http:// www.djangoproject.com/documentation/0.96/authentication/#how-to-log-a-user-in). After many times of trail and error I thought of changing this import from django.contrib.auth import authenticate, login to from django.contrib.auth import authenticate, login as fixlogin() and use fixlogin(request, user) Is this already fix? I am just using 0.96. Thanks james --~--~-~--~~~---~--~~ 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: login() method conflict
Thanks everyone, that was a foolish mistake... I am not only new to django but also new to python cheers, james On Jul 19, 4:09 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > You may find it easier to avoid these conflicts by doing: > from django.contrib import auth > > Then use: > user = auth.authenticate(username='foo', password='bar') > auth.login(request, user) > > On Jul 19, 1:02 am, james_027 <[EMAIL PROTECTED]> wrote: > > > hi, > > > i've been trying to get started with django and i am stock in this > > problem and found out that there's a conflict in login() method. here > > is my view code > > > from django.http import HttpResponse, HttpResponseRedirect > > from django.shortcuts import render_to_response > > from django.contrib.auth import authenticate, login > > > def index(request): > > if not request.user.is_authenticated(): > > return render_to_response('login.htm', {'from':request.path}) > > return render_to_response('index.htm') > > > def login(request): > > if request.method == 'POST': > > user = authenticate(username=request.POST['username'], > > password=request.POST['password']) > > if user is not None: > > if user.is_active: > > #return HttpResponse('user authenticated') > > fixlogin(request, user) > > return HttpResponseRedirect('/main/') > > else: > > return HttpResponse('user not active') > > else: > > return HttpResponse('authenticate fail') > > return render_to_response('login.htm') > > > The problem is an error saying login() method accept only one > > parameter, where I follow this documentation > > (http://www.djangoproject.com/documentation/0.96/authentication/#how-t..). > > After many times of trail and error I thought of changing this import > > from django.contrib.auth import authenticate, login to from > > django.contrib.auth import authenticate, login as fixlogin() and use > > fixlogin(request, user) > > > Is this already fix? I am just using 0.96. > > > Thanks > > james --~--~-~--~~~---~--~~ 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 foreignkey
anyone to help me on this? thanks james On Jul 19, 3:20 pm, james_027 <[EMAIL PROTECTED]> wrote: > Hi Nathan, > > I did manage.py syncdb with the table still not existing. I did > manage.py sqlall myapps when saw that the foreign key was not created. > > here is my actual source code. > > from django.db import models > from django.contrib.auth.models import User as AdminUser > > # Create your models here. > DEPARTMENTS = ( > ('HRD', 'HRD'), > ('ACT', 'Accounting'), > ('PUR', 'Purchasing'), > ('LOG', 'Logistics'), > ('PRO', 'Production'), > ('MKG', 'Marketing'), > ('EXP', 'Export'), > ('ITD', 'IT'), > ) > > LEVELS = ( > ('SM', 'Senior Manager'), > ('MR', 'Manager'), > ('SP', 'Supervisor'), > ('ST', 'Staff'), > ) > > class User(models.Model): > """KSK Employee accounts to use this application""" > > user = models.ForeignKey(AdminUser) > department = models.CharField(maxlength=3, choices=DEPARTMENTS) > level = models.CharField(maxlength=3, choices=LEVELS) > > Thanks > james > > On Jul 19, 2:56 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > manage.py syncdb won't add new fields to the database if the table > > already exists. You'll have to do this yourself. See manage.py sqlall > > for some help. > > > Otherwise, if you have: user = models.ForeignKey(User), then look for > > a field named user_id in your table. > > > > > Nathan Ostgard > > > On Jul 18, 9:57 pm, james_027 <[EMAIL PROTECTED]> wrote: > > > > hi, > > > > I have a model with a field models.ForeignKey(), with manage.py > > > validate I check if my code are right, then run manage.py syncdb. When > > > I was checking the tables generated I don't see any foreign key > > > created? Is there something wrong? where should I check? > > > > I am using django 0.96, mysql 5 on winxp > > > > Thanks > > > james --~--~-~--~~~---~--~~ 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 foreignkey
hi, it seems that there is a small bug for not creating the foreign key on the database. Please see this ticket. http://code.djangoproject.com/ticket/4930#preview Thanks james On Jul 20, 9:05 am, james_027 <[EMAIL PROTECTED]> wrote: > anyone to help me on this? > > thanks > james > > On Jul 19, 3:20 pm, james_027 <[EMAIL PROTECTED]> wrote: > > > Hi Nathan, > > > I did manage.py syncdb with the table still not existing. I did > > manage.py sqlall myapps when saw that the foreign key was not created. > > > here is my actual source code. > > > from django.db import models > > from django.contrib.auth.models import User as AdminUser > > > # Create your models here. > > DEPARTMENTS = ( > > ('HRD', 'HRD'), > > ('ACT', 'Accounting'), > > ('PUR', 'Purchasing'), > > ('LOG', 'Logistics'), > > ('PRO', 'Production'), > > ('MKG', 'Marketing'), > > ('EXP', 'Export'), > > ('ITD', 'IT'), > > ) > > > LEVELS = ( > > ('SM', 'Senior Manager'), > > ('MR', 'Manager'), > > ('SP', 'Supervisor'), > > ('ST', 'Staff'), > > ) > > > class User(models.Model): > > """KSK Employee accounts to use this application""" > > > user = models.ForeignKey(AdminUser) > > department = models.CharField(maxlength=3, choices=DEPARTMENTS) > > level = models.CharField(maxlength=3, choices=LEVELS) > > > Thanks > > james > > > On Jul 19, 2:56 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > > manage.py syncdb won't add new fields to the database if the table > > > already exists. You'll have to do this yourself. See manage.py sqlall > > > for some help. > > > > Otherwise, if you have: user = models.ForeignKey(User), then look for > > > a field named user_id in your table. > > > > > > > Nathan Ostgard > > > > On Jul 18, 9:57 pm, james_027 <[EMAIL PROTECTED]> wrote: > > > > > hi, > > > > > I have a model with a field models.ForeignKey(), with manage.py > > > > validate I check if my code are right, then run manage.py syncdb. When > > > > I was checking the tables generated I don't see any foreign key > > > > created? Is there something wrong? where should I check? > > > > > I am using django 0.96, mysql 5 on winxp > > > > > Thanks > > > > james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
setting up login required pages massly
hi, is there a stupidly fast way to make select but many pages to required login first? I am using 0.96 @login_required is cool, but 0.96 doesn't support LOGIN_URL in the settings.py yet. currently i am using something like this if not request.user.is_authenticated(): return render_to_response('login.htm', {'from':request.path}) for each view's function. thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
newforms
Which official django apps are using the newforms? I just want to take a look at the coding as I am trying to learn the django's newform thanks james --~--~-~--~~~---~--~~ 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: newforms
Hi Alper, I am very new to django so I dont know how does the oldform look like, anyway here is what I like in this new form * helps me create the necessary html code to use in my forms very fast (needs some enhancement, I've already create a ticket) * with new forms you can handle forms for partial fields of a single model, fields from multiple model, fields that even does link to a particular model at all * validation is cool, easy & nice cheers, james On Jul 20, 4:37 pm, Alper KANAT <[EMAIL PROTECTED]> wrote: > What is newforms any way ? A new looking (style) of a form or something > ? If so, can somebody post a screenshot please ? > > Alper KANAT ([EMAIL PROTECTED])http://raptiye.org > > Thomas Guettler yazmış: > > > Am Freitag, 20. Juli 2007 07:53 schrieb james_027: > >> Which official django apps are using the newforms? I just want to take > >> a look at the coding as I am trying to learn the django's newforms. > > > Hi, > > > there is a newforms admin branch. I think you can use this as an example. > > > I have not look at the branch up to now. I use newforms, but often I look > > into djang/newforms/*.py to find how to use and misuse it. > > > Thomas --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
shortcut for assigning values to model?
hi, is there a short cut for assigning input data to model's data attribute? if Book is a model then b = Book(request.POST) b.save() the assignment will be done on all the match key of the request.POST QueryDict and data attribute of the Book Model. or if BookForm is a newform then bf = BookForm() if bf.is_valid(): b = Book(bf.cleaned_data) thanks james --~--~-~--~~~---~--~~ 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: shortcut for assigning values to model?
@canen An example is if your forms are dealing with two or more models wherein form_for_model is for one model only. @nathan I am also new to python, where can I learn more about **kwargs? Cheers, james On Jul 21, 12:46 am, canen <[EMAIL PROTECTED]> wrote: > I may be mistaken but isn't this what form_for_model is for? > > On Jul 20, 11:23 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > Python also allows you to use ** to unpack a dict into a set of > > kwargs: > > > b = Book(**bf.cleaned_data) > > > On Jul 20, 4:28 am, LaundroMat <[EMAIL PROTECTED]> wrote: > > > > On 20 jul, 10:53, james_027 <[EMAIL PROTECTED]> wrote: > > > > > hi, > > > > > is there a short cut for assigning input data to model's data > > > > attribute? > > > > > if Book is a model then > > > > > b = Book(request.POST) > > > > b.save() > > > > > the assignment will be done on all the match key of the request.POST > > > > QueryDict and data attribute of the Book Model. > > > > > or > > > > > if BookForm is a newform then > > > > > bf = BookForm() > > > > if bf.is_valid(): > > > > b = Book(bf.cleaned_data) > > > > > thanks > > > > james > > > > You could run through the request.POST's keys and assign them to the > > > Model's attributes: > > > b = Book() > > > for key in request.POST.keys(): > > > ---b.__setattribute__(key, request.POST[key]) > > > b.save() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
foreign key on database not created with models referencing from other application
I am very new to django, I am creating a model with a field of models.ForeignKey(User) #django.contrib.auth.models import User. When I look at the database, my table has no foreign key define. Another example is the django.contrib.admin.models.LogEntry model it has user = models.ForeignKey(User) which is also from django.contrib.auth.models.user. When the relationship is within the same namespace (am I using the right term, pls correct me) the manage.py syncdb create the tables without a problem if all the tables are create on the same time, but if the tables weren't created the same time it also fail to create the foreign keys. Where should I look to correct this problem. from django.db import models from django.contrib.auth.models import User # Create your models here. DEPARTMENTS = ( ('HRD', 'HRD'), ('ACT', 'Accounting'), ('PUR', 'Purchasing'), ('LOG', 'Logistics'), ('PRO', 'Production'), ('MKG', 'Marketing'), ('EXP', 'Export'), ('ITD', 'IT'), ) LEVELS = ( ('SM', 'Senior Manager'), ('MR', 'Manager'), ('SP', 'Supervisor'), ('ST', 'Staff'), ) class Profile(models.Model): """KSK Employee accounts to use this application"" user = models.ForeignKey(User) department = models.CharField(maxlength=3, choices=DEPARTMENTS) level = models.CharField(maxlength=3, choices=LEVELS) Thanks james --~--~-~--~~~---~--~~ 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: foreign key on database not created with models referencing from other application
Hi, The table was created fine with only a small problem and it's the foreign key. I have my application listed on settings.py, code my model on models.py, then perform manage.py syncdb my_app as I am aware that if the table exist it wont recreate it. I did a number of times of deleting my tables and do manage.py syncdb my_app. As I stated the django_admin_log table should also have foreign key which also doesn't have it since it has a relation to auth_user table. I am doing this in winxp , mysql 5 , python 2.5 , latest mysql driver for python. Hope I've provided enough info. Thanks james On Jul 21, 10:38 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > When the relationship is within the same namespace (am I using the > > right term, pls correct me) the manage.py syncdb create the tables > > without a problem if all the tables are create on the same time, but > > if the tables weren't created the same time it also fail to create the > > foreign keys. > > I think you need to be a little bit more clear on what you have done - > and I mean precise instructions. _EXACTLY_ what steps have you taken, > and how have you come to the conclusion that the foreign key hasn't > been created? > > Creating tables is an operation that gets done every day by many > people, without difficulty. I have tried the models file you provide, > in various orders of creation, and have had no problems. Without > knowing exactly what you have done, it is impossible to know what has > gone wrong. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: foreign key on database not created with models referencing from other application
I didn't say that the relation aren't working, I just wondering why foreign key wasn't created in my case. I am using both SQL Manager 2005 lite and MySQL Administrator just to take a look at the table created. any idea? james On Jul 21, 11:16 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > I am doing this in winxp , mysql 5 , python 2.5 , latest mysql driver > > for python. Hope I've provided enough info. > > Not even close. > > Perhaps I'm not being clear. I have tried your example. It works for > me. The fact that many thousands of other people use Django and > haven't experienced this problem leads me to suspect that the problem > lies with you, not Django. > > However, you are obviously having a problem. What I need you to do is > provide me STEP BY STEP INSTRUCTIONS of EXACTLY what you have done. > Starting with no database in existence, and no django project at all, > how did you get into the situation? > > I also need to know HOW DO YOU KNOW THAT THE RELATION DOESN'T EXIST. > Are you guessing? Is a query not working like you expect? Are you > inspecting a GUI somewhere? Are you issuing an SQL query manually? > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: foreign key on database not created with models referencing from other application
Hi, I dont know what you mean by what_I_have_done? I just follow the django tutorial. the one with poll and choice model. I did every step. and that's my result. However I have discover something this setting INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', ) vs this setting INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', ) will produce a different result ... the first setting will have foreign key on the django_admin_log table while the 2nd table dont have the foreign key. I have do this multiple time, changing the settings between the first and the second and the result is constant. do we have ordering in creating models? thanks james On Jul 21, 12:49 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > I didn't say that the relation aren't working, I just wondering why > > foreign key wasn't created in my case. I am using both SQL Manager > > 2005 lite and MySQL Administrator just to take a look at the table > > created. > > When I run your example, the foreign key IS created. You are not the > first person to create a foreign key reference across applications, > and we haven't had any other complaints to date, so I am almost 100% > confident that the problem isn't with Django. > > I would like to help you solve your problem. Unfortunately, I'm not > telepathic. I can't help you if refuse to tell me WHAT YOU HAVE DONE. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: foreign key on database not created with models referencing from other application
hi, in the case of my application here is what i done (I start from scratch): 1. django-admin.py startproject ksk 2. django-admin.py startapp main 3. edit the settings.py file: database engine, name, user, password, password, and then add the ksk.main in the installed_apps INSTALLED_APPS = ( 'ksk.main', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', ) 4. cd into the main directory and edit the models.py here is the ksk.main application models.py from django.db import models from django.contrib.admin.models import User # Create your models here. class Profile(models.Model): user = models.ForeignKey(User) department = models.CharField(maxlength=20) level = models.CharField(maxlength=3) class CellUsage(models.Model): profile = models.ForeignKey(Profile) minutes = models.PositiveSmallIntegerField() 5. then i run python manage.py syncdb the result is ... in my cellusage table there is no foreign key created. but in the profile table there is a foreign created. 6. I delete all the tables again. I re order the items in the INSTALLED_APPS settings. from my step no. 3 instead of putting ksk.main in the last I put it in the first, then run manage.py syncdb the result is no foreign key on cellusage table and in the profile table also ... When I say I follow the django official I was referring to the apps I created with the tutorial. That results to no foreign key created on the choice table. Please help me, I am really desperate to know where did I go wrong. Why is it a foreign key can't be created with a simple relationship. Why is it that the order of application in the INSTALLED_APPS has effect when performing manage.py syncdb? iam using django .96, my python mysql driver is the latest version., i am doing this on windows env. Thanks Russ for helping me on this, i greatly appreciate it. james On Jul 21, 9:07 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/21/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > I dont know what you mean by what_I_have_done? > > Help me to replicate exactly the steps that you have taken to make > this problem occur. I have your model file. If _I_ use that model > file, and it works fine for me. Obviously you have done something > different somewhere else. What is it? The only way to work that out is > for you to tell me EVERYTHING you have done. For example: > > - I created a new project with ./django-admin.py startproject myproject > - I created a new application with ./manage.py startapp myapp > - I created a MySQL database using InnoDB tables > - I modified models.py to look like > > and so on, listing EVERY change you have made. > > > I just follow the django tutorial. the one with poll and choice model. > > I did every step. and that's my result. > > No, you didn't 'just follow the django tutorial'. If you had followed > the Django tutorial, your models file would have contained two models > named Poll and Choice, not a single model called Profile. I can't read > your mind to work out which steps you changed, and how you changed > them. Help me to retrace your steps. > > > > > However I have discover something > ... > > will produce a different result ... the first setting will have > > foreign key on the django_admin_log table while the 2nd table dont > > have the foreign key. I have do this multiple time, changing the > > settings between the first and the second and the result is constant. > > There will be differences in the SQL that is generated, but that's > only because of the handling of forward references. > > I've tried creating the tables for the two INSTALLED_APPS settings you > describe. I'm not a MySQL expert, but as far as I can make out, I'm > getting exactly the same tables created both ways. > > The only issue I can think of that could be affecting this is ticket > #2720 [1] - > if I remember correctly, if you're using InnoDB tables, the foreign > key column is created, but the constraint is not. Which brings me back > to my other question - exactly what do you mean when you say 'the 2nd > table doesn't have the foreign key', and how did you come to this > conclusion? Can you provide any output to show me exactly what has > been created on the database (e.g., the result of running "describe > django_admin_log" at an SQL prompt) > > [1]http://code.djangoproject.com/ticket/2720 > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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: foreign key on database not created with models referencing from other application
Hi russ, nice to hear from you again... As of now I am only saying that no foreign key is created by just checking the database tables itself, I haven't perform any django query. doing the describe main_profile and main_cellusage I got the same results ... but for me the MUL value on Key column doesn't represent a foreign key. here's the dll description from mysql manager lite CREATE TABLE `main_profile` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) NOT NULL, `department` varchar(20) NOT NULL, `level` varchar(3) NOT NULL, PRIMARY KEY (`id`), KEY `main_profile_user_id` (`user_id`), CONSTRAINT `user_id_refs_id_4af9714f` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `main_cellusage` ( `id` int(11) NOT NULL auto_increment, `profile_id` int(11) NOT NULL, `minutes` smallint(5) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `main_cellusage_profile_id` (`profile_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; the profile table's dell has constraint clause in it, while the cellusage table has no constraint clause only key clause is only tells that it is index. Thanks james On Jul 22, 11:37 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/22/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > 5. then i run python manage.py syncdb > > > the result is ... in my cellusage table there is no foreign key > > created. but in the profile table there is a foreign created. > > mysql> describe mytest_profile; > ++-+--+-+-++ > | Field | Type| Null | Key | Default | Extra | > ++-+--+-+-++ > | id | int(11) | NO | PRI | NULL| auto_increment | > | user_id| int(11) | NO | MUL | || > | department | varchar(20) | NO | | || > | level | varchar(3) | NO | | || > ++-+--+-+-++ > 4 rows in set (0.15 sec) > > mysql> describe mytest_cellusage; > ++--+--+-+-++ > | Field | Type | Null | Key | Default | Extra | > ++--+--+-+-++ > | id | int(11) | NO | PRI | NULL| auto_increment | > | profile_id | int(11) | NO | MUL | || > | minutes| smallint(5) unsigned | NO | | || > ++--+--+-+-++ > 3 rows in set (0.00 sec) > > Looks like two foreign keys to me. > > > 6. I delete all the tables again. I re order the items in the > > INSTALLED_APPS settings. from my step no. 3 instead of putting > > ksk.main in the last I put it in the first, then run manage.py syncdb > > > the result is no foreign key on cellusage table and in the profile > > table also ... > > mysql> describe mytest_profile; > ++-+--+-+-++ > | Field | Type| Null | Key | Default | Extra | > ++-+--+-+-++ > | id | int(11) | NO | PRI | NULL| auto_increment | > | user_id| int(11) | NO | MUL | || > | department | varchar(20) | NO | | || > | level | varchar(3) | NO | | || > ++-+--+-+-++ > 4 rows in set (0.00 sec) > > mysql> describe mytest_cellusage; > ++--+--+-+-++ > | Field | Type | Null | Key | Default | Extra | > ++--+--+-+-++ > | id | int(11) | NO | PRI | NULL| auto_increment | > | profile_id | int(11) | NO | MUL | || > | minutes| smallint(5) unsigned | NO | | || > ++--+--+-+-++ > 3 rows in set (0.00 sec) > > Again - two foreign keys, same tables as before. > > > Please help me, I am really desperate to know where did I go wrong. > > Why is it a foreign key can't be created with a simple relationship. > > Why is it that the order of application in the INSTALLED_APPS has > > effect when performing manage.py syncdb? > > I've asked before, and I'll
Re: foreign key on database not created with models referencing from other application
Thanks russ I greatly appreciate it!, I'll just wait for the fix. cheers, james On Jul 22, 11:01 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/22/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > the profile table's dell has constraint clause in it, while the > > cellusage table has no constraint clause only key clause is only tells > > that it is index. > > That appears to be the effect of ticket #2720 [1] that I mentioned > earlier. The foreign key column _is_ getting created - it's the > _constraint_ that isn't created correctly, depending on the order of > creation. Even more annoying - they syntax to create the constraint > actually _is_ generated - but MySQL ignores it. > > There is a proposed patch to fix this problem attached to the ticket. > I haven't looked at the patch, so I have no idea how good it is, or if > it solves the problem. > > This is a bug, and one of these days one of the core developers will > hopefully get around to looking at it. However, in practice, the > existence of this bug won't make much difference to you, especially as > you are just starting out with Django. It won't affect the views > Django produces, or the queries you can execute. Django's ORM > framework will provide some protection from putting invalid data into > the database - having the constraint in place acts as extra support to > make sure nothing goes wrong. > > If you need row-referential integrity _now_, I can only suggest using > a different database backend (MySQL has a few other annoying issues > that can pose difficulties). > > For future reference: It would have been possible to resolve this > issue in 1 or 2 emails if you had provided the SQL dump in the first > place. It sounds like you had this SQL dump from the very beginning, > but it took 6 emails for you to share this information with me. > Repeatedly saying "X doesn't work" doesn't help me (or anyone else) > debug a problem. On the other hand, stack traces, precise > instructions, or other debug printouts are very helpful. Help us to > help you, and everyone can go home early :-) > > [1]http://code.djangoproject.com/ticket/2720 > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
latest django version
Hi, I would like to use the latest django version. i am trying to use tortoise SVN to get the latest version, but iam always getting this error Error * REPORT request failed on 'http://code.djangoproject.com/svn/ django/trunk/django' REPORT of 'http://code.djangoproject.com/svn/ django/trunk/django': 400 Bad Request (http://code.djangoproject.com) is there an easy to get the latest version of django in winxp? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
learning django testing
hi, Here's another newbie stupid question ... I've heard testing everywhere from software development world, and the testing I know is to run the application I am developing and do all the possibilities that I user might do to make sure that the application behaves how it should be. I am studying this nice tutorial http://toys.jacobian.org/presentations/2007/oscon/tutorial/ And the first topic is testing. I don't have any idea what is the testing all about. Is testing means writing a program that will simulate the usage of an application? Could someone point me to a good short introduction about testing that is somehow gear towards to django or python? Thanks james --~--~-~--~~~---~--~~ 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: learning django testing
Thanks bob cheers, james On Jul 25, 11:48 pm, "Bob T." <[EMAIL PROTECTED]> wrote: > > I don't have any idea what is the > > testing all about. > > James, you might want to take a look at Dive Into Python [1] as a > starting place. It has a couple good chapters on testing and test > driven development. > > Bob > > [1]http://diveintopython.org/unit_testing/index.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
middleware or context_processors
Hi all, As I am trying to extend the django user model not using the auth_profile I have model like this class Profile(models.Model): """KSK Employee accounts to use this application""" user = models.ForeignKey(User, unique=True) department = models.CharField(maxlength=3, choices=DEPARTMENT_LIST) level = models.CharField(maxlength=3, choices=LEVEL_LIST) class Admin: pass def _get_username(self): return self.user.username username = property(fget=_get_username) In order to make use of the profile model as easy as the django user model I can make a middleware like this from ksk.main.models import Profile class ProfileMiddleware(object): """Use to synchronize django user and ksk profile""" def process_request(self, request): if request.user.is_authenticated(): request.profile = Profile.objects.get(user = request.user) else: request.profile = None and with context_processors like this def profile(request): return {'profile': request.profile} or just use only context_processors like this from ksk.main.models import Profile def profile(request): if request.user.is_authenticated(): profile = Profile.objects.get(user = request.user) else: profile = None return { 'profile': profile, } both of them works, but I don't have any idea which is better in terms of design? security? performance? Thanks james --~--~-~--~~~---~--~~ 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: latest django version
hi oggie, On Jul 26, 3:39 am, oggie rob <[EMAIL PROTECTED]> wrote: > Re: TortoiseSVN, take a look athttp://tortoisesvn.net/node/87 > Short story - unless you can get your admin to change your firewall, > you can't use svn since "code" doesn't respond to https, no matter > which platform you are using. > Thanks for pointing this out! I can now get the latest and greatest django version! cheers james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
newforms: common constraints
Hi all, I may not well understand the purpose of newforms, or perhaps it is still in a very early alpha stage ... I am looking to implement some common constraints like mininum or maximum letter of character field then values for numerical field., range for numerical or date field. Thanks james --~--~-~--~~~---~--~~ 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: newforms: common constraints
Thanks for the fast response Doug, but those min max constraints are so common? why not include it? james On Jul 27, 1:20 pm, Doug B <[EMAIL PROTECTED]> wrote: > Garg, hit enter too fast. > > Class MyForm(forms.Form): > username = forms.CharField(max_length=12) > def clean_username(self): > username = self.clean_data['username'] > if username == 'bob': > raise ValidationError("Bob is not allowed here") > return username > > If someone enters 'bob' for a username, form.is_valid() will be False, > anything else under 12 char long is ok > > There are existing fields that do a lot, for email, integers, and so > on... but if you want do do something they don't support, you've got > to do a bit yourself. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
adding contraints on admin
Hi, I really love Django admin, however how can I add customer validation or contraints to my models? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
error on models with foreign key on each other
Hi, I am trying to migrate an existing application to django. I am encountering the following problem with this models D:\private\james\documents\django\ksk>python manage.py validate manning.employee: Reverse query name for field 'employee_contract' clashes with field 'EmployeeContr act.employee'. Add a related_name argument to the definition for 'employee_contract'. manning.employee: Reverse query name for field 'employee_assignment' clashes with field 'EmployeeAss ignment.employee'. Add a related_name argument to the definition for 'employee_assignment'. 2 errors found. class Employee(models.Model): lastname = models.CharField(maxlength=30) firstname = models.CharField(maxlength=30) middlename = models.CharField(blank=True, maxlength=30) gender = models.CharField(maxlength=1) birthday = models.DateField() contact_no = models.CharField(blank=True, maxlength=50) address = models.CharField(maxlength=100) notes = models.CharField(maxlength=200) pay_by = models.CharField(maxlength=3, choices=PAY_BY_LIST) hour_rate = models.DecimalField(max_digits=7, decimal_places=2) allowance = models.DecimalField(max_digits=7, decimal_places=2) account_no = models.CharField(blank=True, maxlength=20) sss = models.CharField(blank=True, maxlength=20) phil_health = models.CharField(blank=True, maxlength=20) pag_ibig = models.CharField(blank=True, maxlength=20) employee_contract = models.ForeignKey('EmployeeContract') employee_assignment = models.ForeignKey('EmployeeAssignment') AREA_LIST = ( ('CKG', 'Cooking'), ('DLY', 'Delivery'), ('DYG', 'Drying'), ('FLA', 'Flavoring'), ('FYG', 'Frying'), ('LGS', 'Logistics'), ('MXG', 'Mixing'), ('PKG', 'Packaging'), ('ROG', 'Roasting'), ) class EmployeeAssignment(models.Model): employee = models.ForeignKey(Employee) assignment_from = models.DateField() assignment_to = models.DateField() area = models.CharField(maxlength=3, choices=AREA_LIST) position = models.CharField(maxlength=20) edit_by = models.ForeignKey(Profile) EMPLOYEE_CONTRACT_STATUS_LIST = ( ('ACT', 'Active'), ('FIN', 'Finnish'), ('RES', 'Resign'), ('TER', 'Terminate'), ) class EmployeeContract(models.Model): employee = models.ForeignKey(Employee) contract_to = models.DateField() contract_from = models.DateField() notes = models.CharField(blank=True, maxlength=200) status = models.CharField(maxlength=3, choices=EMPLOYEE_CONTRACT_STATUS_LIST) edit_by = models.ForeignKey(Profile) Although this problem can be solve with just renaming some of the fields. I wonder if when doing some django orm operation could produce a problem. thanks james --~--~-~--~~~---~--~~ 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: newforms: common constraints
hi, what will be the proper approach to do this? creating a custom fields or custom field validation? Thanks james On Jul 27, 10:53 pm, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]> wrote: > On 7/27/07, james_027 <[EMAIL PROTECTED]> wrote: > > > but those min maxconstraintsare socommon? why not include it? > > Because "common" is different for any given user and/or site. I think > *I've* only written a single form with min/max validation, FWIW. > Designing a framework is hard; you've got to search for things that > are as close to truly universal as possible. Otherwise you end up > including every little pet feature that someone asks for, and that's > known as "PHP". > > A good programmer will keep around his/her own library ofcommoncode > and break it out whenever needed. If you need min/max validation > often, you should make that the start of your own personal toolkit. > > Jacob --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
overiding the clean method on newforms
Hi, is there any sample on over riding the clean method of the newforms? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
retaining the data on validation error using newforms
Hi, this is how I am using the newforms. My Form class NewEmployeeForm(forms.Form): contract_from = forms.DateField() contract_to = forms.DateField() position = forms.CharField(max_length=20) My View def create_employee(request): f = None if request.method == 'POST': f = NewEmployeeForm(request.POST) if f.is_valid(): return HttpResponse('valid') return render_to_response('create_employee.htm', {'form':f}) My Template Contract from: {{form.contract_from.errors}} Contract to: {{form.contract_to.errors}} Position: {{form.position.errors}} my problem is after the validation error, I would like to populate the form with the posted data. One solution is to change my view to def create_employee(request): if request.method == 'GET': f = NewEmployeeForm() if request.method == 'POST': f = NewEmployeeForm(request.POST) if f.is_valid(): return HttpResponse('valid') return render_to_response('create_employee.htm', {'form':f}) and my template to {{form.contract_from.label}} {{form.contract_from}} {{form.contract_from.errors}} {{form.contract_to.label}} {{form.contract_to}} {{form.contract_to.errors}} {{form.position.label}} {{form.position}} {{form.position.errors}} but my problem here is that how can I apply my css if I can't change the class attribute of label and input tag generated by the newforms? any ideas? james --~--~-~--~~~---~--~~ 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: overiding the clean method on newforms
Hi, > > http://django-registration.googlecode.com/svn/trunk/registration/form... > Thanks Nathaniel, I am looking for over riding the clean() instead of clean_(). After hours of experiments. I would like to confirm if my learnings are correct. in over riding the clean() method, I have to first check if the attribute I want to check on is available on the cleaned_data dictionary, if not I will not proceed to my validation, if yes then proceed to my custom validation. All the Validation I raise in the clean() method will be recorded on the _errors dictionary? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how to overcome {% if %} limitation
Hi, I am very new to django, now I am dealing with templates. Coming from JSP, I am suprise that in django we can't do something like {% if Events.objects.filter(...).count > 10 %} Is there a way to do something like that? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
learning django's HttpRequest Object and Middleware
Hi, I want to make sure that my understanding is right. is middleware the place where I can add more attribute to the HttpRequest Object and manipulate the added attribte? Is this advisable? if Not where is the right place to do it? Thanks james --~--~-~--~~~---~--~~ 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: learning django's HttpRequest Object and Middleware
Hi Thomas > The methods of each middleware are called one for every request. If your > changes need information from the request, that's the right place. > > If you want to add a method which should be added once the server (mod_python, > scgi, ...) starts you can use this place too. But it is better if you use > the module level of the middleware: > > MyMiddleWare.py > > foofunc() # executed on server start > > class MyMiddleWare: > def process_request(...): > # executed for every request. Thanks for this info. What is this foofunc() (a method that can be anyware in the django source?) I have another question, when do I use middleware for additional attribute to put place on the request object VS the request.session objects? Thanks james --~--~-~--~~~---~--~~ 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 overcome {% if %} limitation
Thanks everyone! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
remember me feature
hi, is implementing remember me feature for login is as simple as changing the cookies settings in the settings.py? is manipulating of setting.py allowed in views? THanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
understanding request.user
hi, I am seeking some enlightenment as why the user (variable use to track if the user is logged in or not) seems to be on the request level and not on the session which is the practice of most or all of web framework? If I am not wrong request.user is done on the middleware which will get executed on every request, this could be a unnecessary process? Thanks james --~--~-~--~~~---~--~~ 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: understanding request.user
hi, > request.user gets created by to OR mapping (from the sql database). > request.session comes from a pickle (serialized to a bytestream). > > Both needs to be done for every request. You could use caching, > but object caching (like for request.user) is not possible up to now. > Just like what you say request.user needs to be done on every request why is it not design to put it in the session ... instead of request.user it should be request.session['user'] ... although request.user is much code friendly, I just want to understand how django works for me to learn this framework well. Isn't session will be done only if there's a change in it? assumming we define SESSION_SAVE_EVERY_REQUEST = False Thanks james --~--~-~--~~~---~--~~ 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: default behavior of django.middleware.transaction.TransactionMiddleware
hi, anyone to clarify this? On Jul 17, 4:54 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > If I use django.middleware.transaction.TransactionMiddleware, is > @transaction.commit_on_success the default behavior? or I should > always call on the python decorators? > > Thanks > james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
something I really don't know in using manage.py shell
hi, i am trying to use the manage.py shell, for fast testing of what I would like to do. I have a model like this class Function(models.Model): """Functions that KSK Employee account could use""" name = models.CharField(maxlength=40) url = models.CharField(maxlength=40, default='/') method = models.CharField(maxlength=40, default='index') class Profile(models.Model): """KSK Employee accounts to use this application""" user = models.ForeignKey(User, unique=True) department = models.CharField(maxlength=3, choices=DEPARTMENT_LIST) level = models.CharField(maxlength=2, choices=LEVEL_LIST) functions = models.ManyToManyField(Function, blank=True) when I do in the shell >>>p = Profile.objects.filter(id=1) >>>p [] but when I did this >>>p.department it say AttributeError: '_QuerySet' object has no attribute 'level' is there anything I should know? THanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django equivalent of ROR flash
Does Django have this http://api.rubyonrails.com/classes/ActionController/Flash.html Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
value for choices arguments for newforms.MultipleSelectField
hi somewhere on the django documentation I saw the choice provided for MultipleSelectField is from a Database but I can't recall where I read it but I do it this way, let me know if there are better alternative items = newforms.MultipleChoiceField(choices = [('i.id', 'i.name') for i in Items.objects.all()]) Thanks james --~--~-~--~~~---~--~~ 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: value for choices arguments for newforms.MultipleSelectField
H On Aug 2, 11:35 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > You can use ModelMultipleChoiceField for this: > > items = > newforms.ModelMultipleChoiceField(queryset=Items.objects.all()) > I don't see ModelMultipleChoiceField on the documentaion or the latest source code Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Firebird support
Hi, anybody here heard of firebird database? how can I get support from django? Thanks james --~--~-~--~~~---~--~~ 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 handle forms with more than submit button
hi > create different URLs (and thus different views) for the different > buttons and then redirect to wherever you want to go. > How do I create a different URL for different buttons but under one form? Thanks james --~--~-~--~~~---~--~~ 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 handle forms with more than submit button
hi, On Aug 3, 11:12 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Oh... forgot the semicolons after .submit(); but you get the picture > thanks carole, yes I the picture. so its about javascript not django ... cheers, james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how to handle forms with more than submit button
Hi, How do I handle this situation wherein I want different submit button to call different method on the views. I feel that calling the same method on views for all the submit button on a form is not good, as you'll make the distinction of what to do inside the method... Thanks james --~--~-~--~~~---~--~~ 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 handle forms with more than submit button
Hi, On Aug 3, 11:21 am, Doug B <[EMAIL PROTECTED]> wrote: > As far as I know a form submits to a single url via the action=? > specifier. That's just the way an html form works. Each submit > button that is part of the form is going to post to the action url in > the form. You can override with javascript, but that doesn't make > much sense unless you're doing ajax or something. > > You CAN check to see which submit button was used in the view, and > make logic decisions accordingly. Just make sure you name your submit > buttons and check which is in request.POST and make logic decisions > from there. > > in template > > > > then in view > if request.POST: > if request.POST.has_key('button1'): > do button 1 stuff > elif request.POST.has_key('button2'): > do button 2 stuff thanks doug, this is what I did, but I am not comfortable with it. those two button do different things, and if they're under one method on the views it could be ugly, what if I have 4 or 5 submit buttons? any other sugguestions? thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
help serving static files (css, images, pdf, js)
hi, I already did the (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root':'d:/private/james/documents/django/ksk/media'}), in my urls.py and in my template i have something like this but why is it the image still don't appear? Thanks james --~--~-~--~~~---~--~~ 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: help serving static files (css, images, pdf, js)
hi, are this settings used when running under development mode? MEDIA_ROOT MEDIA_URL does it affect the django.views.static.serve? thanks james --~--~-~--~~~---~--~~ 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: help serving static files (css, images, pdf, js)
hi, On Aug 3, 4:32 pm, koenb <[EMAIL PROTECTED]> wrote: > My guess is you are interfering with your admin_media (look at the > admin_media_prefix setting). > Try using something like r'^sitemedia/... and src="/sitemedia/...". > Thanks koen, that did it. I think it could be nice if it was mention on the documentation. cheers, james --~--~-~--~~~---~--~~ 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: help serving static files (css, images, pdf, js)
hi Kai, > If you do not use it, no. > If I use it, how does it affect then? thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
an application with print on dot matrix printer
hi, what is the nice way to provide a print function on a dot matrix printer for django apps aside from generating a printer friendly page? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
elseif or elseifqual or elseifnotequal
Hi, Just want to confirm if elseif and the alike doesn't exist in django's template. What tricks could be give to newbies if something like is needed ... if bool: elseif bool: elseif boo: it could be not nice to do something like this in django's template {% if bool %} {% else %} {% if bool %} {% else %} {% if bool %} {% endif %} {% endif %} {% endif %} THanks james --~--~-~--~~~---~--~~ 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: elseif or elseifqual or elseifnotequal
hi kai! thanks a lot. this will help a lot. cheers, james On Aug 6, 4:02 pm, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > Hi James, > > On 8/6/07, james_027 <[EMAIL PROTECTED]> wrote: > > > Just want to confirm if elseif and the alike doesn't exist in django's > > template. > > > What tricks could be give to newbies if something like is needed ... > > Is switch ok? :)http://www.djangosnippets.org/snippets/300/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
weird django orm behavior
Hi, I have this models ... class Employee(models.Model): emplyoee_contract = models.ForeignKey('EmployeeContract', null=True, related_name='contracted_employee') employee_assignment = models.ForeignKey('EmployeeAssignment', null=True, related_name='assigned_employee') class EmployeeAssignment(models.Model): employee = models.ForeignKey(Employee) assignment_from = models.DateField() assignment_to = models.DateField() area = models.CharField(maxlength=3, choices=AREA_LIST) position = models.CharField(maxlength=20) edit_by = models.ForeignKey(Profile, null=True) class EmployeeContract(models.Model): employee = models.ForeignKey(Employee) contract_to = models.DateField() contract_from = models.DateField() notes = models.CharField(blank=True, maxlength=200) status = models.CharField(maxlength=3, choices=EMPLOYEE_CONTRACT_STATUS_LIST) edit_by = models.ForeignKey(Profile, null=True) and I have something like this in my view e = Employee() for key in f.cleaned_data.keys(): e.__setattr__(key, f.cleaned_data[key]) e.save() c = EmployeeContract() for key in f.cleaned_data.keys(): c.__setattr__(key, f.cleaned_data[key]) c.employee = e c.status = 'ACT' c.save() a = EmployeeAssignment() for key in f.cleaned_data.keys(): a.__setattr__(key, f.cleaned_data[key]) a.employee = e a.assignment_from = c.contract_from a.assignment_to = c.contract_to a.save() e.employee_assignment = a e.employee_contract = c e.save() all the data are valid, the problem here is that the employee.employee_contract is not get assign. everything got save successfully. here is the sql django's running {'time': '0.015', 'sql': u'INSERT INTO `manning_employee` (`lastname`,`firstname`,`middlename`,`gender`,`birthday`,`contact_no`,`address`,`notes`,`pay_by`,`hour_rate`,`allowance`,`account_no`,`sss`,`phil_health`,`pag_ibig`,`emplyoee_contract_id`,`employee_assignment_id`) VALUES (Dy,Willie,,M,1977-02-18,,Laguna,,HRR, 34.37,50.00,None,None)'}, {'time': '0.000', 'sql': u'INSERT INTO `manning_employeecontract` (`employee_id`,`contract_to`,`contract_from`,`notes`,`status`,`edit_by_id`) VALUES (13,2007-10-21,2007-03-18,,ACT,None)'}, {'time': '0.000', 'sql': u'INSERT INTO `manning_employeeassignment` (`employee_id`,`assignment_from`,`assignment_to`,`area`,`position`,`edit_by_id`) VALUES (13,2007-03-18,2007-10-21,ADM,Supervisor,None)'}, {'time': '0.000', 'sql': u'SELECT COUNT(*) FROM `manning_employee` WHERE `id`=13'}, {'time': '0.000', 'sql': u'UPDATE `manning_employee` SET `lastname`=Dy,`firstname`=Willie,`middlename`=,`gender`=M,`birthday`=1977-02-18,`contact_no`=,`address`=Laguna,`notes`=,`pay_by`=HRR,`hour_rate`=34.37,`allowance`=50.00,`account_no`=,`sss`=,`phil_health`=,`pag_ibig`=,`emplyoee_contract_id`=None,`employee_assignment_id`=10 WHERE `id`=13'}] as you can see the last update statement has employee_contract_id = None ... which I don't know what make it happen? anything wrong with my models or views? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
multiple user account login
Hi, How do I enable multiple user account login in one computer? I don't know what is the disadvantage if this works this way, I just need it for development and testing purpose. Thanks james --~--~-~--~~~---~--~~ 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: multiple user account login
Hi, > I think the OP is asking for the ability to have more than one > different user simultaneously logged into the web app. This > isn't conventionally feasible. You can use multiple browsers > (I've used FireFox, IE, Lynx, and Dillo for testing various users > at the same time) or possibly even a browser such as FF that > supports multiple profiles (I don't know if you can start > multiple profiles simultaneously in FF, and have them keep > sessions separate). > > From a testing framework perspective, you certainly can have > multiple "users" in your tests. This is helpful for testing > concurrency scenarios. However, this "browsing" is merely > scripting. If you're asking for multiple user account logins > from the same computer, just so you can make testing easy, I > recommend looking into Django's (and Python's) unit testing > framework. This allows you to do this sort of testing in a > repeatable, automated way. > > -tim Yes, that's what I mean. Thanks again Tim cheers, james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
using chaining filter() and select_related()
hi, I am doing something like this params = request.GET['name'].split() employees = Employee.objects.all().select_related() for p in params: employees = employees.filter(Q(firstname = p) | Q(lastname = p)) the query is fine but when I look at the connection.queries django still is not using join selects ... Any idea? james --~--~-~--~~~---~--~~ 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: using chaining filter() and select_related()
Hi, On Aug 8, 1:37 pm, Udi <[EMAIL PROTECTED]> wrote: > Try doing the select_related() at the end > > Remove the first use of it and then after the loop add this: > employees = employees.select_related() > > I think that'll work? > I try but it didn't work ... james --~--~-~--~~~---~--~~ 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: using chaining filter() and select_related()
hi On Aug 8, 1:45 pm, Margaret <[EMAIL PROTECTED]> wrote: > how > > employees = employees.join(employees.filter(Q(firstname = p) | Q(lastname= > p))) > is this something new that hasn't been yet documented? james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django.views.generic.simple
hi, is the purpose of this view for showing static html page? if not what is the use of this view? Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Is this not allowed select_related()
hi, I have this model which doesn't work when using select_related(). What happen is django seems to be in a infinite loop. class Employee(models.Model): employee_contract = models.ForeignKey('EmployeeContract', related_name='contracted_employee') employee_assignment = models.ForeignKey('EmployeeAssignment', related_name='assigned_employee') class EmployeeAssignment(models.Model): employee = models.ForeignKey(Employee) assignment_from = models.DateField() assignment_to = models.DateField() area = models.CharField(maxlength=3, choices=AREA_LIST) position = models.CharField(maxlength=20) edit_by = models.ForeignKey(Profile, null=True) class EmployeeContract(models.Model): employee = models.ForeignKey(Employee) contract_to = models.DateField() contract_from = models.DateField() notes = models.CharField(blank=True, maxlength=200) status = models.CharField(maxlength=3, choices=EMPLOYEE_CONTRACT_STATUS_LIST) edit_by = models.ForeignKey(Profile, null=True) Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
context vs request context
Hi, While I was studying the list generic view. I ask myself why does the django generic view list uses request context to store the pagination related info instead of a regular context. If I understand it right, using the request context could provide additional info from the context processor to the template, unlike the request context will which only the the info you pass in from the view? Thanks james --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
Hi collin On Aug 9, 1:06 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > Because you have an infinite loop there. > > Why are you linking both directions? There's a reverse relation > available to get from EmployeeAssignment and EmployeeContract back to > the Employee model, you don't need to explicitly define it. The EmployeeAssignment and EmployeeContract keeps track the history of each employee contract and assignment they receive, while the employee_contract and the employee_assignment attributes tells their current status ... Regards, james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
getting pagination tag to work
hi, I am trying to do this http://code.djangoproject.com/wiki/PaginatorTag I have two apps in my projects which are main and manning. I put the pagination tag code in the main/templatetags/extra_tags.py file. And I am trying to use the tag from a template in manning/templates/ results.htm. But I am getting this error "TemplateDoesNotExist at / manning/search_employee/ paginator.htm". I place the paginator.htm in main/templates folder. how do I correct this? thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
pagination for search result ...
hi, I am trying to put a page list for a search result. So far here's what I've try by using the django.views.generic.list_detail.object_list and the pagination tag (http://code.djangoproject.com/wiki/PaginatorTag) and later found out that it won't meet my needs. def search_employee(request): if not request.GET: return render_to_response('search_employee.htm') else: params = request.GET['name'].split() employees = Employee.objects.all() for p in params: employees = employees.filter(Q(firstname = p) | Q(lastname = p)) return object_list(request, employees, paginate_by=3, template_name='search_employee_result.htm', template_object_name='employee') This won't work because when you try to select other page the query_set from previous is lost ... I am thinking off passing the request.GET to the object_list's extra_context argument, then edit the pagination tag that will provide link constrcuted from the extra_context? Or is there a better solution or existing solution? Thanks james --~--~-~--~~~---~--~~ 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: pagination for search result ...
Hi Kai, > > Do you mean that the filter works on the first page but > is lost when you go to another page? If yes: > I save my filter in a session and filter on each page using > that filter values (the values that were given to the input fields > of the filter form). I don't know whether this is the right way (tm) > but it works for me. :-) > Could you share you code how your save your filter in session? THanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
context processors execution
hi, Are the context processors executed only when you pass a request context from view to template? The documentation mentions that a requestcontext could accept an optional argument which is a context processor, is it the same as putting the context processor in the context processor settings but only gets executed when as requested by the requestcontext? Thanks james --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
hi, On Aug 9, 11:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > He means that you can remove: > > employee = models.ForeignKey(Employee) > > from your 'EmployeeAssignment' and 'EmployeeContract' models because > the relationship is already defined in your 'Employee' model. You can > use reverse relations to get the relation instead. > when i remove the employee = models.ForeignKey(Employee), how can I get the history of employee contract & assignment? THanks james --~--~-~--~~~---~--~~ 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: pagination for search result ...
hi, > def list_filter(request): > """Update session filter""" > # request['filter'] is a hidden field. frankly, I don't know if > this is really needed. > # I added it in case I add another form to the template > if request.method == 'POST' and request['filter'] == '1': > request.session['filter_title'] = request.POST['title'] > request.session['filter_genre'] = request.POST['genre'] > request.session['filter_rating'] = request.POST['rating'] > return HttpResponseRedirect('/') > thanks kai :). is this request['filter'] a django builtin or u just created it? james --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
hi collin, On Aug 10, 11:26 am, Collin Grady <[EMAIL PROTECTED]> wrote: > What do you mean by "get the history" ? the employee could have new contract & assignment as months goes by. the employee_contract & employee_assignment tells of their recent contract & assignment. while the employee attribute on the EmployeeContract & EmployeeAssignment will make the getting of employee contracts & assignment history possible. Thanks james --~--~-~--~~~---~--~~ 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: pagination for search result ...
hi, On Aug 10, 11:25 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > > > hi, > > > > def list_filter(request): > > > """Update session filter""" > > > # request['filter'] is a hidden field. frankly, I don't know if > > > this is really needed. > > > # I added it in case I add another form to the template > > > if request.method == 'POST' and request['filter'] == '1': > > > request.session['filter_title'] = request.POST['title'] > > > request.session['filter_genre'] = request.POST['genre'] > > > request.session['filter_rating'] = request.POST['rating'] > > > return HttpResponseRedirect('/') > > > thanks kai :). is this request['filter'] a django builtin or u just > > created it? > > No, I added it. It's a hidden field just to check that's the filter > that is fired up and not another form on the page. > > To tell the truth, this should be request.POST['filter'] and I > don't really know why request['filter'] worked. Thanks for > pointing that out. :-) > > Kai THanks for all of this! cheers, james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
url styling
hi, is there any advantage or disadvantage or best practices in forming urls? like which set are much better? domain/employee/1 domain/edit_employee/1 domain/inactive_employee/1 or domain/employee/1 domain/employee/1/edit/ domain/employee/1/inactive/ thanks james --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
THanks Doug > > class Employee(models.Model): > # your employee model fields here, no FKs to Contact or > Assignment models > ... > > class EmployeeAssignment(models.Model): > active = models.BooleanField() # I added this > employee = models.ForeignKey(Employee) > ... > > class EmployeeContract(models.Model): > active = models.BooleanField() # I added this > employee = models.ForeignKey(Employee) > ... > > then you could do > > bob = Employee.objects.get(pk=1) > current_contacts = bob.employeecontract_set.filter(active=True) > current_assignments = bob.employeassignment_set.filter(active=True) > > I added the active flag to differentiate history vs current cheers, james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django built-in web server
hi, Can I use the django's built in web server in an intranet enviroment where the maximum users could be not more than 50 users? I am just asking this for the purpose for easy deployment :). I am very newbie, and trying to avoid apache THanks james --~--~-~--~~~---~--~~ 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 built-in web server
Hi, > > > I am very newbie, > > and trying to avoid apache > > why? > Just in case a problem occur, I think it could be more easy to troubleshoot it without being a apache expert? Or if threre's a patch for the client's program that need to be apply it could be much easier? THanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
scheduling job
hi, This might not be a django stuff, but how could I write something that will execute itself depending on the frequency that I'll set. For example, since django session table needs to be clean up at a certain time, I want to write a script that will execute itself monthly to clean up the session table. Thanks james --~--~-~--~~~---~--~~ 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: editing newforms field
Hi, On Aug 10, 4:12 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > Yes, just edit the fields in form.fields :) I am sorry, I didn't make it clear, I mean changing it like in views? james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
editing newforms field
hi, is it possible to edit the newforms field like required from true to false? or editing the widget property? Thanks james --~--~-~--~~~---~--~~ 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: context processors execution
hi, someone to confirm this? thanks james On Aug 10, 10:29 am, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > Are the context processors executed only when you pass a request > context from view to template? The documentation mentions that a > requestcontext could accept an optional argument which is a context > processor, is it the same as putting the context processor in the > context processor settings but only gets executed when as requested by > the requestcontext? > > Thanks > james --~--~-~--~~~---~--~~ 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: context processors execution
hi Matt, On Aug 13, 3:13 pm, "Matt Davies" <[EMAIL PROTECTED]> wrote: > James, are you talking about putting a context processor into the > settings.py file? > yes, and also context processor called as argument on views by ContextRequest() Thanks james --~--~-~--~~~---~--~~ 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: Installing django on a vm using NAT - SVN 400 bad request
Hi, On Aug 14, 9:36 am, sanchothefat <[EMAIL PROTECTED]> wrote: > Hi, I'm trying to get django going on a debian etch vm I have which > uses NAT to access the web. I found some info that suggested using https:// > but that won't work. > Should I try ubuntu or is there something in the vm settings I need to > change? I'm still quite new to *nix but making progress so any advice > you can give me on what things to try is very welcome. > > Ta very much, > Rob looks like a firewall is avoiding you james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
production instance on windowsxp
Hi, Ask I have successfully try to run django apps on apache/mod_python/ winxp, I learn that apache for winxp only support worker_mpm oppose to what django is suggesting (prefork_mpm). Should I worry about this? Or should I go with fast cgi? THanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ModelChoiceField on newforms
hi, while learning and experimenting with forms ... one should use ModelChoiceField in order to let newforms bind the value on a foreignkey field of a model. My concern is that in the real world, you usually don't use to let the user chose the value to be filled especially if the list of choices is very very large. While I have success with ModelChoiceField(Item.object.all(), widget=TextInput), providing a for entering a value which could come from a selected record thru searching, my concerned/question is ... 1. Does the Item.objects.all() get executed while rendering the ? (I hope not since the widget is not the ) 2. Does the Item.objects.all() get executed when in the process of assignment. example class InvoiceItem(models.Model): qty = models.PositiveInteger() item = models.ForeignKey(Item) class InvoiceItemForm(forms.Form): qty = forms.IntegerField() item = models.ModelChoiceField(Item.objects.all(), widget=TextInput) f = InvoiceItemForm(requst.POST) if f.is_valid(): ii = InvoiceItem(**f.cleaned_data) ii.save() (I hope during the assignment ii.item = f.item, the Item.objects.all() is not executed but instead it will do something like item.objects.all().filter(id="value from the text input"). If this is the case then I have no problem with this approach but if not could some share their solution?) Thanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---