Re: Dynamic model field

2008-12-27 Thread sergioh

Maybe a better approach for this, can be override the save method for
your model and also exclude that field on your forms.

Actually there is a post from James Bennett at:
http://www.b-list.org/weblog/2008/dec/24/admin/

hope it helps,

regards,

Sergio Hinojosa

On Dec 26, 6:32 pm, eldonp2  wrote:
> I'm writing a library app - would like to find out if it is possible
> to have a dynamically updating (returndate) field in a model?
>
> class Loan...
> ...
>   borrowdate = models.DateTimeField(auto_now_add = True)
>   returndate = models.DateTimeField(timediff(borrowdate+ timedelta
> (days=2))
> ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to set defaults['empty_permitted'] = False in a BaseFormSet

2008-12-23 Thread sergioh

Hi,

I would like to find a straightforward way to get the defaults
['empty_permitted'] = False in a BaseFormSet to True, which means that
all forms in a formset should be not empty by default.

Thanks in advance,

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



Re: Customizing ModelForm fields appearance

2008-12-23 Thread sergioh

You can always add your own custom fields, by default they override
the default fields that becomes with the modelform, and there is an
optional parameter "attributes", which is used to add css class to
your fields.

On Dec 23, 9:47 am, sagi s  wrote:
> I really like the concept of generating a form from a model using
> ModelForm but would like to customize the apprearance slightly (e.g.
> size of the TextInput etc.).
>
> Any suggestion as to how to do this?
>
> I looked at the forms module code but got lost in the maze of the meta
> programming...
>
> Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Local flavor and admin (zip-code)

2008-12-02 Thread sergioh



On Dec 1, 11:14 am, Fabio Natali <[EMAIL PROTECTED]> wrote:
> Hi everybody!
>
> I'm having difficulties while trying to insert a zip-code field in one
> of my models. I'd like to rely upon some italian local flavor stuff,
> so to get some validation for free.
>
> Here comes my models.py:
>
> from django.contrib.localflavor.it import forms
>
> class DittaDipendenti(models.Model):
>     nome = models.CharField(max_length=30)
>     cap = models.IntegerField("Cap",max_length=5)
>
> class DittaDipendentiAdmin(admin.ModelAdmin):
>     def formfield_for_dbfield(self, db_field, **kwargs):
>         if db_field.name == "cap":
>             return forms.ITZipCodeField(**kwargs)
>         else:
>             return super(DittaDipendentiAdmin, 
> self).formfield_for_dbfield(db_field, **kwargs)

from django.contrib.localflavor.it.forms import ITZipCodeField
from django import forms
from django.utils.translation import ugettext_lazy as _

class DittaDipendentiAdmin(admin.ModelAdmin):
 cap = ITZipCodeField(_('ZIP Code'))

 class Meta:
model= DittaDipendenti

Just overriding the form field using the ITZipCodeField, works fine.

hope this works for you,


Regards,

Sergio
>
> I get this error:
>
> Request URL:    http://localhost:8000/admin/anagrafiche/dittadipendenti/add/
> Exception Type:         AttributeError
> Exception Value:        'module' object has no attribute 'ITZipCodeField'
>
> Anyone who can kindly shed a bit of light on this? Or give me some
> tips on the best way to get some zip-code field inside my model? I'll
> provided more log/context if needed.
>
> Bye and thanks, Fabio.
>
> --
> Fabio Natali
--~--~-~--~~~---~--~~
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: Admin - Auto Generate user_id on save

2008-11-30 Thread sergioh

On Nov 29, 8:26 pm, AJ <[EMAIL PROTECTED]> wrote:
> James,
>
> Thanks for the reply, I can't tell you how many times I read over that
> page in the documentation today, and didn't catch that.  I think when
> this problem arose I looked over the ModelForm docs and couldn't find
> a solution.  Thanks again for your assistance!
>
> On Nov 29, 6:38 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > On Sat, Nov 29, 2008 at 5:25 PM, AJ <[EMAIL PROTECTED]> wrote:
> > > to the vairables self and commit.  So as far as I can tell I can't do
> > > this in the Admin.  It looks like I would need to write my own custom
> > > form and view.  Is this correct, or is there another way to do this?
>
> > Consult the documentation for the admin; there are methods on
> > ModelAdmin you can override to customize and control what happens
> > during object saving.

Override your method and receive as a parameter the request object, so
through the request object you can get access to the user logged in.

>
> > And in general, please consider doing some searching when you
> > encounter something you don't quite know how to do; this is, for
> > example, one of the most-frequently-asked questions about the admin,
> > and the techniques for solving it have been covered repeatedly on this
> > list and elsewhere.
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overriding contrib.auth User save()

2008-11-28 Thread sergioh

I did not notice you were trying to override in a wrong way, sorry
about that.

Actually for override the user model you need to:

class CustomUser(User):
   #your new fields, DRY user fields
  objects = MyCustomManager()

class MyCustomManager(models.Manager):
def create_mycustom_user(.):
   self.create(...#user fields and your new custom
fields#)
   self.set_password('222')
   self.save()

On Nov 28, 9:39 am, sergioh <[EMAIL PROTECTED]> wrote:
> On Nov 28, 8:02 am, bruno desthuilliers
>
> <[EMAIL PROTECTED]> wrote:
> > On 28 nov, 09:45, Paddy Joy <[EMAIL PROTECTED]> wrote:
>
> > > Thanks however I'm guessing:
>
> > > > admin.site.unregister(User)
> > > > admin.site.register(User, NewModelForm)
>
> > > will only work in the admin site?
>
> > Yes.
>
> Actually as is a Form you are able to use it not just in the admin
> section, you could override the fields or add as many fields as you
> want, but you will need to define the validation methods for those new
> fields and also the save method, you could use it in any view and pass
> it to a template for rendering.
>
> An actually monkey patch may cause you problems for future versions,
> and if you are planing to have many applications sharing your django,
> it will cause you problems. I think it you could find a better
> solution, just keep going.
>
> Kind Regards,
>
> Sergio Hinojosa
>
>
>
> > > Not actually using the admin site at
> > > the moment but would nice to have something that would work globally.
>
> > > I nearly have the monkey patch working however I'm getting the
> > > following error, any idea?
>
> > > >>> from django.contrib.auth.models import UserManager
> > > >>> a=UserManager()
> > > >>> a.create_user(username='sdf', email='[EMAIL PROTECTED]', 
> > > >>> password='222')
>
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > >   File "/var/django/mysite/../mysite/hosting/models.py", line 166, in
> > > my_create_user
> > >     return _create_user(self, username, email, password)
> > >   File "/usr/lib/python2.5/site-packages/django/contrib/auth/
> > > models.py", line 100, in create_user
> > >     user = self.model(None, username, '', '', email.strip().lower(),
> > > 'placeholder', False, True, False, now, now)
> > > TypeError: 'NoneType' object is not callable
>
> > Your UserManager instance is not connected to any model, so it's model
> > attribute is None. Manager classes are meant to be used thru model
> > classes, not directly.
>
> > IOW, you want:
>
> > from django.contrib.auth.models import User
> > user = User.objects.create_user(username='sdf', email='[EMAIL PROTECTED]',
> > password='222')
>
> > HTH
--~--~-~--~~~---~--~~
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: Form Widget Attributes

2008-11-28 Thread sergioh

Probably you will need to create your custom widget and override the
method:

 def id_for_label(self, id_):
# See the comment for RadioSelect.id_for_label()
if id_:
id_ += '_0'
return id_
id_for_label = classmethod(id_for_label)

at the checkboxmultiple widget.

hope this helps,


Kind Regards,

Sergio Hinojosa

On Nov 28, 9:44 am, Alfonso <[EMAIL PROTECTED]> wrote:
> I'd like to specify a unique id for each checkbox iteration in a
> CheckboxSelectMultiple setup.  This is what I have so far:
>
> grading = forms.BooleanField(label="Site Grading",
> widget=forms.CheckboxSelectMultiple(choices=grading_choices))
>
> So in my form using the tag {{ form.grading }} gives me:
>
> 
>  value="1" id="id_grading_0" /> 1 star
>
>  value="2" id="id_grading_1" /> 2 stars
>  value="3" id="id_grading_2" /> 3 stars
>  value="4" id="id_grading_3" /> 4 stars
>  value="5" id="id_grading_4" /> 5 stars
> 
>
> So is there any way I can apply a corresponding css id to the label?
> like id_grading_1_label?
>
> Its so I can add a background graphic or bullet, I can't apply a
> background graphic to an input - only the label (as far as I know).
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: sql used in the save method

2008-11-28 Thread sergioh

There is

On Nov 28, 8:05 am, Robert <[EMAIL PROTECTED]> wrote:
> Hello !!
>
> I am using mysql as the backend and trying to use insert delayed of a
> query (http://dev.mysql.com/doc/refman/5.0/en/insert-delayed.html), to
> do this I have to change a bit the insert statement, and I want to
> know if is possible to know before executing the sql what is the sql
> INSERT statement that we are going to execute.

Maybe using the connection can help you:

from django.db import connection

# do your queries

connection.queries  # will display the queries you have executed

>
> or any way to add this "DELAYED" keyword in an insert statement.
>
> thanks in advance, r
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Overriding contrib.auth User save()

2008-11-28 Thread sergioh



On Nov 28, 8:02 am, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 28 nov, 09:45, Paddy Joy <[EMAIL PROTECTED]> wrote:
>
> > Thanks however I'm guessing:
>
> > > admin.site.unregister(User)
> > > admin.site.register(User, NewModelForm)
>
> > will only work in the admin site?
>
> Yes.

Actually as is a Form you are able to use it not just in the admin
section, you could override the fields or add as many fields as you
want, but you will need to define the validation methods for those new
fields and also the save method, you could use it in any view and pass
it to a template for rendering.

An actually monkey patch may cause you problems for future versions,
and if you are planing to have many applications sharing your django,
it will cause you problems. I think it you could find a better
solution, just keep going.

Kind Regards,

Sergio Hinojosa
>
>
>
> > Not actually using the admin site at
> > the moment but would nice to have something that would work globally.
>
> > I nearly have the monkey patch working however I'm getting the
> > following error, any idea?
>
> > >>> from django.contrib.auth.models import UserManager
> > >>> a=UserManager()
> > >>> a.create_user(username='sdf', email='[EMAIL PROTECTED]', password='222')
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/var/django/mysite/../mysite/hosting/models.py", line 166, in
> > my_create_user
> >     return _create_user(self, username, email, password)
> >   File "/usr/lib/python2.5/site-packages/django/contrib/auth/
> > models.py", line 100, in create_user
> >     user = self.model(None, username, '', '', email.strip().lower(),
> > 'placeholder', False, True, False, now, now)
> > TypeError: 'NoneType' object is not callable
>
> Your UserManager instance is not connected to any model, so it's model
> attribute is None. Manager classes are meant to be used thru model
> classes, not directly.
>
> IOW, you want:
>
> from django.contrib.auth.models import User
> user = User.objects.create_user(username='sdf', email='[EMAIL PROTECTED]',
> password='222')
>
> HTH
--~--~-~--~~~---~--~~
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 organizing inline fields in User

2008-11-28 Thread sergioh

You could use field sets to get your information organized:

fieldsets = (
('Account Information', { 'fields':('company_name', 'username',
'password', 'email', 'is_active')}),
('Company Information',{'fields': ('physical_address',
'city', 'state', 'zip_code', 'telephone', 'fax', 'type_of_business',
'years_in_business')}),
('Billing Information',{'fields': ('billing_address',
'billing_city', 'billing_state', 'billing_zip_code')}),
)

Regards,

Sergio Hinojosa

mondonauta wrote:
> hello everybody,
> i've already created a custom user profile
> and added it to the User by
> foreignkey, AUTH_PROFILE_MODULE
> and i have been able to add the custom profile
> to the admin page by coding in admin.py this:
>
> ___
> from django.contrib import admin
> from django.contrib.auth.models import User
> from django.contrib.auth.admin import UserAdmin
>
> from django.utils.translation import ugettext_lazy as _
>
> from ProfSystem.users.models import Professor
>
> admin.site.unregister(User)
>
> # Set it up so we can edit a user's professor profile inline in the
> admin
> class ProfessorInline(admin.StackedInline):
>model = Professor
>
> class ProfessorAdmin(UserAdmin):
>inlines = [ProfessorInline]
>
> # re-register the User with the extended admin options
> admin.site.register(User, ProfessorAdmin)
> _
>
> now my problem is that in this way the new fields
> r in a new frameset at the bottom of the admin page!
> while what i would like to do is adding the new fields
> to the "Personal info" frameset.
> is there any way to obtain this?
>
> thanks for any one who is going to help me :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm question

2008-11-27 Thread sergioh



On Nov 26, 4:25 pm, fiedzia <[EMAIL PROTECTED]> wrote:
> Hi
>
> I am trying to achieve the following effect:
>
> A ModelForm containing list of choices and input to possibly add
> another
> element to the list is presented on page.
> If user will not choose any item from list and will type something
> into
> new_item field, then:
>  - if new_item is present on the list, ValidationError should be
> raised and
> user should choose item from list instead of creating new one, but i
> also
> want to make this item selected on the list (problem 1)
>   - if new_item is not on the list, then i want to add it to the list
> and
> set as model instance property (problem 2)
>
> problem 1: i don't know how to modify modelform during or before/after
> validation.
> problem 2: basically the same
> and there is also problem 3: i want access request.user during
> validation.
> Is it possible?

what you could do, is pass as a parameter to your _init_ method in
your form as:

>
> Thanks for help
>
> my model:
>
> class Song(models.Model):
>     """
>         Song
>     """
>     title = models.CharField(max_length = 500, blank = False)
>     user = models.ForeignKey(User)
>     author = models.ForeignKey(Author)
>     category = models.ForeignKey(Category)
>     content = models.TextField(blank = True)
>     format = models.CharField(max_length = 50, choices = SONG_FORMATS)
>     creationdate = models.DateTimeField(auto_now_add = True)
>
> my form:
>
> class SongEditForm(ModelForm):
>     class Meta:
>         model = songs_models.Song
>         exclude = ('user')
>     new_author = forms.CharField(max_length=100,  required = False )
>     new_category = forms.CharField(max_length=100,  required = False )
>
here you can pass an extra arg, your user, so this can be added from
the view

     def __init__(self, user, *args,  **kwargs):
>         super(SongEditForm, self).__init__( *args,  **kwargs)
>         self.fields['author'].required = False
>         self.fields['category'].required = False

but you could use the ModelAdmin save method, wich has as a argument
the request object

class ArticleAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):


>
>     def clean(self):
>         #FIXME: check user validation
>         cleaned_data = self.cleaned_data
>         if not cleaned_data['author'] and not cleaned_data
> ['new_author']:
>             raise forms.ValidationError('Fill either author or new
> author')
>         if not cleaned_data['author'] and cleaned_data['new_author']:
>             authors = songs_models.Author.objects.filter(name =
> cleaned_data['new_author'])
>             if len(authors) > 0:
>                 #TODO: select existing author
>                 #self.data.author = authors[0] #doesn't work
>                 #self.data.new_author = u'test' #doesn't work
>                 raise forms.ValidationError('author with that name
> already
> exists, so choose him/her instead of creating new one')
>             else: #create author
>                 #self.author = songs_models.Author()
>                 #self.author.name = cleaned_data['new_author']
>                 pass
>         return cleaned_data

For all of this behavior, i think you could probably check at the
Admin Forms implementation
you have the choice list and also you could add a new instance.

> --
> Maciej Dziardziel

Hope this help :)

Best Regards,

Sergio Hinojosa
--~--~-~--~~~---~--~~
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: Overriding contrib.auth User save()

2008-11-27 Thread sergioh

Maybe you could override the save method in a New User Model Form:

save_model(self, request, obj, form, change)

So you can:

admin.site.unregister(User)
admin.site.register(User, NewModelForm)

http://docs.djangoproject.com/en/dev/ref/contrib/admin/

I hope this could help you!

And finally the other way i usually use is extend a new Client Model
from User, so i have a plenty access to the User Model
and also from the request i get it through request.user.client and i
override the save method for it.

Regards,

Sergio Hinojosa

On Nov 27, 12:59 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 27 nov, 17:11, Paddy Joy <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the tips, signals would work except I need access to the
> > raw password when users are created.
>
> > On further inspection it seems I would need to override the
> > UserManager,
>
> On even further inspection, you may in fact want to override
> User.set_password !-)
>
> > I know I can extend it with more methods but I don't
> > think I can override it.
>
> As Alex said, you can always - I mean, as a _last_ resort -
> monkeypatch it:
>
> # mymodel.py
> from auth.models import UserManager
> _create_user = UserManager.create_user
> def my_create_user(self, username, email, password=None):
>     # do whatever here
>     # and eventually remember to call the original method
>     return _create_user(self, username, email, password)
>
> UserManager.create_user = my_create_user
>
> # et voilà.
>
> > Paddy
>
> > On Nov 27, 12:39 am, sergioh <[EMAIL PROTECTED]> wrote:
>
> > > Signals are the better way to achieve. You usually override the save
> > > method when you need to define something related with the model
> > > itself, but in many cases signals are the better way to notify some
> > > function to do something if a model change (after save)
>
> > > def your_function(sender, instance, created=False, **kwargs):
> > >       # your tasks
>
> > > models.signals.post_save.connect(your_function, sender=User)  #this
> > > relate your User model with the signal
>
> > > regards,
>
> > > Sergio Hinojosa
>
> > > On Nov 26, 7:01 am, "Alex Koshelev" <[EMAIL PROTECTED]> wrote:
>
> > > > Of course you can monkey-patch the User model but the better way is to 
> > > > use
> > > > signals pre_ or post_save
>
> > > > On Wed, Nov 26, 2008 at 13:54, Paddy Joy <[EMAIL PROTECTED]> wrote:
>
> > > > > I would like to override the save() method on the contrib.auth User
> > > > > model so that I can run a routine when a user is created/modified.
>
> > > > > Is this possible or do I need to use a signal? I have tried overriding
> > > > > the User model like this but it never seems to call my code:
>
> > > > > from django.contrib.auth.models import User
>
> > > > > # Override User model
> > > > > class User(models.Model):
>
> > > > >        def save(self):
>
> > > > >                # Do something here
> > > > >                myroutine()
> > > > >                super(User, self).save()
>
> > > > > Can anyone help?
>
> > > > > Paddy
--~--~-~--~~~---~--~~
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: Sending automatic emails

2008-11-27 Thread sergioh


On Nov 27, 9:28 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On Friday 28 November 2008 06:46:57 am izzy wrote:
>
> > I'm just curious if its possible in django to send automatic emails
> > based on the data in the database?
>
> what do you mean by 'automatic emails"? Do you mean emails at some fixed time,
> or emails based on changes in the database? In the first case do not use
> django, use cron, and in the second case use signals.

http://docs.djangoproject.com/en/dev/ref/signals/

you can use post_save on models and send emails

http://docs.djangoproject.com/en/dev/topics/email/

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



Re: Overriding contrib.auth User save()

2008-11-26 Thread sergioh

Signals are the better way to achieve. You usually override the save
method when you need to define something related with the model
itself, but in many cases signals are the better way to notify some
function to do something if a model change (after save)

def your_function(sender, instance, created=False, **kwargs):
  # your tasks

models.signals.post_save.connect(your_function, sender=User)  #this
relate your User model with the signal


regards,

Sergio Hinojosa

On Nov 26, 7:01 am, "Alex Koshelev" <[EMAIL PROTECTED]> wrote:
> Of course you can monkey-patch the User model but the better way is to use
> signals pre_ or post_save
>
> On Wed, Nov 26, 2008 at 13:54, Paddy Joy <[EMAIL PROTECTED]> wrote:
>
> > I would like to override the save() method on the contrib.auth User
> > model so that I can run a routine when a user is created/modified.
>
> > Is this possible or do I need to use a signal? I have tried overriding
> > the User model like this but it never seems to call my code:
>
> > from django.contrib.auth.models import User
>
> > # Override User model
> > class User(models.Model):
>
> >        def save(self):
>
> >                # Do something here
> >                myroutine()
> >                super(User, self).save()
>
> > Can anyone help?
>
> > Paddy
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist

2008-11-13 Thread sergioh


 are you using fastcgi? it could be an error on your syspath?


On Nov 13, 3:57 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-11-12 at 23:05 -0800, [EMAIL PROTECTED] wrote:
> > Sorry about the inconsistency but just to be clear, here is what I
> > have:
>
> > Dreamhost directory structure:
>
> > TEMPLATE_DIRS = (
> >     # Put strings here, like "/home/html/django_templates" or "C:/www/
> > django/templates".
> >     # Always use forward slashes, even on Windows.
> >     # Don't forget to use absolute paths, not relative paths.
> >    '/home/USERNAME/projects/django_templates/SITENAME/polls',
>
> Which is nothing like what you posted originally. So I'll wager this
> isn't what you have on Dreamhost at all, but an approximation, which
> introduces yet more errors (for example, the use of "USERNAME" and
> "SITENAME" -- they really aren't helping). Construct a realistic local
> example that fails in the same way where you can cut-and-paste the
> precise string without changing anything so that further errors aren't
> introduced and this might go faster.
>
>
>
> > within this directory:
> > - index.html
> > - base.html
>
> > local directory structure:
>
> > TEMPLATE_DIRS = (
> >     # Put strings here, like "/home/html/django_templates" or "C:/www/
> > django/templates".
> >     # Always use forward slashes, even on Windows.
> >     # Don't forget to use absolute paths, not relative paths.
> >         '/home/USERNAME/django_projects/django_templates/polls',
>
> Since your original view tries to load a template called
> polls/index.html, this implies that inside the django_templates/polls/
> directory you have *another* directory called polls/ containing
> index.html. It sounds like you need to remove the polls/ piece at the
> end here.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 regarding Sqlite3

2008-11-06 Thread sergioh

Also you can use the python shell, you can import your models and
create objects, the you can save them and also make queries to your
model.

is simple as:

# manage.py shell
>>> from django.contrib.auth.models import User
>>>User.objects.all()
..

Also the structure of the tables created you can obtain with the
following command:

manage.py sql [model]

this command will show you the sql used to create your tables.

On Nov 5, 6:46 am, Mattias Jämting <[EMAIL PROTECTED]> wrote:
> I use the sqlite manager extension for firefox. Very good.
>
> http://code.google.com/p/sqlite-manager/
>
> /Mattias
>
> From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED]
> On Behalf Of sadeesh Arumugam
> Sent: den 5 november 2008 11:07
> To: django-users@googlegroups.com
> Subject: Help regarding Sqlite3
>
> Hi Friends,
>   I'm a newbie to Django, in my application i'm uisng Sqlite3 as my
> Database. I've created the models as per my requirement. The database is
> succesfully synchronized. After this how can i view the tables (like select
> statement in Postgres) to check whether my data is successfully inserted
> into the tables.
>
> Any help will be highly 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-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: javascript

2008-09-19 Thread sergioh

Maybe an easy way for qa env you could add something like:

(r'^scripts/(.*)', 'django.views.static.serve',
{'document_root':'jscripts/'}),

 to your urls.py of your project.

And in your template:



This will looks for jquery.js inside the jscript directory
(yourproject/jscripts/lib/..)

On Sep 19, 10:03 pm, yozhik <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm learning django and ran into the following problem. I have an html
> file with an external javascript file. The .js file is in the same
> directory as html file . The problem is django ignores the script in
> the file but works fine otherwise, i.e. displays the html page
> correctly. Also, if I put the script inside html file (as opposed to
> in a separate file in the same directory) there are no problems.

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