Re: how should reusable apps handle url namespace?
independed urls.py file On Sat, Jun 12, 2010 at 10:45 AM, HARRY POTTRER wrote: > On Jun 4, 4:10 am, Daniel Roseman wrote: > > On Jun 4, 5:06 am, HARRY POTTRER wrote: > > > > > I'm writing a forum app that I want to be reusable. All of my urls I > > > have named. Some of them are named like "index" and "thread" which are > > > generic and will likely collide with existing project's urls. I don't > > > want to do something like name all my urls "forum_index" and > > > "forum_thread" either. > > > > > I think the best way is to use the newnamespacefeature, but I'm not > > > quite sure how to do it for reusuable apps. The docs make it seem like > > > the only purpose ofnamespaceurls is when you have two or more > > > instances of an app. > > > > You don't need to do anything with it. You don't define thenamespace > > in the application's urlconf, the end developer does it when they > > include your application's urlconf in their project-level one. See the > > docs on defining namespaces: > http://docs.djangoproject.com/en/1.2/topics/http/urls/#defining-url-n... > > -- > > DR. > > but how do I handle get_absolute_url? I don't see how I'm supposed to > resolve any urls if I don't supply it with a namespace... > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: error : python manage.py shell
I think like Kenneth... django is the same python but additional library. No python - no django My recommendation Python Essential Reference 4th edition On Sat, Jun 12, 2010 at 11:01 AM, Kenneth Gonsalves wrote: > On Saturday 12 June 2010 10:39:36 Jagdeep Singh Malhi wrote: > > IndentationError: unindent does not match any outer indentation level > > > > no one help you in this unless you are willing to do some homework - most > IDEs > have a button to press to compile the code - mine uses f8. Press that key > and > it will show the indentation error - indentation is part of python syntax. > You > should not waste the time of this list by bringing up basic python errors > here > - if necessary please take a short course in python. > -- > Regards > Kenneth Gonsalves > Senior Associate > NRC-FOSS at AU-KBC > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I experience problem with special chars like æ øå in filename when using models.ImageField. and models.Fi leField
did you tried so: import sys reload(sys) sys.setdefaultencoding('utf-8') or something similar? On Sun, Jun 13, 2010 at 1:25 AM, MichaleHjulskov wrote: > Hi Bjørn > > I have allready # -*- encoding: utf-8 -*-# in top of my settings.py > and models.py > > Should I put it in all my .py files? > > Thanks :o) > > > On 12 Jun., 17:06, Bjørn Høj Jakobsen wrote: > > Hi > > > > Try and put "# -*- encoding: utf-8 -*-#" in the top of the py script. > > > > These danish characters really are a pain the ass. > > > > Regards > > > > Bjørn > > > > On 12 Jun., 14:37, MIL wrote: > > > > > I experience problem with special chars like æøå in filename when > > > using models.ImageField. > > > > > What am I doing wrong? > > > > > models.py > > >picture = models.ImageField(upload_to='pics', blank=True, > > > verbose_name='Picture of you') > > > > > Using model forms > > > > > Let say I want to upload picture named "æøå.jpg" > > > > > If I do that, I get the following error msg: > > > 'ascii' codec can't encode characters in position 59-61: ordinal not > > > in range(128) > > > > > Django ver 1.2 Alpha > > > > > Please help me thanks > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ordering fields in admin form
You should do it in admin.py class MyClassAdmin(admin.ModelAdmin): ordering = ['-myfield'] On Sun, Jun 13, 2010 at 6:18 AM, darren wrote: > I'm sure the answer is probably documented clearly somewhere. But, I > can't find it. > > I would like to change the ordering of a field in a form on the admin > site based on the model below. The "game" column is several records > long. I would like to order desc. I've tried adding a META class to > my model and tinkering with the admin.py. But, I haven't been able to > figure this out. > > Could someone point me to the documentation? I've been reading this: > http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#ref-contrib-admin, > but I don't see what I'm looking for there. > > Thanks > > 104 class AtBat(models.Model): > 105 atbat_id = models.AutoField(primary_key=True) > 106 player = models.ForeignKey(Person, to_field='f_name', > verbose_name='Player', limit_choices_to={'relationship' : 'Player'}) > 107 game = models.ForeignKey(Score, to_field='scores_id', > verbose_name='Game') > 108 result = models.CharField('Result', choices=(('H', 'Hit'), > ('BB', 'Walk'), ('K', 'Strike Out'), ('ROE', 'Reached On Error'), > ('HBP', 'Hit By Pitch'), ('FO', 'Ground or Fly Out'), ('FC', 'Fielders > Choice'), ('Sacrifice', 'Sacrafice')), max_length=10) > 109 rbi = models.PositiveSmallIntegerField("RBI", default=0) > 110 > 111 def __unicode__(self): > 112 return unicode('%s %s %s %s' % (self.atbat_id, > self.player, self.game, self.result)) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: My http://localhost/admin/ display
ln -s admin/media to /var/ww On Sun, Jun 13, 2010 at 7:04 PM, Jagdeep Singh Malhi < singh.malh...@gmail.com> wrote: > > > On Jun 13, 12:12 am, Rolando Espinoza La Fuente > wrote: > > On Sat, Jun 12, 2010 at 12:58 PM, Jagdeep Singh Malhi > > > > wrote: > > > Myhttp://localhost/admin/ is display in pattern without grapic or > > > image not like that which is shown in Tutorial > > >http://docs.djangoproject.com/en/1.2/intro/tutorial02/#intro-tutorial02 > > > > > MY admin page (http://localhost/admin/) > > > > > Django administration > > > Welcome, Jagdeep. Change password / Log out > > > Site administration > > > Auth > > > Groups Add Change > > > Users Add Change > > >Polls > > > Polls Add Change > > >Sites > > > Sites Add Change > > > > > Recent Actions > > > My Actions > > > > > where is the problem .i am not able to find??? > > > > Using manage.py runserver you shouldn't have this problem. > > runserver command takes care of admin styles. > > > > Are you using apache as webserver? > > > > ~Rolando > > yes i am using apache as the Web server... > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I experience problem with special chars like æ øå in filename when using models.ImageField. and models.Fi leField
It also depends on your filesystem i think On Mon, Jun 14, 2010 at 1:18 AM, MichaleHjulskov wrote: > Hi Karen, I did not know there was a new release, sorry. > > So if I just install the new release, it will solve the problem just > like that? > Or do I still need to do something, in order to make it work with > special chars in the filenames? > > Thanks :o) > > Michael > > > > On 13 Jun., 01:47, Karen Tracey wrote: > > On Sat, Jun 12, 2010 at 8:37 AM, MIL wrote: > > > I experience problem with special chars like æøå in filename when > > > using models.ImageField. > > > > > What am I doing wrong? > > > > > models.py > > > picture = models.ImageField(upload_to='pics', blank=True, > > > verbose_name='Picture of you') > > > > > Using model forms > > > > > Let say I want to upload picture named "æøå.jpg" > > > > > If I do that, I get the following error msg: > > > 'ascii' codec can't encode characters in position 59-61: ordinal not > > > in range(128) > > > > > Django ver 1.2 Alpha > > > > The full traceback instead of just the error message would help people > help > > you. Perhaps try this: > http://docs.djangoproject.com/en/1.2/howto/deployment/modpython/#if-y > > Though that is in with the mod_python doc, it is not a mod_python > specific > > problem. In general, no matter what deployment environment, your > environment > > must be set to allow unicode to be passed to file functions, if you want > to > > be able to manipulate files that contain non-ASCII characters. > > > > Also, you should really update to a 1.2 release level. Why are you > running > > alpha? > > > > Karen > > --http://tracey.org/kmt/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I experience problem with special chars like æ øå in filename when using models.ImageField. and models.Fi leField
reload(sys) etc you can put it in start of your settings.py it will reload python utf-8 support so you will able to use different i had such problem executing spain/portugal project import os, sys reload(sys) sys.setdefaultencoding( "utf-8" ) On Mon, Jun 14, 2010 at 1:24 AM, Alexander Jeliuc wrote: > It also depends on your filesystem i think > > > On Mon, Jun 14, 2010 at 1:18 AM, MichaleHjulskov wrote: > >> Hi Karen, I did not know there was a new release, sorry. >> >> So if I just install the new release, it will solve the problem just >> like that? >> Or do I still need to do something, in order to make it work with >> special chars in the filenames? >> >> Thanks :o) >> >> Michael >> >> >> >> On 13 Jun., 01:47, Karen Tracey wrote: >> > On Sat, Jun 12, 2010 at 8:37 AM, MIL wrote: >> > > I experience problem with special chars like æøå in filename when >> > > using models.ImageField. >> > >> > > What am I doing wrong? >> > >> > > models.py >> > > picture = models.ImageField(upload_to='pics', blank=True, >> > > verbose_name='Picture of you') >> > >> > > Using model forms >> > >> > > Let say I want to upload picture named "æøå.jpg" >> > >> > > If I do that, I get the following error msg: >> > > 'ascii' codec can't encode characters in position 59-61: ordinal not >> > > in range(128) >> > >> > > Django ver 1.2 Alpha >> > >> > The full traceback instead of just the error message would help people >> help >> > you. Perhaps try this: >> http://docs.djangoproject.com/en/1.2/howto/deployment/modpython/#if-y >> > Though that is in with the mod_python doc, it is not a mod_python >> specific >> > problem. In general, no matter what deployment environment, your >> environment >> > must be set to allow unicode to be passed to file functions, if you want >> to >> > be able to manipulate files that contain non-ASCII characters. >> > >> > Also, you should really update to a 1.2 release level. Why are you >> running >> > alpha? >> > >> > Karen >> > --http://tracey.org/kmt/ >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error when passing arguments to custom __init__ of ModelForm
Read about python version difference in function overloading domain -->ModelForm.__init__(self, *args, **kwargs) # this can be different On Mon, Jun 14, 2010 at 2:06 AM, Jani Rahkola wrote: > Hei, > > I hope someone could shed some light on this one. > I have these in their appropriate files: > > class ShoppinglistForm(ModelForm): > >def __init__(self, user=False, *args, **kwargs): >ModelForm.__init__(self, *args, **kwargs) >self.fields['pantry'].empty_label = None >if user: >self.fields['pantry'].queryset = > Product.objects.filter(owner=user) > >class Meta: >model = Shoppinglist > > def new(request): >if request.method == 'POST': >form = ShoppinglistForm(request.POST) >if form.is_valid(): >try: >list = Shoppinglist(name=form.cleaned_data['name'], > > pantry=form.cleaned_data['pantry']) >list.save() >return redirect('blackem.users.views.home') >except ObjectDoesNotExist: >return redirect('blackem.users.views.home') >else: >form = ShoppinglistForm(user = request.user) >return render_to_response('shoppinglists/shoppinglist_form.html', > {'form': form, > 'logged': True}, > > context_instance=RequestContext(request)) > > After pressing Submit on the form, I get this: > > Traceback: > File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" > in get_response > 100. response = callback(request, > *callback_args, **callback_kwargs) > File "/usr/lib/python2.6/site-packages/django/contrib/auth/ > decorators.py" in _wrapped_view > 25. return view_func(request, *args, **kwargs) > File "/home/jani/projects/blackem/shoppinglists/views.py" in new > 20. form = ShoppinglistForm(request.POST) > File "/home/jani/projects/blackem/shoppinglists/models.py" in __init__ > 18. self.fields['pantry'].queryset = > Pantry.objects.filter(owner=my_user) > File "/usr/lib/python2.6/site-packages/django/db/models/manager.py" in > filter > 141. return self.get_query_set().filter(*args, **kwargs) > File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in > filter > 550. return self._filter_or_exclude(False, *args, **kwargs) > File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in > _filter_or_exclude > 568. clone.query.add_q(Q(*args, **kwargs)) > File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py" > in add_q > 1131. can_reuse=used_aliases) > File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py" > in add_filter > 1071. connector) > File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py" > in add > 66. value = obj.prepare(lookup_type, value) > File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py" > in prepare > 299. return self.field.get_prep_lookup(lookup_type, > value) > File "/usr/lib/python2.6/site-packages/django/db/models/fields/ > related.py" in get_prep_lookup > 134. return self._pk_trace(value, 'get_prep_lookup', > lookup_type) > File "/usr/lib/python2.6/site-packages/django/db/models/fields/ > related.py" in _pk_trace > 196. v = getattr(field, prep_func)(lookup_type, v, **kwargs) > File "/usr/lib/python2.6/site-packages/django/db/models/fields/ > __init__.py" in get_prep_lookup > 292. return self.get_prep_value(value) > File "/usr/lib/python2.6/site-packages/django/db/models/fields/ > __init__.py" in get_prep_value > 476. return int(value) > > Exception Type: TypeError at /shoppinglists/new > Exception Value: int() argument must be a string or a number, not > 'QueryDict' > > Taking away the 'user' keyword argument makes it work nicely. But I > need to include only the user's pantries in the choices of the select > wiget. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: admin default field widget changing
Thank you. :) On Mon, Jun 14, 2010 at 3:13 PM, stanleyxu2005 wrote: > Take a look at > > ModelAdmin.formfield_overrides > > > > On Jun 14, 1:35 am, Jeliuc Alexandr wrote: > > Hello. > > I want to change default text input widget in admin for CharField to > > text area... > > How can I do it? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Localized admin and date field formats
Thank You, I found a patch for that. My version is already 1.2.1 After pathching fields.py and widgets.py it start working fine On Tue, Jun 15, 2010 at 12:49 AM, D3f0 wrote: > Hi > There's been a slighty change in 1.2, take a look at: > http://docs.djangoproject.com/en/dev/ref/settings/#date-input-formats > > Nahuel > > On 13 jun, 09:00, Jeliuc Alexandr wrote: > > Hello. > > I'm using django1.2.1 with i18n and l10n enabled... > > > > standart django admin date format is mm-dd- > > when it changes to Spain it becomes dd/mm/ > > Not problem it is possible to choice date and save it... > > But if I want to edit row it becomes like standart mm-dd-... > > No problem... but if I edit row and want to save. I got error - wrong > > date format... > > > > Question is: How can I change date field format in admin edit form > > action? to be like it should be dd/mm/? > > Is it bug? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Multi-db: is database routing per request possible?
I didn't work with multidb but I think it is possible anyway... try it using additional middleware... for example.. change dynamically db settings... etc On Tue, Jun 15, 2010 at 2:12 PM, johan de taeye wrote: > Hello, > > In my application a number of databases are configured with identical > schemas. > From a dropdown box on the screen, the user selects the database he/ > she wants to work with. The selected database is stored on the > cookie. > An object with the same primary key can be created in each schema by > the user. > > The above means objects can't be routed to the correct database based > on their primary key. > Only by looking at the request I know what database is required. > > From the documentation (and after digging a bit in the code) I think > the database router concept doesn't support this type of usage. > Is this possible somehow? > Is it feasible to pass the request as a hint to the router somehow? > > All feedback appreciated... > > Johan > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: DateField issues
read about autofill_now=True and autofill=True On Thu, Jun 17, 2010 at 8:14 AM, Sheena wrote: > I've defined a number of models, one of which I've called > MemberProfile that looks like this > > class MemberProfile(models.Model): >postal_addr1=models.CharField(max_length=50, verbose_name="postal > address line 1") >postal_addr2=models.CharField(max_length=50, verbose_name="postal > address line 2") >postal_addr3=models.CharField(max_length=50, verbose_name="postal > address line 3") >postalcode=models.CharField(max_length=4, verbose_name="postal > code") >res_addr1=models.CharField(max_length=50, > verbose_name="residential address line 1") >res_addr2=models.CharField(max_length=50, > verbose_name="residential address line 2") >res_addr3=models.CharField(max_length=50, > verbose_name="residential address line 3") >rescode=models.CharField(max_length=4, verbose_name="residential > postal code") >homeno=models.CharField(max_length=12, verbose_name="home number") >workno=models.CharField(max_length=12, verbose_name="work number") >cellno=models.CharField(max_length=12, unique=True, > verbose_name="cellphone number") >idno=models.CharField(max_length=13, unique=True, verbose_name="id > or passport number") >occu=models.CharField(max_length=15, verbose_name="occupation") >employer=models.CharField(max_length=30) >amount_paid=models.IntegerField(blank=True, null=True, > help_text="total fees paid to date", verbose_name="total reciepts") >reciept_no=models.IntegerField(blank=True, null=True, > help_text="latest reciept number", verbose_name="reciept number") >dob=models.DateField(verbose_name="date of birth") >start_date=models.DateField() >expire_date=models.DateField() >captured_by=models.CharField(max_length=50, help_text="name of > data capturer") >photo=models.ImageField(upload_to="memberphotos", null=True, > blank=True) >permission=models.CharField(max_length=1, > choices=PERMISSION_CHOICES, help_text="Administration level, if the > user is a superuser this field has no effect") >user=models.ForeignKey(User,unique=True,related_name="member", > editable=False) >branch=models.ForeignKey(Branch,related_name="member", null=True) > >def create_member(self,username,email,password): >m=MemberProfile() > > > m.user=User.objects.create_user(username=username,email=email,password=password) >return m > >def __unicode__(self): >return self.user.username > >def save(self,*args,**kwargs): >if not self.start_date: >self.start_date=models.DateField(datetime.date.today()) >year=timedelta(days=365) >self.expire_date=models.DateField(datetime.date.today() > +year) >super(MemberProfile, self).save(self,*args,**kwargs) > > > I then wrote a method called populate just to test the database out > and it is pretty friendly until I get this: > > Traceback (most recent call last): > File "", line 1, in > File "/host/Shared info/MyDBA/MyMembers/populate.py", line 114, in > populate >m1.save() > File "/host/Shared info/MyDBA/MyMembers/../MyMembers/chiefs/ > models.py", line 115, in save >super(MemberProfile, self).save(self,*args,**kwargs) > File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line > 410, in save >self.save_base(force_insert=force_insert, > force_update=force_update) > File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line > 483, in save_base >values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) > or f.pre_save(self, True))) for f in meta.local_fields if not > isinstance(f, AutoField)] > File "/usr/lib/pymodules/python2.6/django/db/models/fields/ > __init__.py", line 192, in get_db_prep_save >return self.get_db_prep_value(value) > File "/usr/lib/pymodules/python2.6/django/db/models/fields/ > __init__.py", line 511, in get_db_prep_value >return connection.ops.value_to_db_date(self.to_python(value)) > File "/usr/lib/pymodules/python2.6/django/db/models/fields/ > __init__.py", line 472, in to_python >if not ansi_date_re.search(value): > TypeError: expected string or buffer > > m1 is an instance of MemberProfile... > > The error goes away if I comment out everything to do with > DateField... > Am I doing something retarded? As far as I can see I'm populating the > fields the right way... > > Any help would be greatly appreciated > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscr
Re: DateField issues
Your error is this... def save(self,*args,**kwargs): if not self.start_date: self.start_date=models.DateField(datetime.date.today()) year=timedelta(days=365) self.expire_date=models.DateField(datetime.date.today() +year) On Thu, Jun 17, 2010 at 8:40 AM, Sheena wrote: > Thanks > > The question is how do I populate a field with some other date, for > example, there's a date of birth field that the auto stuff wont be > ideal for... > In the populate method i mentioned before, i passed the dob(date of > birth) field a Date object initialized to something arbitrary. Does > the DateField not get along with standard date objects? What format > should stuff be in for populating DateFields? > > On Jun 17, 7:24 am, Alexander Jeliuc wrote: > > read about autofill_now=True and autofill=True > > > > On Thu, Jun 17, 2010 at 8:14 AM, Sheena > wrote: > > > I've defined a number of models, one of which I've called > > > MemberProfile that looks like this > > > > > class MemberProfile(models.Model): > > >postal_addr1=models.CharField(max_length=50, verbose_name="postal > > > address line 1") > > >postal_addr2=models.CharField(max_length=50, verbose_name="postal > > > address line 2") > > >postal_addr3=models.CharField(max_length=50, verbose_name="postal > > > address line 3") > > >postalcode=models.CharField(max_length=4, verbose_name="postal > > > code") > > >res_addr1=models.CharField(max_length=50, > > > verbose_name="residential address line 1") > > >res_addr2=models.CharField(max_length=50, > > > verbose_name="residential address line 2") > > >res_addr3=models.CharField(max_length=50, > > > verbose_name="residential address line 3") > > >rescode=models.CharField(max_length=4, verbose_name="residential > > > postal code") > > >homeno=models.CharField(max_length=12, verbose_name="home number") > > >workno=models.CharField(max_length=12, verbose_name="work number") > > >cellno=models.CharField(max_length=12, unique=True, > > > verbose_name="cellphone number") > > >idno=models.CharField(max_length=13, unique=True, verbose_name="id > > > or passport number") > > >occu=models.CharField(max_length=15, verbose_name="occupation") > > >employer=models.CharField(max_length=30) > > >amount_paid=models.IntegerField(blank=True, null=True, > > > help_text="total fees paid to date", verbose_name="total reciepts") > > >reciept_no=models.IntegerField(blank=True, null=True, > > > help_text="latest reciept number", verbose_name="reciept number") > > >dob=models.DateField(verbose_name="date of birth") > > >start_date=models.DateField() > > >expire_date=models.DateField() > > >captured_by=models.CharField(max_length=50, help_text="name of > > > data capturer") > > >photo=models.ImageField(upload_to="memberphotos", null=True, > > > blank=True) > > >permission=models.CharField(max_length=1, > > > choices=PERMISSION_CHOICES, help_text="Administration level, if the > > > user is a superuser this field has no effect") > > >user=models.ForeignKey(User,unique=True,related_name="member", > > > editable=False) > > >branch=models.ForeignKey(Branch,related_name="member", null=True) > > > > >def create_member(self,username,email,password): > > >m=MemberProfile() > > > > > > m.user=User.objects.create_user(username=username,email=email,password=password) > > >return m > > > > >def __unicode__(self): > > >return self.user.username > > > > >def save(self,*args,**kwargs): > > >if not self.start_date: > > >self.start_date=models.DateField(datetime.date.today()) > > >year=timedelta(days=365) > > >self.expire_date=models.DateField(datetime.date.today() > > > +year) > > >super(MemberProfile, self).save(self,*args,**kwargs) > > > > > I then wrote a method called populate just to test the database out > > > and it is pretty friendly until I get this: > > > > > Traceback (most recent call last): > > > File "", line 1, in > > > File &quo
Re: DateField issues
Here is DateField class I think You will find all You need here class DateField(Field): description = _("Date (without time)") empty_strings_allowed = False default_error_messages = { 'invalid': _('Enter a valid date in -MM-DD format.'), 'invalid_date': _('Invalid date: %s'), } def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add #HACKs : auto_now_add/auto_now should be done as a default or a pre_save. if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True Field.__init__(self, verbose_name, name, **kwargs) def get_internal_type(self): return "DateField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): return value.date() if isinstance(value, datetime.date): return value if not ansi_date_re.search(value): raise exceptions.ValidationError(self.error_messages['invalid']) # Now that we have the date string in -MM-DD format, check to make # sure it's a valid date. # We could use time.strptime here and catch errors, but datetime.date # produces much friendlier error messages. year, month, day = map(int, value.split('-')) try: return datetime.date(year, month, day) except ValueError, e: msg = self.error_messages['invalid_date'] % _(str(e)) raise exceptions.ValidationError(msg) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.datetime.now() setattr(model_instance, self.attname, value) return value else: return super(DateField, self).pre_save(model_instance, add) def contribute_to_class(self, cls, name): super(DateField,self).contribute_to_class(cls, name) if not self.null: setattr(cls, 'get_next_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=True)) setattr(cls, 'get_previous_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=False)) def get_prep_lookup(self, lookup_type, value): # For "__month", "__day", and "__week_day" lookups, convert the value # to an int so the database backend always sees a consistent type. if lookup_type in ('month', 'day', 'week_day'): return int(value) return super(DateField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts dates into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.value_to_db_date(value) def value_to_string(self, obj): val = self._get_val_from_obj(obj) if val is None: data = '' else: data = datetime_safe.new_date(val).strftime("%Y-%m-%d") return data def formfield(self, **kwargs): defaults = {'form_class': forms.DateField} defaults.update(kwargs) return super(DateField, self).formfield(**defaults) On Thu, Jun 17, 2010 at 8:47 AM, Alexander Jeliuc wrote: > Your error is this... > def save(self,*args,**kwargs): >if not self.start_date: >self.start_date=models.DateField(datetime.date.today()) >year=timedelta(days=365) >self.expire_date=models.DateField(datetime.date.today() > +year) > > > > On Thu, Jun 17, 2010 at 8:40 AM, Sheena wrote: > >> Thanks >> >> The question is how do I populate a field with some other date, for >> example, there's a date of birth field that the auto stuff wont be >> ideal for... >> In the populate method i mentioned before, i passed the dob(date of >> birth) field a Date object initialized to something arbitrary. Does >> the DateField not get along with standard date objects? What format >> should stuff be in for populating DateFields? >> >> On Jun 17, 7:24 am, Alexander Jeliuc wrote: >> > read about autofill_now=True and autofill=True >> > >> > On Thu, Jun 17, 2010 at 8:14 AM, Sheena >> wrote: >> > > I've defined a number of models, one of which I've called >> > > MemberProfile that looks like thi
Re: Should I start to use Mako from beginning?
Default template engine is very nice... and more than enough. On Thu, Jul 1, 2010 at 8:22 AM, Kenneth Gonsalves wrote: > On Wednesday 30 June 2010 21:04:25 AllenDang wrote: > > I'm new to django, it's amazing! But after I did some research from > > google, I found out that some people say that the default template > > engine of django is not that good to use, they recommend Mako as a > > replacement. > > it is not wise to listen to people - the default template engine is great > in > django and most people use it - however there is no harm in using the > engine > of your choice > > > > So I'm wondering if I should start learning and using Mako from > > beginning? > > > > Frankly, it's hard for me to judge. In one hand, I think it's better > > to use the default components to understand the design philosophy > > behind. In another hand, I also think to use a commonly recommended > > replacement may lead me to a straight forward way to archive the goal. > > > > And the same concern also happened for the data model component. > > Should I use SQLAchemy from beginning? > > > > again the django ORM is used by most people - but again it is your choice. > > -- > Regards > Kenneth Gonsalves > Senior Associate > NRC-FOSS at AU-KBC > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Paid support for Django?
Try djangopeople On Fri, Jul 9, 2010 at 6:00 PM, Derek wrote: > Not sure if this is the right place to ask, but... how do I go about > finding Django developers that offer support for development of Django > apps. i.e. not do the development themselves, but be available to > provide answers to key questions (the ones that typically are not > answered on this mailing list), provide suggestions, code reviews and > so on. (I assume that such support would be paid for, of course.) > > Thanks > Derek > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Dajax or Jquery
Hello. Django community use jquery in contrib/admin - motives - it is fast growing js framework. I personally use both dojo, jquery and YUI. jQuery is best for general uses but sometimes is slower then dojo and YUI. Finally it depends on you and your needs. dajax is good choice. On Mon, Jul 12, 2010 at 1:36 PM, Imad Elharoussi wrote: > Hi, > > I want to know what's the best plugin of Ajax to use with django Dajax or > Jquery (for someone who just began in developping with such technologies) > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Anyone want to take over maintaining Instant Django?
It is your child. :( On Tue, Jul 13, 2010 at 5:37 PM, cjl wrote: > Djangoholics: > > I no longer have the time or interest to maintain my little project: > > http://www.instantdjango.com > > If anyone would like to take over the project, I would gladly give it > away. Right now it costs a few dollars in shared hosting a month, and > a few more dollars for the downloads I host with AWS. If you take over > the project I will give you the domain, but I'm not going to pay the > hosting. > > I'll also give you my 'build' script, but it no longer works correctly > because the Python core devs broke the Windows installer, and mocked > me when I reported the bug. > > The project website gets a hundred or so hits a day, and several > thousand downloads a month. It also ranks highly for a few different > google searches related to Django. > > Let me know if you have any interest. It wouldn't take much effort to > maintain, I just can't do it anymore. > > -cjl > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django GeoIP
Yes. there are dependencies. On Sat, Jul 17, 2010 at 8:58 AM, haibin wrote: > hi, > > I am trying to use GeoIP part of GeoDjango. I importing it by from > django.contrib.gis.utils import GeoIP but getting import error. Do I > have to install someting or do the whole installation process for > GeoDjango? Or what is the minimum requirements just for GeoIP > > 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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I live in Ukraine. For me it is better to pick up European or US host?
intoVPS.com eu and us location On Thu, Jul 29, 2010 at 2:51 PM, KLRUMPF wrote: > Kostya, maybe have a look at www.ovh.fr, the language tabs are at the > bottom. Lots of *ux flavours, too. > > Been using them for years, cheap and competent, but I don't know how much > they know about django. > > Karl L. Rumpf > málagaklru...@gmail.com > > > El 29/07/2010 13:05, django-users+nore...@googlegroups.com escribió: > > kostia Jul 29 > 01:16AM -0700 ^ > > Currently looking at. So many choices! > I'm a person with not enough money. > > What do you think about Canadian https://servqc.net/ one? It is very > cheap from the list. > > I live in Ukraine. For me it is better to pick up European or US host? > > Kostia > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.3
It is django-users group. Isn't it? On Sun, Aug 1, 2010 at 5:35 PM, mayikmaster wrote: > hello and thank you for this great project which I have learned so > much. I would like to know what will happen with djanggo 1.3 Where > we've heard.many thanks > > > --- > hola y gracias por este gran proyecto del cual he aprendido tanto. me > gustaria saber que va pasar con djanggo 1.3 cuando tendremos noticias > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django IDE
gvim, emacs, eclipse, eric On Wed, Aug 4, 2010 at 6:50 AM, Nick Arnett wrote: > > > On Sun, Jul 18, 2010 at 10:19 AM, Biju Varghese wrote: > >> Eclipse is the best IDE for python and django. >> >> > I don't know if it is actually the best, but I'm happy with it. > > Nick > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Translation
you should include {% load i18n %} tag in every file you use translation On Tue, Aug 10, 2010 at 8:13 PM, kostia wrote: > My base.html has a header: > > {% load i18n %} > > {% get_current_language as LANGUAGE_CODE %} > > > > www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > http://www.w3.org/1999/xhtml"; lang="{{ LANGUAGE_CODE }}" > xml:lang="{{ LANGUAGE_CODE }}"> > > > > /> > > > >... > > > > The LANGUAGE_CODE in settings is: > > LANGUAGE_CODE = 'ru' > > > > #multilingual > > LANGUAGES = ( > >('en', 'English'), > >('ru', 'Russian'), > >('uk', 'Ukrainian'), > > ) > > > > Why after reloading the web server and browser (before cleaning from > history and cookies) I see the English web site and not a Russian one? > > I have already created language files and translated with rosetta. > > Why I'm so idiot? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.