Re: Forms - Widget - Radioselect - how to set initial value on a static form
Karen's suggestion is great. You can also pass initial data into the form constructor. So using the example above if you do (in your view): my_form = F1(initial=dict(rs_field='N')) you'll achieve the same result. Don't think there's much to be said for either way other the way I just suggest might allow you a bit more flexibility if you want something in the view to dictate the initial value. Euan On Jun 23, 4:37 am, Karen Tracey wrote: > On Tue, Jun 22, 2010 at 9:46 PM, Roboto wrote: > > I can't seem to find documentation on this anywhere, so I imagine > > someone must have run into this. > > > if I had a radioselect Yes / No and I wanted the default value to be > > 'No', but I'm not loading this data from a database or anything, is > > there a method to just insert an initial value so that the html comes > > out as No > > > ? > > > Any ideas? This is so basic it's killing me. > > You say RadioSelect widget but you mention HTML that doesn't go with a radio > input type -- option goes with a construct? If you showed some > code for what you are trying it might help people help you. The way to > specify the initially-selection option for a RadioSelect is to specify it as > the initial value for the associated form field. For example: > > class F1(forms.Form): > rs_field = forms.ChoiceField(choices=(('Y','Yes'), ('N','No')), > initial='N', widget=forms.RadioSelect) > > which would render (unbound) as: > > Rs field: > value="Y" name="rs_field" /> Yes > id="id_rs_field_1" value="N" name="rs_field" /> No< > /label> > > > ...with the "No" radio input initially selected, since it specified the > checked attribute. > > 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.
Re: How to options by limited_choices_to ?
First of all you might want to reconsider not using the name "type" for one of your fields as it is a builtin in python. I guess what you could do it limit the choices using the choices keyword in the field constructor. However, since this appears to be dynamic you would need to set it in the model's constructor, e.g. class Hardware(models.Model): ... def __init__(self, *args, **kwargs): self.fields['hardware_type'].choices = HardwareType.objects.all().values_list('pk', 'name')) I'm guessing at what the fields on HardwareType might be here. Euan On Jun 23, 2:06 am, cat in a tub wrote: > Hi All, > > I want to built a django application for hardware compatibility > testing > Some hardwares are compatible with certain mother board. And > attributes of each hardware are different (I use a ugly table to store > attributes), which are compatible with Hardware types, such as MEM as > SIZE, HDD has Firmware ver... > > class HardwareType > ... > > class Hardware > type=models.ForeighKey('HardwareType') > hardware_type=models.ForeignKey('HardwareType', > limited_choice_to{'compatible_type':self.type}) > attribute=ManyToManyField('hardwareAttribute') > > class HardwareAttribute > compatible_type=models.ForeighKey('HardwareType') > > I use limited_choice_to to limit the available options in the admin > (show compatible ones only) > But it doesn't work. The error is 'self is undefined ...' > > Any one here has any idea how to to this ? > > Thanking you in advance. > > Homer -- 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-Mysql
Thanks to everyone that replied. I got an friend that knows more about these stuff and he fixed it. Not sure how -- 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: virtual currency / check-in apps
No but you can do 'badges' or awards with this: http://bitbucket.org/jiaaro/django-badges/src HTH Dan On 23 June 2010 00:28, Greg Pelly wrote: > Can anyone recommend any apps/tools for implementing either virtual currency > or "check-ins" in Django? > Thanks, > > Greg > > -- > 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. > -- Dan Hilton www.twitter.com/danhilton www.DanHilton.co.uk -- 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.
An idea for a serialization framework
I am coming up with a framework that helps serialization of models. My idea is for each field to have a view permissions level: PUBLIC, OWNER, or ADMIN. I want to have a model to dict function that takes 2 arguments, permission_level and serialize_chain. Firstly, let me explain how it would change models.py: from django.db import models from django.contrib.auth.models import User class Profile(models.Model): user = models.ForeignKey(User, permission=PUBLIC) bio = models.TextField(permission=PUBLIC) activated = models.BooleanField(default=False, permission=OWNER) activate_code = models.CharField(max_length=256, permission=ADMIN) pages_bookmarked = models.ManyToManyField('Page', related_name='profile_pages_bookmarked', permission=OWNER) So, in this example, let's think about when we serialize Profile into a dictionary (for later turning into JSON for ajax). user is the only special case, so skip that mentally for now. Anyone is able to view a profile's bio. A person can view their own profile's activation status and what pages they have bookmarked. But only the system can read the activate_code. Of course the default value for permission would be ADMIN, so you'd have to explicitly allow fields to be sent to the browser. OK, and how would the serialization work? Let's look at a view function. from django.shortcuts import get_object_or_404 from django.http import HttpResponse import simplejson as json def ajax_profile_info(request, id): id = int(id) profile = get_object_or_404(Profile, id=id) # ok now we want to serialize profile for sending to json. # let's say this is the ajax view for getting data about OTHER people. return json_response(profile.serialize(PUBLIC)) def json_response(data): return HttpResponse(json.dumps(data), mimetype="text/plain") So in this view, only fields with the PUBLIC will get rendered into the dict. Let's say it was a view function for looking at a person's own account settings. Then we would pass OWNER to the serialize function and we would get all PUBLIC fields + OWNER fields. OK that's dandy, but I have one other idea to make serialization awesome. When you have models that foreignkey all over the place, it's a pain to create a nice json object that follows the chain to the exact depth that you want. So let me complicate the model a little bit. from django.db import models from django.contrib.auth.models import User class Profile(models.Model): user = models.ForeignKey(User, permission=PUBLIC) bio = models.TextField(permission=PUBLIC) activated = models.BooleanField(default=False, permission=OWNER) activate_code = models.CharField(max_length=256, permission=ADMIN) books_read = models.ManyToManyField('Book', related_name='profile_pages_bookmarked', permission=PUBLIC) class Book(models.Model): title = models.CharField(max_length=100, permission=PUBLIC) protagonist = models.ForeignKey('Character', permission=PUBLIC) language_used = models.ForeignKey('Language', permission=PUBLIC) cover_art_plan = models.ForeignKey('CoverArtPlan', permission=PUBLIC) internal_admin_thing = models.IntegerField(permission=ADMIN) class Character(models.Model): name = models.CharField(max_length=100, permission=PUBLIC) class Language(models.Model): name = models.CharField(max_length=100, permission=PUBLIC) class CoverArtPlan(models.Model): name = models.CharField(max_length=100, permission=PUBLIC) OK so let's say I'm making a page where we see all the books a person has read (and the info about those books). Here's a view function: def ajax_books_read(request, profile_id): id = int(id) profile = get_object_or_404(Profile, id=id) return json_response(profile.serialize(PUBLIC), ['books_read.protagonist', 'books_read.language_used']) So this second argument, the serialize_chain, says that we want to serialize profile into a dict, and the books_read field, instead of containing a list of ids, should contain a list of serialized Books. And since we have a dot there, when Profile passes it's serialization request on to Book, it cuts off the "books_read." and passes the rest to Book, so that book sees ['protagonist', 'language_used']. so when Book serializes, its 'protagonist' field is the serialization of the Character instead of just an id. Same for 'language_used'. However, since cover_art_plan was not included, it is simply the id of the CoverArtPlan instead of following the link. Also of note, since we serialized with PUBLIC, internal_admin_thing is completely left out of Book's serialized data. A note about access levels: let's say Profile was serialized with OWNER access, when it serializes its books_read, it doesn't pass OWNER, it de-escalates the access level to PUBLIC. However if you serialize Profile with ADMIN access, it does pass admin when it serializes its links. Think about it; it makes sense. Anyways, I would like to know if 1) Does a solution like this already
Re: An idea for a serialization framework
God damn it, the most dangerous thing about Dvorak is hitting tab instead of or along with apostrophe. "don't " translates into "don'" Anyways, I think this idea has merit - even alongside a role-based security system. Feedback? On Jun 23, 3:29 am, Andy Kelley wrote: > I am coming up with a framework that helps serialization of models. My > idea is for each field to have a view permissions level: PUBLIC, > OWNER, or ADMIN. I want to have a model to dict function that takes 2 > arguments, permission_level and serialize_chain. Firstly, let me > explain how it would change models.py: > > from django.db import models > from django.contrib.auth.models import User > class Profile(models.Model): > user = models.ForeignKey(User, permission=PUBLIC) > bio = models.TextField(permission=PUBLIC) > activated = models.BooleanField(default=False, permission=OWNER) > activate_code = models.CharField(max_length=256, permission=ADMIN) > pages_bookmarked = models.ManyToManyField('Page', > related_name='profile_pages_bookmarked', permission=OWNER) > > So, in this example, let's think about when we serialize Profile into > a dictionary (for later turning into JSON for ajax). user is the only > special case, so skip that mentally for now. Anyone is able to view a > profile's bio. A person can view their own profile's activation status > and what pages they have bookmarked. But only the system can read the > activate_code. Of course the default value for permission would be > ADMIN, so you'd have to explicitly allow fields to be sent to the > browser. > > OK, and how would the serialization work? Let's look at a view > function. > > from django.shortcuts import get_object_or_404 > from django.http import HttpResponse > import simplejson as json > > def ajax_profile_info(request, id): > id = int(id) > profile = get_object_or_404(Profile, id=id) > # ok now we want to serialize profile for sending to json. > # let's say this is the ajax view for getting data about OTHER > people. > return json_response(profile.serialize(PUBLIC)) > > def json_response(data): > return HttpResponse(json.dumps(data), mimetype="text/plain") > > So in this view, only fields with the PUBLIC will get rendered into > the dict. Let's say it was a view function for looking at a person's > own account settings. Then we would pass OWNER to the serialize > function and we would get all PUBLIC fields + OWNER fields. > > OK that's dandy, but I have one other idea to make serialization > awesome. When you have models that foreignkey all over the place, it's > a pain to create a nice json object that follows the chain to the > exact depth that you want. So let me complicate the model a little > bit. > > from django.db import models > from django.contrib.auth.models import User > > class Profile(models.Model): > user = models.ForeignKey(User, permission=PUBLIC) > bio = models.TextField(permission=PUBLIC) > activated = models.BooleanField(default=False, permission=OWNER) > activate_code = models.CharField(max_length=256, permission=ADMIN) > books_read = models.ManyToManyField('Book', > related_name='profile_pages_bookmarked', permission=PUBLIC) > > class Book(models.Model): > title = models.CharField(max_length=100, permission=PUBLIC) > protagonist = models.ForeignKey('Character', permission=PUBLIC) > language_used = models.ForeignKey('Language', permission=PUBLIC) > cover_art_plan = models.ForeignKey('CoverArtPlan', > permission=PUBLIC) > internal_admin_thing = models.IntegerField(permission=ADMIN) > > class Character(models.Model): > name = models.CharField(max_length=100, permission=PUBLIC) > > class Language(models.Model): > name = models.CharField(max_length=100, permission=PUBLIC) > > class CoverArtPlan(models.Model): > name = models.CharField(max_length=100, permission=PUBLIC) > > OK so let's say I'm making a page where we see all the books a person > has read (and the info about those books). Here's a view function: > > def ajax_books_read(request, profile_id): > id = int(id) > profile = get_object_or_404(Profile, id=id) > return json_response(profile.serialize(PUBLIC), > ['books_read.protagonist', 'books_read.language_used']) > > So this second argument, the serialize_chain, says that we want to > serialize profile into a dict, and the books_read field, instead of > containing a list of ids, should contain a list of serialized Books. > And since we have a dot there, when Profile passes it's serialization > request on to Book, it cuts off the "books_read." and passes the rest > to Book, so that book sees ['protagonist', 'language_used']. so when > Book serializes, its 'protagonist' field is the serialization of the > Character instead of just an id. Same for 'language_used'. However, > since cover_art_plan was not included, it is simply the id of the > CoverArtPlan instead of following the link. Also of note, since we > serialized with PUBLIC, intern
Re: An idea for a serialization framework
I posted this to django-developers instead, so if you want to reply go find that thread and do it there. On Jun 23, 3:33 am, Andy Kelley wrote: > God damn it, the most dangerous thing about Dvorak is hitting tab > instead of or along with apostrophe. "don't " translates into > "don'" > > Anyways, I think this idea has merit - even alongside a role-based > security system. > > Feedback? > > On Jun 23, 3:29 am, Andy Kelley wrote: > > > I am coming up with a framework that helps serialization of models. My > > idea is for each field to have a view permissions level: PUBLIC, > > OWNER, or ADMIN. I want to have a model to dict function that takes 2 > > arguments, permission_level and serialize_chain. Firstly, let me > > explain how it would change models.py: > > > from django.db import models > > from django.contrib.auth.models import User > > class Profile(models.Model): > > user = models.ForeignKey(User, permission=PUBLIC) > > bio = models.TextField(permission=PUBLIC) > > activated = models.BooleanField(default=False, permission=OWNER) > > activate_code = models.CharField(max_length=256, permission=ADMIN) > > pages_bookmarked = models.ManyToManyField('Page', > > related_name='profile_pages_bookmarked', permission=OWNER) > > > So, in this example, let's think about when we serialize Profile into > > a dictionary (for later turning into JSON for ajax). user is the only > > special case, so skip that mentally for now. Anyone is able to view a > > profile's bio. A person can view their own profile's activation status > > and what pages they have bookmarked. But only the system can read the > > activate_code. Of course the default value for permission would be > > ADMIN, so you'd have to explicitly allow fields to be sent to the > > browser. > > > OK, and how would the serialization work? Let's look at a view > > function. > > > from django.shortcuts import get_object_or_404 > > from django.http import HttpResponse > > import simplejson as json > > > def ajax_profile_info(request, id): > > id = int(id) > > profile = get_object_or_404(Profile, id=id) > > # ok now we want to serialize profile for sending to json. > > # let's say this is the ajax view for getting data about OTHER > > people. > > return json_response(profile.serialize(PUBLIC)) > > > def json_response(data): > > return HttpResponse(json.dumps(data), mimetype="text/plain") > > > So in this view, only fields with the PUBLIC will get rendered into > > the dict. Let's say it was a view function for looking at a person's > > own account settings. Then we would pass OWNER to the serialize > > function and we would get all PUBLIC fields + OWNER fields. > > > OK that's dandy, but I have one other idea to make serialization > > awesome. When you have models that foreignkey all over the place, it's > > a pain to create a nice json object that follows the chain to the > > exact depth that you want. So let me complicate the model a little > > bit. > > > from django.db import models > > from django.contrib.auth.models import User > > > class Profile(models.Model): > > user = models.ForeignKey(User, permission=PUBLIC) > > bio = models.TextField(permission=PUBLIC) > > activated = models.BooleanField(default=False, permission=OWNER) > > activate_code = models.CharField(max_length=256, permission=ADMIN) > > books_read = models.ManyToManyField('Book', > > related_name='profile_pages_bookmarked', permission=PUBLIC) > > > class Book(models.Model): > > title = models.CharField(max_length=100, permission=PUBLIC) > > protagonist = models.ForeignKey('Character', permission=PUBLIC) > > language_used = models.ForeignKey('Language', permission=PUBLIC) > > cover_art_plan = models.ForeignKey('CoverArtPlan', > > permission=PUBLIC) > > internal_admin_thing = models.IntegerField(permission=ADMIN) > > > class Character(models.Model): > > name = models.CharField(max_length=100, permission=PUBLIC) > > > class Language(models.Model): > > name = models.CharField(max_length=100, permission=PUBLIC) > > > class CoverArtPlan(models.Model): > > name = models.CharField(max_length=100, permission=PUBLIC) > > > OK so let's say I'm making a page where we see all the books a person > > has read (and the info about those books). Here's a view function: > > > def ajax_books_read(request, profile_id): > > id = int(id) > > profile = get_object_or_404(Profile, id=id) > > return json_response(profile.serialize(PUBLIC), > > ['books_read.protagonist', 'books_read.language_used']) > > > So this second argument, the serialize_chain, says that we want to > > serialize profile into a dict, and the books_read field, instead of > > containing a list of ids, should contain a list of serialized Books. > > And since we have a dot there, when Profile passes it's serialization > > request on to Book, it cuts off the "books_read." and passes the rest > > to Book, so that book sees ['protagonist', 'language_u
trouble with many to many form
Hi all. I'm new to django. Help me pls. Situation: Need form on web page that look like this: --- Item order form Your name: [___] Tel : [] etc. item1_name_here | count [___] item2_name_here | count [___] ... itemN_name_here | count [___] (Submit) --- In this form i need to create new order with items and their count. Looks simply. But i can't do it.. :( Item that displayed in this form is queering from model Item (all items must be displayed). How can i do it? my models: class Item(ImageModel): name = models.CharField(max_length=100) class Order(models.Model): name = models.CharField(max_length=100) tel = models.CharField(max_length=100) class Itemsinorder(models.Model): itemcount = models.IntegerField() order = models.ForeignKey(Order) item = models.ForeignKey(Item) Thanks. p.s. sorry for my English. -- 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.
mysql fulltext search
Hi, is there more information/examples available on fulltext with mysql as the statement here, that it exists as __search: http://docs.djangoproject.com/en/1.1/ref/models/querysets/ I would like to do something like this: http://dev.mysql.com/doc/refman/5.1/de/fulltext-search.html having more than one indexed column each table regards Henrik -- 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: trouble with many to many form
I am also pretty new to django but I think that what you are looking for is the many to many through relationship: http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships Maybe someone else can provide more information if that doesn't get you started. -- Casey On 06/23/2010 07:48 AM, netremo wrote: Hi all. I'm new to django. Help me pls. Situation: Need form on web page that look like this: --- Item order form Your name: [___] Tel : [] etc. item1_name_here | count [___] item2_name_here | count [___] ... itemN_name_here | count [___] (Submit) --- In this form i need to create new order with items and their count. Looks simply. But i can't do it.. :( Item that displayed in this form is queering from model Item (all items must be displayed). How can i do it? my models: class Item(ImageModel): name = models.CharField(max_length=100) class Order(models.Model): name = models.CharField(max_length=100) tel = models.CharField(max_length=100) class Itemsinorder(models.Model): itemcount = models.IntegerField() order = models.ForeignKey(Order) item = models.ForeignKey(Item) Thanks. p.s. sorry for my English. -- 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: trouble with many to many form
It's not casual form 2010/6/23 Casey S. Greene > I am also pretty new to django but I think that what you are looking for is > the many to many through relationship: > > > http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships > > Maybe someone else can provide more information if that doesn't get you > started. > > -- Casey > > > > On 06/23/2010 07:48 AM, netremo wrote: > >> Hi all. I'm new to django. Help me pls. >> >> Situation: >> >> Need form on web page that look like this: >> >> --- >> Item order form >> >> >> Your name: [___] >> Tel : [] >> etc. >> >> >> >> item1_name_here | count [___] >> item2_name_here | count [___] >> ... >> itemN_name_here | count [___] >> >> >> (Submit) >> --- >> >> In this form i need to create new order with items and their count. >> Looks simply. But i can't do it.. :( >> >> Item that displayed in this form is queering from model Item (all >> items must be displayed). >> >> How can i do it? >> >> my models: >> >> class Item(ImageModel): >> name = models.CharField(max_length=100) >> >> class Order(models.Model): >> name = models.CharField(max_length=100) >> tel = models.CharField(max_length=100) >> >> class Itemsinorder(models.Model): >> itemcount = models.IntegerField() >> order = models.ForeignKey(Order) >> item = models.ForeignKey(Item) >> >> Thanks. >> p.s. sorry for my English. >> >> > -- > 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.
Limiting choices in an admin inline
Hi, I'm trying to limit choices in an admin inline foreign key dropdown. I have a models.py and admin.py roughly as follows: # models.py class Trip(object): title = models.CharField(max_length=50) class Departure(object): trip = models.ForeignKey('Trip') price_window = models.ForeignKey('PriceWindow', blank=True, null=True) class PriceWindow(models.Model): trip = models.ForeignKey('Trip') title = models.CharField(max_length=50) # admin.py: class PriceWindowInline(admin.TabularInline): model = PriceWindow extra = 1 class DepartureInline(admin.TabularInline): model = Departure extra = 1 class TripAdmin(admin.ModelAdmin): inlines = (PriceWindowInline, DepartureInline) When I view a Trip in the admin interface, as expected, I get inlines for Departures and Price Windows. What I would like to do is to restrict the price window dropdown in the Departure inline to those price windows which are associated with the trip that is currently being viewed (the default, of course, is to show all price windows.) The only way I've found of achieving this is adding the following method to DepartureInline: def formfield_for_dbfield(self, field, **kw): if field.name == 'price_window': trip_id = kw['request'].META['PATH_INFO'].strip('/').split('/')[-1] trip = Trip.objects.get(pk=trip_id) return forms.ModelChoiceField( label=u'Price window', queryset=PriceWindow.objects.filter(trip=trip) ) else: return super(DepartureInline, self).formfield_for_dbfield(field, **kw) I don't like this, as it dives into the request and relies on the structure of the admin URL; it'd be cleaner if I could somehow get a reference to the Trip that's being edited. Is there a better way? Cheers, Dan How should I approach this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Problem with DateField input_formats
I have: DATE_INPUT_FORMATS = ( '%n/%j/%Y', '%n/%j/%y', # '10/25/2006', '10/25/06' '%n-%j-%Y', '%n-%j-%y', # '10-25-2006', '10-25-06' '%M %j %Y', '%M %j, %Y', # 'Oct 25 2006', 'Oct 25, 2006' '%b %j %Y', '%b %j, %Y', # 'oct 25 2006', 'oct 25, 2006' '%F %j %Y', '%F %j, %Y', # 'October 25 2006', 'October 25, 2006' ) class CandidateProfileForm(forms.ModelForm): class Meta: model = Person dob = forms.DateField(input_formats=DATE_INPUT_FORMATS) But I'm not getting my date format through. For example, 4-20-1990 fails, even though I think it should be covered by %n-%j-%Y I've also tried: class CandidateProfileForm(forms.ModelForm): class Meta: model = Person widgets = { 'dob': forms.DateField(input_formats=DATE_INPUT_FORMATS), } with no luck. What am I missing here? -- 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 logging
Hi, I am creating a new django framework and figured django would come with its own logging feature. I found this one that Fraser wrote but is no longer in development (http://code.google.com/p/django-logging/ wiki/Overview) Can anyone suggest me a django logging project to log debug/error messages at server level and as a bonus feature perhaps an email to admin if a critical error happens. Cheers, Nathan. -- 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.
root_path in admin sites is None
After migrating to 1.2 I encountered a problem in admin panel. My change password ang logout links look like this: https://example.com/admin/Nonelogout/ https://example.com/admin/Nonepassword_change/ I have taken a look into django source and it seems, that root_path is None (at least this variable is rendered in those urls). What I might have forgotten to set and how can I change it to an empty string? -- Filip Gruszczyński -- 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-tagging registering
I have, in my code: import tagging class Entity(models.Model): ... tagging.register(Entity) I'm getting an error. So far as I can tell, this is the only time tagging.register() is called, although I do call admin.site.register(Entity). Any ideas how I might be making a redundant request? If this is happening because the file is being imported more than once, what is an appropriate way to guarantee that Entity is only registered once? AlreadyRegistered at / The model 'Entity' has already been registered. Request Method:GETRequest URL:http://linux:8000/Exception Type: AlreadyRegisteredException Value: The model 'Entity' has already been registered. Exception Location:/usr/local/lib/python2.6/dist-packages/django_tagging-0.3.1-py2.6.egg/tagging/__init__.py in register, line 39Python Executable:/usr/bin/pythonPython Version:2.6.5Python Path:['/home/jonathan/directory', '/usr/local/lib/python2.6/dist-packages/pip-0.6.3-py2.6.egg', '/home/jonathan/store/src/satchmo/satchmo/apps', '/usr/local/lib/python2.6/dist-packages/django_threaded_multihost-1.3_3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_signals_ahoy-0.1_1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_tagging-0.3.1-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']Server time:Wed, 23 Jun 2010 10:46:07 -0500 -- → Jonathan Hayward, christos.jonathan.hayw...@gmail.com → An Orthodox Christian author: theology, literature, et cetera. → My award-winning collection is available for free reading online: ☩ I invite you to visit my main site at http://JonathansCorner.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with DateField input_formats
On Wed, Jun 23, 2010 at 11:34 AM, bax...@gretschpages.com < mail.bax...@gmail.com> wrote: > I have: > > DATE_INPUT_FORMATS = ( >'%n/%j/%Y', '%n/%j/%y', # '10/25/2006', '10/25/06' >'%n-%j-%Y', '%n-%j-%y', # '10-25-2006', '10-25-06' >'%M %j %Y', '%M %j, %Y', # 'Oct 25 2006', 'Oct 25, 2006' >'%b %j %Y', '%b %j, %Y', # 'oct 25 2006', 'oct 25, 2006' >'%F %j %Y', '%F %j, %Y', # 'October 25 2006', 'October 25, 2006' > ) > > Looks like you are using the table from http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ttag-now, which is used for formatting date/times for output. The input formats, as noted http://docs.djangoproject.com/en/dev/ref/settings/#date-input-formats use Python's formatting characters: http://docs.python.org/library/datetime.html#strftime-strptime-behavior, not the ones in that other table which come from PHP's date() function (yes, this is not ideal that the two are different, but that's the way it is). %n is not in Python's table -- I think you want %m where you have %n %j, to Python, is day of the year as a decimal number, not day of the month. I think you want %d where you have %j %M is minutes, I think you want %b where you have %M %F is not in the table, I think you want %B where you have %F. 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.
Re: django-tagging registering
On Wed, Jun 23, 2010 at 11:52 AM, Jonathan Hayward < christos.jonathan.hayw...@gmail.com> wrote: > what is an appropriate way to guarantee that Entity is only registered > once? > Yes, it happens because models.py may be imported more than once. You should put admin registrations in an admin.py file, not models.py, and call admin.autodiscover() from urls.py. See: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objectsand http://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf . 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.
Django ModelAdmin doesn't seem to save m2m fields with save_model
Hi, I have some trouble understanding how ModelAdmin do save models when those have many to many fields. Long story: I have for one of my application overridden ModelAdmin class and the save_model. Basicaly, the save_model is: def save_model(self, request, obj, form, change): super(TranslationAdmin, self).save_model(request, obj, form, change) # Some other processing However, I have noticed that if the object has a many to many field, it isn't saved. I looked at ModelAdmin and BaseModelAdmin classes and all I saw is BaseModelAdmin doing a simple obj.save() I just don't understand why my many to many fields aren't saved. I added a form.save_m2m() in my save_model but I still don't understand why I need it. Could someone help me understand or simply point me in a direction to look at please ? Regards, Xavier. -- 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: root_path in admin sites is None
i have the same problem i fixed: in urls.py root proyect before: ('^admin/(.*)', admin.site.root), after: (r'^admin/', include(admin.site.urls)), it work good now!!! bye 2010/6/23 Filip Gruszczyński > After migrating to 1.2 I encountered a problem in admin panel. My > change password ang logout links look like this: > > https://example.com/admin/Nonelogout/ > https://example.com/admin/Nonepassword_change/ > > I have taken a look into django source and it seems, that root_path is > None (at least this variable is rendered in those urls). What I might > have forgotten to set and how can I change it to an empty string? > > -- > Filip Gruszczyński > > -- > 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: root_path in admin sites is None
> before: ('^admin/(.*)', admin.site.root), > > after: (r'^admin/', include(admin.site.urls)), Well, I had to change it before and about two weeks ago I changed it too (this is how my urls.py looks like): (r'^admin/doc/', include('django.contrib.admindocs.urls')), # (r'^admin/(.*)', admin.site.root), (r'^admin/', include(admin.site.urls)), It solved some other problems (admin didn't work at all), but I still have the problems with links in admin site. > > it work good now!!! > > bye > > 2010/6/23 Filip Gruszczyński >> >> After migrating to 1.2 I encountered a problem in admin panel. My >> change password ang logout links look like this: >> >> https://example.com/admin/Nonelogout/ >> https://example.com/admin/Nonepassword_change/ >> >> I have taken a look into django source and it seems, that root_path is >> None (at least this variable is rendered in those urls). What I might >> have forgotten to set and how can I change it to an empty string? >> >> -- >> Filip Gruszczyński >> >> -- >> 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. > -- Filip Gruszczyński -- 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 logging
On 23/06/10 16:48, thusjanthan wrote: Hi, I am creating a new django framework and figured django would come with its own logging feature. I found this one that Fraser wrote but is no longer in development (http://code.google.com/p/django-logging/ wiki/Overview) That's wasn't really for logging in the operational server system logs sense, it was for showing log messages arising in the request-response cycle in the html returned to the browser (which IS very handy during development/debug, but not something you'd do on a production server...). django-debug-toolbar has a superset of its functionality. Can anyone suggest me a django logging project to log debug/error messages at server level and as a bonus feature perhaps an email to admin if a critical error happens. Python itself ships with a logging infrastructure (quite the baroque one), module "logging". You can just use that in conjunction with django. http://docs.python.org/release/2.6/library/logging.html regarding email: Django does fire off certain exception emails when disaster strikes, python logging has SMTPHandler, and there's also the "logwatch" tool once you have stuff going to logs. ### So, most of our django app's python files do something like the following near the top: # say for the models.py in a django app "accounts" import logging _log = logging.getLogger('accounts.models') # and then use _log.error("ohno") _log.warning("grr") _log.info("hey") _log.debug("soturnsout") We use the leading underscore on the module-level _log so that A doesn't pick up B's logger if A does a "from B import *" ! ### We then init python's logging in a vaguely django-project-useful fashion in a function called from our settings.py or somewhere similarly early (you may need to take steps to make sure to only register the handlers once per process, say a global "configured" var) e.g. (not precisely the code we use, untested): # prefix is just a per-project prefix we set, that way two # instances of the same app in two different projects are # distinguishable in combined logging. # root logger for argument's sake # you might want something else, see logging docs rl = logging.getLogger('') # Stuff you send to stderr with mod_wsgi does end up in the apache log, # though maybe it's not the best option. streamformatter = logging.Formatter("django[%(process)d]: %(levelname)s: [" + prefix + "]%(name)s: %(message)s") streamhandler = logging.StreamHandler() # defaults to stderr streamhandler.setLevel(logging.WARNING) streamhandler.setFormatter(streamformatter) rl.addHandler(streamhandler) # and/or you could send to syslog slformatter = logging.Formatter("django[%(process)d]: %(levelname)s: [" + prefix + "]%(name)s: %(message)s") sysloghandler = logging.handlers.SysLogHandler( address='/dev/log', facility=logging.handlers.SysLogHandler.LOG_DAEMON) sysloghandler.setLevel(logging.WARNING) sysloghandler.setFormatter(slformatter) rl.addHandler(sysloghandler) # And/or to a file # N.B. python 2.5 lacks WatchedFileHandler, but it's an easy backport # from 2.6 sources. # base some base file path+name fformatter = logging.Formatter("[%(asctime)s] django[%(process)d]: %(levelname)s: [" + prefix + "]%(name)s: %(message)s") h = WatchedFileHandler(base + ".log", encoding='utf-8') h.setLevel(logging.INFO) h.setFormatter(fformatter) rl.addHandler(h) e = WatchedFileHandler(base + ".err", encoding='utf-8') e.setLevel(logging.ERROR) e.setFormatter(fformatter) rl.addHandler(e) if settings.DEBUG: debugformatter = logging.Formatter("[%(asctime)s] django[%(process)d]: %(levelname)s: [" + prefix + "]%(name)s: %(pathname)s(%(lineno)d): %(message)s") d = WatchedFileHandler(base + ".dbg", encoding='utf-8') d.setLevel(logging.DEBUG) d.setFormatter(debugformatter) rl.addHandler(d) # See logging docs for more. -- 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.
djangocon hotel question
I bought a early bird ticket a few days ago. It said that the hotel was going to cost $104. Is that value per night, or is it for all 7 days of the conference? It doesn't say. -- 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.
authenticate problem with multiple db ?
Hi, when authenticate is called i get this error http://dpaste.com/210674/ though the user exist in database... is authenticate known to not work with multiple database context ? my register function was working fine before that... i've tried with @transaction.autocommit in place of @transaction.commit_on_success to ensure the creation of the user before authenticate is called. here is the function : @transaction.autocommit def register(request,template_name='accounts/ register.html',template_name_success='accounts/ register_success.html'): if request.method == 'POST': form = RegisterForm(request.POST) if form.is_valid(): formdata = form.cleaned_data user = User.objects.create_user( formdata['username_reg'], formdata['email_address'], formdata['password_reg'], ) UserProfile(user=user).save() user = authenticate( username = formdata['username_reg'], password = formdata['password_reg'] ) login(request, user) return render_to_response( template_name_success, { }, context_instance = RequestContext(request) ) else: form = RegisterForm() return render_to_response( template_name, { 'form': form }, context_instance = RequestContext(request) ) thanx! -- 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.
import django : error
$import django error : import: unable to open X server `' @ import.c/ImportImageCommand/361. i am working on ubuntu 10.04 server version -- 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.
SVN Problems
Hi List, I try to sync with the svn repo of django but all I get is # svn co http://code.djangoproject.com/svn/django/trunk django-trunk svn: The server responded in an anwaited way(504 Gateway Time-out) to the question PROPFIND for »/svn/django/trunk« someone an idea how to solve this? Greetings -- --- Martin 'golodhrim' Scholz Auf dem Sattler 4 34516 Ederbringhausen Phone: +49 6454 799623 mobile: +49 176 63301749 Fax: +49 6454 e-Mail: scholz@googlemail.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-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: import django : error
On Jun 23, 11:00 pm, Jagdeep Singh Malhi wrote: > $import django > error : > import: unable to open X server `' @ import.c/ImportImageCommand/361. > > i am working on ubuntu 10.04 server version And ./manage.py runserver Error: No module named messages how handle this error ??? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to access the request inside a model manager's get_query_set?
I would like to define a default manager for MyModel that always filters all records (when the model is accessed from anywhere in my application) based on data from the request: e.g. on the lines of: class MyModelManager(models.Manager): #override default def get_query_set(self, request): if request.foo == bar: return super(MyModelManager, self).get_query_set() return MyModel.objects.filter(spam = eggs) class MyModel(models.Model): ... objects = MyModelManager() However I get the error: Django Version: 1.2.1 Exception Type: TypeError Exception Value: Error when calling the metaclass bases get_query_set() takes exactly 2 arguments (1 given) So its clear that get_query_set() cannot take the request inserted there... but how else can I access the request inside the above model Manager class? (Note that I don't want to define an extra method that needs to be appended onto the MyModels.objects.zzz type of chained calls - such as the solution posted at http://osdir.com/ml/django-users/2010-02/msg00819.html - as I would then have to make these changes throughout the application, and also remember to add such a method to all future code.) 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.
from a template how to access the request object
Hi all. >From a template suppose base.html in your templates how do I access the request object without actually passing it via the view. Cause I can access the user object using {{ user }} but I can't access the get_full_path using something like {{ request.get_full_path }} Any thoughts? Nathan. -- 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.
Generate image and send to template
Hi all, I need generate a image and send to template, but I'm not getting ...see my code http://paste.pocoo.org/show/OtwMsOEhe8c9b7jF0elw/ I'm not getting to understand the def generate_graph (request): -- 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: SVN Problems
On Wed, Jun 23, 2010 at 2:08 PM, Martin 'golodhrim' Scholz < scholz@googlemail.com> wrote: > Hi List, > > I try to sync with the svn repo of django but all I get is > > # svn co http://code.djangoproject.com/svn/django/trunk django-trunk > svn: The server responded in an anwaited way(504 Gateway Time-out) to the > question PROPFIND for »/svn/django/trunk« > > someone an idea how to solve this? Just a guess based on the "gateway time-out" but it sounds like your machine is behind some sort of gateway/proxy that does not fully support the HTTP methods that SVN requires. So your machine says "PROPFIND", the gateway drops the request on the floor because it does not support it, and eventually your machine times out and gives you that error message. If that is the problem, and you have control over the gateway/proxy, you could perhaps fix/configure it to support these methods. But I'm guessing you don't control the gateway box causing the problem, in which case the only way I know of to fix it is to use a machine that is not behind the broken proxy/gateway. Alternatively you could just install a released version via one of the two first options listed here: http://docs.djangoproject.com/en/1.2/intro/install/#install-django. Or if you really want to be keeping up with the latest trunk level, one of the unofficial DVCS mirrors may be a way to go -- if you are interested in that then mention what DVCS you'd prefer to use and someone may be able to point you in the right direction. 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.
Re: import django : error
On Wed, Jun 23, 2010 at 2:26 PM, Jagdeep Singh Malhi < singh.malh...@gmail.com> wrote: > > > On Jun 23, 11:00 pm, Jagdeep Singh Malhi > wrote: > > $import django > > error : > > import: unable to open X server `' @ import.c/ImportImageCommand/361. > > > > i am working on ubuntu 10.04 server version > > And > ./manage.py runserver > > Error: No module named messages > > how handle this error ??? > For the first I have no idea, never seen it. The "No module named messages" error happens when you have a Django project settings file that was created with Django 1.2 but the Django your PYTHONPATH is pointing to is 1.1.X or lower. Fix is to fix up your PYTHONPATH to point to a 1.2 level of Django. 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.
Re: from a template how to access the request object
On Wed, Jun 23, 2010 at 3:04 PM, thusjanthan wrote: > From a template suppose base.html in your templates how do I access > the request object without actually passing it via the view. Cause I > can access the user object using {{ user }} but I can't access the > get_full_path using something like {{ request.get_full_path }} > > Any thoughts? > Sounds like you are using a RequestContext, which is the first step. That plus having the auth context processor listed in the TEMPLATE_CONTEXT_PROCESSORS setting would give you a template variable user. (The auth context processor is included in the default setting value for TEMPLATE_CONTEXT_PROCESSORS.) The context processor that would set request is this one: http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request. That one is not in the default TEMPLATE_CONTEXT_PROCESSORS setting, so if you want request to be set in all your templates then you'll need to add it. 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.
Re: SVN Problems
On Wed, 23 Jun 2010 15:23:44 -0400, Karen Tracey wrote: > On Wed, Jun 23, 2010 at 2:08 PM, Martin 'golodhrim' Scholz < > scholz@googlemail.com> wrote: > >> Hi List, >> >> I try to sync with the svn repo of django but all I get is >> >> # svn co http://code.djangoproject.com/svn/django/trunk django-trunk >> svn: The server responded in an anwaited way(504 Gateway Time-out) to >> the question PROPFIND for »/svn/django/trunk« >> >> someone an idea how to solve this? > > > Just a guess based on the "gateway time-out" but it sounds like your > machine is behind some sort of gateway/proxy that does not fully support > the HTTP methods that SVN requires. So your machine says "PROPFIND", the > gateway drops the request on the floor because it does not support it, > and eventually your machine times out and gives you that error message. > > If that is the problem, and you have control over the gateway/proxy, you > could perhaps fix/configure it to support these methods. But I'm > guessing you don't control the gateway box causing the problem, in which > case the only way I know of to fix it is to use a machine that is not > behind the broken proxy/gateway. > > Alternatively you could just install a released version via one of the > two first options listed here: > http://docs.djangoproject.com/en/1.2/intro/install/#install-django. Or > if you really want to be keeping up with the latest trunk level, one of > the unofficial DVCS mirrors may be a way to go -- if you are interested > in that then mention what DVCS you'd prefer to use and someone may be > able to point you in the right direction. > > Karen > -- > http://tracey.org/kmt/ Hi Karen, thanks for your hint, as other svn repos are working, I don't know where to look for the error in the gateway, but if someone has a git repo somewhere it would be nice to know, as I know these normaly don't fail. Greetings -- --- Martin 'golodhrim' Scholz Auf dem Sattler 4 34516 Ederbringhausen Phone: +49 6454 799623 mobile: +49 176 63301749 Fax: +49 6454 e-Mail: scholz@googlemail.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-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.
Would like to modify request.user and have it be the changed value through out site
Hi, Basically within my application for whatever reason I am changing the user and doing something like this: Ex: at first the request.user = UserA request.user = Users.objects.get(some exp) After this the request.user = UserB However once the page redirects to another page the request.user goes back to being the original one (UserA) that logged in. How do I permanently change the request.user for the duration of the session? Thank you all, Nathan. -- 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.
noob syntax question
Hi, In the tutorial 1. It has this: # Give the Poll a couple of Choices. The create call constructs a new # choice object, does the INSERT statement, adds the choice to the set # of available choices and returns the new Choice object. Django creates # a set to hold the "other side" of a ForeignKey relation # (e.g. a poll's choices) which can be accessed via the API. and gives these examples: # Create three choices. >>> p.choice_set.create(choice='Not much', votes=0) >>> p.choice_set.create(choice='The sky', votes=0) >>> c = p.choice_set.create(choice='Just hacking again', votes=0) I understand what its doing, but I don't understand where the "_set" comes from or where its resolved to. Its probably more of a python thing than a django thing, but if someone could provide insight, it would be much appreciate. Thanks, -j -- 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: Would like to modify request.user and have it be the changed value through out site
On Jun 23, 9:14 pm, thusjanthan wrote: > Hi, > > Basically within my application for whatever reason I am changing the > user and doing something like this: > > Ex: at first the request.user = UserA > > request.user = Users.objects.get(some exp) > > After this the request.user = UserB > > However once the page redirects to another page the request.user goes > back to being the original one (UserA) that logged in. How do I > permanently change the request.user for the duration of the session? > > Thank you all, > Nathan. Write your own middleware in place of django.contrib.auth.middleware.AuthenticationMiddleware, which returns your UserB instead of UserA. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: noob syntax question
(Sorry in advance for the brevity and any typos, I am typing this from my aging Windows Mobile). It's quite Django-specific actually. If you take a look at http://docs.djangoproject.com/en/dev/topics/db/queries/ it says, "Django also creates API accessors for the "other" side of the relationship -- the link from the related model to the model that defines the relationship. For example, a Blog object b has access to a list of all related Entry objects via the entry_set attribute: b.entry_set.all()." Hope that clears things up. Michael Schade Spearhead Development LLC On 6/23/10, Sector7B wrote: > Hi, > In the tutorial 1. > > It has this: > # Give the Poll a couple of Choices. The create call constructs a new > # choice object, does the INSERT statement, adds the choice to the set > # of available choices and returns the new Choice object. Django > creates > # a set to hold the "other side" of a ForeignKey relation > # (e.g. a poll's choices) which can be accessed via the API. > > and gives these examples: > # Create three choices. p.choice_set.create(choice='Not much', votes=0) > p.choice_set.create(choice='The sky', votes=0) > c = p.choice_set.create(choice='Just hacking again', votes=0) > > I understand what its doing, but I don't understand where the "_set" > comes from or where its resolved to. > Its probably more of a python thing than a django thing, but if > someone could provide insight, it would be much appreciate. > > Thanks, > -j > > -- > 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. > > -- Sincerely, Michael Schade www.mschade.me - 815.514.1410 -- 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 logging
On Thu, Jun 24, 2010 at 1:07 AM, David De La Harpe Golden wrote: > On 23/06/10 16:48, thusjanthan wrote: >> >> Hi, >> >> I am creating a new django framework and figured django would come >> with its own logging feature. I found this one that Fraser wrote but >> is no longer in development (http://code.google.com/p/django-logging/ >> wiki/Overview) > > That's wasn't really for logging in the operational server system logs > sense, it was for showing log messages arising in the request-response cycle > in the html returned to the browser (which IS very handy during > development/debug, but not something you'd do on a production server...). > > django-debug-toolbar has a superset of its functionality. > >> Can anyone suggest me a django logging project to log >> debug/error messages at server level and as a bonus feature perhaps an >> email to admin if a critical error happens. >> > > Python itself ships with a logging infrastructure (quite the baroque one), > module "logging". You can just use that in conjunction with django. > > http://docs.python.org/release/2.6/library/logging.html > > regarding email: Django does fire off certain exception emails when > disaster strikes, python logging has SMTPHandler, and there's also the > "logwatch" tool once you have stuff going to logs. I would also add that adding support for logging is one of the high priority items for Django 1.3 [1]. The design is mostly sorted at this point, and a preliminary implementation is available at [2] [1] http://code.djangoproject.com/tickets/12012 [2] https://code.launchpad.net/~vinay-sajip/django/logging 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-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: djangocon hotel question
On Thu, Jun 24, 2010 at 1:08 AM, ff wrote: > I bought a early bird ticket a few days ago. It said that the hotel > was going to cost $104. Is that value per night, or is it for all 7 > days of the conference? It doesn't say. It doesn't say because it's pretty much implied -- it's $104 a night. Not everybody will be staying for the full length of the conference, and some people (like myself) will be there a day or so either side to account for jetlag/travel arrangements. Also... I don't even want to think what a $14.86 per night hotel would be like... Even Motel 6 charges more... :-) 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-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: Question regarding subdomains of a single project
> Check out this from djangosnippets: http://djangosnippets.org/snippets/1509/ > It allows you to specify multiple URLconfs and then choose which you > .. Anyone know if the ticket mentioned in the comments (#5034) of the above djangosnippet has been resolved? -- 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: authenticate problem with multiple db ?
On Thu, Jun 24, 2010 at 1:25 AM, Keats wrote: > Hi, > when authenticate is called i get this error http://dpaste.com/210674/ > though the user exist in database... is authenticate known to not work > with multiple database context ? I'm not aware of any problems. The authenticate code doesn't do anything special with the database either, so I can't think of any obvious sources of problems that might have been missed. My first port of call would be to look into the way you have multi-database configured, to ensure that the queries that are issued can be directed to the appropriate database. If you're getting errors that indicate that a user doesn't exist, that would suggest that the query may be being routed to the wrong database. 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-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: djangocon hotel question
oh i see. I thought that it may be a possibility that ticket prices would maybe offset the cost a little so they could charge a little less for the rooms... thanks for the clarification... I've never been to a conference like this, so I have no idea how these things work. On Jun 23, 7:41 pm, Russell Keith-Magee wrote: > On Thu, Jun 24, 2010 at 1:08 AM, ff wrote: > > I bought a early bird ticket a few days ago. It said that the hotel > > was going to cost $104. Is that value per night, or is it for all 7 > > days of the conference? It doesn't say. > > It doesn't say because it's pretty much implied -- it's $104 a night. > Not everybody will be staying for the full length of the conference, > and some people (like myself) will be there a day or so either side to > account for jetlag/travel arrangements. > > Also... I don't even want to think what a $14.86 per night hotel would > be like... Even Motel 6 charges more... :-) > > 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-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 logging
On 2010-06-23, at 8:48 AM, thusjanthan wrote: > I am creating a new django framework and figured django would come > with its own logging feature. I found this one that Fraser wrote but > is no longer in development (http://code.google.com/p/django-logging/ > wiki/Overview) Can anyone suggest me a django logging project to log > debug/error messages at server level and as a bonus feature perhaps an > email to admin if a critical error happens. Give Arecibo a look. http://www.areciboapp.com/ http://www.areciboapp.com/docs/client/django.html http://www.agmweb.ca/blog/andy/2268/ etc... Cheers -- Andy McKay, @andymckay Django Consulting, Training and Support -- 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.
trying to do console testing of my models, "no module named X"
I have a django project running on local linux machine with apache. I run this at localhost:8081 and I use import statements to import my models in my views (e.g. "from DjangoSite.ManageProducts.models import Member"). For testing, I want to be able to import my models into python console and run test queries. I don't know how python knows where my models are...when I run import statement in python console, it comes back with error "no module named DjangoSite.ManageProducts.models". How do I references my own modules using console? Do I need to add my project to python path? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: import django : error
On Jun 24, 12:26 am, Karen Tracey wrote: > On Wed, Jun 23, 2010 at 2:26 PM, Jagdeep Singh Malhi < > > > > singh.malh...@gmail.com> wrote: > > > On Jun 23, 11:00 pm, Jagdeep Singh Malhi > > wrote: > > > $import django > > > error : > > > import: unable to open X server `' @ import.c/ImportImageCommand/361. > > > > i am working on ubuntu 10.04 server version > > > And > > ./manage.py runserver > > > Error: No module named messages > > > how handle this error ??? > > For the first I have no idea, never seen it. > > The "No module named messages" error happens when you have a Django project > settings file that was created with Django 1.2 but the Django your > PYTHONPATH is pointing to is 1.1.X or lower. Fix is to fix up your > PYTHONPATH to point to a 1.2 level of Django. > where i check my PYTHONPATH is pointing to 1.2.or lower ?? And i never use Django 1.1 version , i only install 1.2 version with python 2.6 > 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.
Re: import django : error
On Wednesday 23 June 2010 23:30:14 Jagdeep Singh Malhi wrote: > $import django > error : > import: unable to open X server `' @ import.c/ImportImageCommand/361. > > i am working on ubuntu 10.04 server version > you are trying to import from the bash shell - please open a python shell and try the import -- 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.
Re: import django : error
Hi $import django error : import: unable to open X server `' @ import.c/ImportImageCommand/361. i am working on ubuntu 10.04 server versio you're using shell command import, which is for capturing X-windows to images. You should start python shell first, with python command: $python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> Best, Teemu -- 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.