settings file being imported four times
is it normal that the settings file is being imported four times? I'd give more info, but I really have no clue what's going on here's my manage.py: from django.core.management import execute_manager import imp try: imp.find_module('local_settings') # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("""Error: Can't find the file 'local_settings.py' in the directory containing %r. It appears you've customized things. You'll have to run django-admin.py, passing it your settings module. (If the file local_settings.py does indeed exist, it's causing an ImportError somehow.) """ % __file__) sys.exit(1) import local_settings if __name__ == '__main__': execute_manager(local_settings) And I printed a stacktrace at the top of my local_settings file. It does a 'from settings import *' at the top. lacrymology@Roller:boilerplate$ ./manage.py runserver local_settings File "./manage.py", line 15, in import local_settings File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/local_settings.py", line 4, in traceback.print_stack() ### local_settings File "./manage.py", line 18, in execute_manager(local_settings) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command app_name = get_commands()[subcommand] File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands apps = settings.INSTALLED_APPS File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__ self._setup() File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 87, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/../boilerplate/local_settings.py", line 4, in traceback.print_stack() ### No handlers could be found for logger "keyedcache" local_settings File "./manage.py", line 15, in import local_settings File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/local_settings.py", line 4, in traceback.print_stack() ### local_settings File "./manage.py", line 18, in execute_manager(local_settings) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command app_name = get_commands()[subcommand] File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands apps = settings.INSTALLED_APPS File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__ self._setup() File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 87, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/hom
Re: Forms for updating a compound model
I'm sorry to tell you that ModelForms don't seem to have this functionality, but I'm happy to tell you that ModelAdmins do. What it does, basically, is to return this: { 'label': label_for_field(field, self.opts.model, self.opts), 'widget': { 'is_hidden': False }, 'required': False } when there's a field marked as readonly, so it can transparently be used from the templates. I recommend you go look at the code in django.contrib.admin.helpers.InlineAdminFormSet to get a feel of what you can do. Annd... looking around, I found a ReadonlyWidget, look at the first answer here: http://stackoverflow.com/questions/2931884/odd-behavior-in-django-form-readonly-field-widget -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: problem with django model method save()
I don't see why wouldn't your model's .save() work, maybe we'd need to see the model code, but I know you probably want to read this: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/ once you've implemented a ModelForm, you'd pretty much would just do form = RoomForm(request.POST) if form.is_valid(): form.save() On Wed, Jul 4, 2012 at 3:58 PM, rafiee.nima wrote: > Hi Im some how new to django . I write a view to handle ajax request > but I find out that save() method dose not save model instance in to the > database > here is my code > > def add_room(request): > context={} > status='' > if request.is_ajax: > if request.POST: > hotel_instance=Hotel.objects.get(id=request.POST['hotel']) > room_id=int(request.POST['id']) > if room_id > 0 : > room=HotelRoom.objects.get(id=request.POST['id']) > room.hotel=hotel_instance > room.number=request.POST['number'] > room.bed_count=request.POST['bed_count'] > room.ground_sleep=request.POST['ground_sleep'] > room.view=request.POST['view'] > room.reserved=request.POST['reserved'] > room.tv=request.POST['tv'].capitalize() > room.phone=request.POST['phone'] > room.refrigerator=request.POST['refrigerator'] > room.air_condition=request.POST['air_condition'] > room.toilet=request.POST['toilet'] > room.creator=request.user > room.save() > room_json=model_to_dict(room) > status="room successfully updated" > else: > room = HotelRoom( > hotel=hotel_instance, > number=request.POST['number'], > bed_count=request.POST['bed_count'], > ground_sleep=request.POST['ground_sleep'], > view=request.POST['view'], > reserved=request.POST['reserved'], > tv=request.POST['tv'], > phone=request.POST['phone'], > refrigerator=request.POST['refrigerator'], > air_condition=request.POST['air_condition'], > toilet=request.POST['toilet'], > creator=request.user ) > room.save() > status="new room successfully added " > raw_data={'status':status,'data':room_json} > data=simplejson.dumps(raw_data) > return HttpResponse(data, mimetype="application/json") > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/Q3kHTKx-BX4J. > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: install a new model in my project
> (django_multiuploader), and i write in INSTALLED_APPS 'sorl.thumbnail', > 'multiuploader', then i execute manager.py runserver and return "Error: No > module named multiuploader" I dont understand how make a link for this > module. *How* did you install it? are you using pip and a virtualenv? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: migration via south for inheritance change -> please help
You'll have to migrate your data manually in your migration, yes. Besides that, if you don't want actual Base instances, then this is an abstract class, and you should do this: class Base(models.Model): eggs plants class Meta: abstract=True class Foo(Base): carpet= class Bar(Base): car= On Wed, Jul 4, 2012 at 5:18 PM, Lachlan Musicman wrote: > I'd like to know this too - but I think the real answer is "get better > at python" - you are essentially (from what I can tell) in a django > shell when south pops the "not blank, not null but no data" error - > try pulling in some details from fixtures? > > cheers > L. > > On Thu, Jul 5, 2012 at 2:30 AM, Daniel Walz wrote: >> ...no one? >> >> regards, mcJack >> >> 2012/7/2 mcJack : >>> Hi all, >>> >>> I've got a problem migrating some changes in the model, so I tried to solve >>> it with south. >>> The situation: >>> I implemented two classes, which share some functionality. Now that I >>> improved a little with python, django and co. I wanted to use inheritance >>> for that issue. >>> The model looks like this: >>> >>> class Foo(models.Model): >>> eggs = models.TextField( null=True, blank=True ) >>> plants = models.TextField( null=True, blank=True ) >>> carpet = models.IntegerField() >>> >>> class Bar(models.Model): >>> eggs = models.TextField( null=True, blank=True ) >>> plants = models.TextField( null=True, blank=True ) >>> car = models.IntegerField() >>> >>> >>> And obviously I want to transform to: >>> class Base(models.Model): >>> eggs = models.TextField( null=True, blank=True ) >>> plants = models.TextField( null=True, blank=True ) >>> >>> class Foo(models.Model): >>> base = models.OneToOneField( 'Base', parent_link=True ) >>> carpet = models.IntegerField() >>> >>> class Bar(models.Model): >>> base = models.OneToOneField( 'Base', parent_link=True ) >>> car = models.IntegerField() >>> >>> But how can I tell south to fill the super class with the data from the old >>> schema? >>> >>> Can I add this information manually in the created migration script? or is >>> there an option/switch I didn't notice? >>> >>> Any hints are very welcome, thanks a lot >>> >>> mcJack >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/django-users/-/_6CYJ1yqh-sJ. >>> 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. >> >> >> >> -- >> Daniel Walz - mcj...@gmail.com >> Bremen, Germany >> >> -- >> 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. >> > > -- > 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. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: migration via south for inheritance change -> please help
By the way, if you do that, and I'm not crazy, you won't need to do any migration with south, since the Foo and Bar tables would both have all of base's columns (because Base is abstract). If Base can't be abstract (if you want Base instances that are neither Foo nor Bar), then you'll have to do this: First, create the Base class, without changing Foo or Bar. Create a south migration for this Second, create a south Data Migration, copy all the data over on that migration from Foo and Bar to Base instances Third, modify Foo and Bar, and create migrations for this On Wed, Jul 4, 2012 at 5:29 PM, Tomas Neme wrote: > You'll have to migrate your data manually in your migration, yes. > > Besides that, if you don't want actual Base instances, then this is an > abstract class, and you should do this: > > class Base(models.Model): > eggs > plants > class Meta: > abstract=True > > class Foo(Base): > carpet= > > class Bar(Base): > car= > > > On Wed, Jul 4, 2012 at 5:18 PM, Lachlan Musicman > wrote: > > I'd like to know this too - but I think the real answer is "get better > > at python" - you are essentially (from what I can tell) in a django > > shell when south pops the "not blank, not null but no data" error - > > try pulling in some details from fixtures? > > > > cheers > > L. > > > > On Thu, Jul 5, 2012 at 2:30 AM, Daniel Walz wrote: > >> ...no one? > >> > >> regards, mcJack > >> > >> 2012/7/2 mcJack : > >>> Hi all, > >>> > >>> I've got a problem migrating some changes in the model, so I tried to > solve > >>> it with south. > >>> The situation: > >>> I implemented two classes, which share some functionality. Now that I > >>> improved a little with python, django and co. I wanted to use > inheritance > >>> for that issue. > >>> The model looks like this: > >>> > >>> class Foo(models.Model): > >>> eggs = models.TextField( null=True, blank=True ) > >>> plants = models.TextField( null=True, blank=True ) > >>> carpet = models.IntegerField() > >>> > >>> class Bar(models.Model): > >>> eggs = models.TextField( null=True, blank=True ) > >>> plants = models.TextField( null=True, blank=True ) > >>> car = models.IntegerField() > >>> > >>> > >>> And obviously I want to transform to: > >>> class Base(models.Model): > >>> eggs = models.TextField( null=True, blank=True ) > >>> plants = models.TextField( null=True, blank=True ) > >>> > >>> class Foo(models.Model): > >>> base = models.OneToOneField( 'Base', parent_link=True ) > >>> carpet = models.IntegerField() > >>> > >>> class Bar(models.Model): > >>> base = models.OneToOneField( 'Base', parent_link=True ) > >>> car = models.IntegerField() > >>> > >>> But how can I tell south to fill the super class with the data from > the old > >>> schema? > >>> > >>> Can I add this information manually in the created migration script? > or is > >>> there an option/switch I didn't notice? > >>> > >>> Any hints are very welcome, thanks a lot > >>> > >>> mcJack > >>> > >>> -- > >>> You received this message because you are subscribed to the Google > Groups > >>> "Django users" group. > >>> To view this discussion on the web visit > >>> https://groups.google.com/d/msg/django-users/-/_6CYJ1yqh-sJ. > >>> 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. > >> > >> > >> > >> -- > >> Daniel Walz - mcj...@gmail.com > >> Bremen, Germany > >> > >> -- > >> 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
Re: cannot access admin
ah, got it... your url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'), is too permisive On Wed, Jul 4, 2012 at 6:54 PM, Scott Somers wrote: > > /Local Python Source Code/tacobakedotnet > manage.py > settings.py > urls.py > /Local Python Source Code/tacobakedotnet/media > JavaScript files > /Local Python Source Code/tacobakedotnet/dotnet_forms > models.py > tests.py > views.py > /Local Python Source Code/tacobakedotnet/dotnet_forms/static > CSS files > > What it is having a hard time finding is > > So > > http://127.0.0.1:8000/source-code/c++ works > > and http://127.0.0.1:8000/admin/ actually works too > > But when I try and access anything inside the admin I get article not found. > > Now, and this might be interesting if I go > http://127.0.0.1:8000/admin/sfsdfdsfsfd just doing gibberish it gives me the > ArticleNotFound, as opposed to say 404, which it does if you do something > that violates urlconf. So basically the database got corrupted somehow is > that what happened? > > > > On Wednesday, July 4, 2012 2:05:22 PM UTC-4, Melvyn Sopacua wrote: >> >> On 4-7-2012 19:18, Scott Somers wrote: >> >> > My urls >> > >> > urlpatterns = patterns('', >> > (r'^media/(?P.*)$', 'django.views.static.serve', >> > {'document_root': settings.MEDIA_ROOT }), >> > ) >> > >> > urlpatterns += patterns('', >> > url(r'^$', 'tacobakedotnet.dotnet_forms.views.home'), >> > url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'), >> >> It looks like you have the project name in the view, which suggests the >> current working directory of the project is one directory too high. >> Could you show the directory layout, including the location of >> settings.py, admin.py for the app and views.py. >> >> -- >> Melvyn Sopacua >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/Z5X0qegeC44J. > > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: cannot access admin
On Wed, Jul 4, 2012 at 7:33 PM, Tomas Neme wrote: > ah, got it... your > > url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'), > > is too permisive ... maybe? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: migration via south for inheritance change -> please help
I wanted to chang the subject because I didn't want to spam someone's plead for help into a design discussion, but then I thought, how am I gonna make sure this is read by the right people? Also, context would be lost, so.. sorry about this But I don't see how what you say makes sense. I mean, all the way starting from this: > No, you /should/ not. You may do this, but you will end up with two > tables that /do not share the records/. > From the OP's post it's obvious these classes share the data. Think of oh, yeah, completely obvious, of course. It's plain that Foo and Bar are just MEANT to be just subtypes of Base, you can tell just from the names! Sorry, I don't mean to sound cocky, but you're making a hell of an assumption about what Foo and Bar and Base are, here, and *I* and making a completely different, but I think by no means less acceptable one: that he just wants to share his python code. > Base as a table 'fruit' and the other two as apples and oranges. In this > case it doesn't make sense to duplicate the fruit data in the apples and > oranges table. As I said before, the only thing this *really* depends on is in this question: do you need to be able to do something in the lines of: Fruit.objects.all()? And even more so: will you EVER do fruit = Fruit()? If not, there's no difference whatsoever, except you'd be littering the database namespace with a useless table. Very big apps, like, say django-blog-zinnia use abstract classes for the ease of extension and share of information for VERY concrete concepts like EntryBase, which defines all the fields the app uses in it's views, so a user can define their own Entry(EntryBase) class. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ForeignKey on CharField and char operations
I might not be understanding this fully, but what about A.objects.filter(type__mnemo__startswith="type1")? On Thu, Jul 5, 2012 at 7:51 AM, Serg Shtripling wrote: > Hello, community! > Have anyone tried this: > class AType(models.Model): > #cut > mnemo = models.CharField(u'Mnemocode', max_length=31, null=True, > unique=True) > > class A(models.Model): > #cut > type = models.ForeignKey(AType, 'mnemo', verbose_name=u'A Type', > null=True) > > class B(models.Model): > #cut > type_mnemo = models.CharField(u'A Type', max_length=31, null=True, > blank=True) > Mnemos = {type1, type1__plus, type1__minus, type2, type2__plus,} > Now I want to get all A records, having AType starts with "type1", eg: > "type1,type1__plus, type1__minus" > > r = A.objects.filter(type_id__startswith='type1') > And got: > TypeError: Related Field has invalid lookup: startswith > As a workaround, I've replaced A model with B model - I do not have a > relation, but query works as expected. > Q: 1)Is it OK, that A.type_id, not just A.type field is a Related Field? > q=AType.objects.all()[0] type(q.type) > type(q.type_id) > > 2) Is there a more correct way to solve this issue? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/aV3iT_l4v1kJ. > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: migration via south for inheritance change -> please help
> Not really. But from the question: > "But how can I tell south to fill the super class with the data from the > old schema?" Well, in aswer to this, and Tom's remarks, you assumed he wanted to have a new table because he was asking how to populate it, I assumed he maybe doesn't know about abstract models because he said he's just getting started programming (or at least on py/dj) and maybe he wasn't sure what behavior he needed, and what were his options. I *do* start saying "if you don't want Base instances". and from Tom's: > In the example, it is evident that the OP wants MTI, since he includes > the foreign key links in the class definition - there is no clearer > indicator than this! The evidency of this gets flimsy, AFAICS, if you take in consideration that he's refactoring code, and having two separate tables was good enough for him until he "got a little better with python and django". So, yes, this goes down, I think, if at any point he has a view where he joins both groups of objects. > And you're spreading records over two different tables and making it > impossible to enforce uniqueness on shared attributes. So it's not just > about creating an instance. tru dat.. And yeah, the holy war wouldn't be on inheritance types, but rather on reading comprehension, it seems ;) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ForeignKey on CharField and char operations
> Wouldn't it create INNER JOIN query on a_type table? AFAIR it would and it's > a bit overhead. > But surely it is a better solution than mine one, thanks for that. Well, in that case, I think your problem is that your AType PK isn't the mnemo field, but some integer field, so type_id is integer, not string. Try defining it as mnemo = models.CharField(u'Mnemocode', max_length=31, null=True, unique=True, primary_key=True) but I'm not sure if this is the behavior you want -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ForeignKey problem
> But! I do have another problem. Lets ditch our football example. Let's say > that I have something like that: > > class CherryTree(models.Model): > name = models.IntegerField() > cherries = models.ManyToManyField('CherryFruit') > > class CherryFruit(models.Model): > name = models.CharField(max_length=50) > > More or less. The point is, I want to ass many CherryFruit to one > CherryTree. How do I pass the additional information? I suspect this can > have something to do with the 'through' argument, but I'm probably > completely wrong. Or do I have to create additional Model, like: > > class CherriesOnTree(models.Model): > name = models.ForeignKey('CherryFruit') > tree = models.ForeignKey('CherryTree') > amount = models.IntegerField() > > and add each fruit separately? Hope It's clear what I mean :). well, no, no and no, but interesting anyways. A tree and it's fruit is the same as a team and it's players. You'd do class CherryTree(models.Model): name = models.IntegerField() class CherryFruit(models.Model): tree = models.ForeignKey(CherryTree) name = models.CharField(max_length=50) because each cherry belongs to a single tree. You can think of it as a parent-child relationship, the children are the ones that have the ForeignKey. The "through" parameter in a many to many just defines the name of the table to be used for that "CherriesOnTree" model you put there, which you wouldn't need to define. Also, the "amount" field would be of no point, would it? then you would do this: # create a new tree my_tree = Tree("Tree on the corner") # or maybe get a tree from the database my_tree = Tree.objects.get(name="Tree on the corner") # create a new cherry for this tree cherry = Cherry(tree=my_tree, name="Some Cherry Name") cherry.save() ## or if you don't need to do anything afterwards, you can simply Cherry(tree=my_tree, name="Some Cherry Name").save() a many-to-many would be used, for example, in a classes and students scenario Each student goes to many classes, each class has many students, so: class Class(models.Model): name = models.CharField(max_length=50) class Student(models.Model): name = models.CharField(max_length=50) classes = models.ManyToManyField(Class) # create class math = Class(name="Math") math.save() # create student student = Student(name="Charles") student.save() # need to save before setting up many to manies # Charles goes to Math class student.classes.add(math) Here an extra table will be created to hold the many-to-many relationships. I think it's called _class_m2m_student, or something like that. The through class is used if you want to add some extra data, like for example, where does a student seat in a particular class, or what other students he's in groups with in there, see https://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany for more details -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: install a new model in my project
> I used pip for install sorl.thumbnail but "multiuploader" it isn't in > the pip's repo well, HOW did you install it? you can still tell pip to use a git or mercurial repository, or a tarbal file, for example (virtualenv) $ pip install git+git:// github.com/Lacrymology/cmsplugin_s3slider.git#egg=cmsplugin-s3slider will install a cms plugin I forked that uses the s3 javascript slider for image galleries in your virtualenv But anyways, how *did* you install it? your issue is that your python interpreter is not finding the package -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ForeignKey problem
> I don't understand. It's the same wheel added four times, not four > different wheels. I guess you could implement it either way. The thing is that doing it this way would become complicated at the time you need to define what is attached where. For Lego pieces, I'd do this: class LegoType(Model) has a description, maybe a picture, and it's behavior model LegoPiece has a ForeignKey(LegoType), a ManyToMany to other LegoPieces (the ones it's connected to). You'd have one LegoType = wheel, and four LegoPiece who's type would be wheel. When you defined the Type you'd need a way to link each model to specific python code that controlled how many pieces it can connect to, and how, but that's a song for another day. Then you do LegoPiece.objects.filter(type__name="wheel").count(), and voila, you have how many wheels you have. You COULD have enough knowing the amount of pieces of each kind you have, you'd be modeling something similar to an inventory, but defining connections in that context would be unnecessarily complicated, since you'd not only have to count how many pieces you have of each type, but when you connect one to another, *which one* are you connecting? one that's free, or one that's connected to another one? How would you model the connections? Say one brick can connect to as many as 8 other pieces, 4 on each side, say you have 3 bricks, so you know you can't have more than 24 connecctions, but.. how do you differentiate between A--B C--D--E and A--B--C--D or.. I don't know how to draw it, but D--A--B D--A--C (A is connected to D on one side, and to B and C both on the other). It might be that you can model your needs this way, but AFAICS, it'd be a lot harder to follow things and keep things consistent in an Object Oriented way. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ForeignKey problem
> Thanks, but damn, isn't that overly complicated (for me). Using through > looks like a easier way, but then I have to add Wheel four times and can't > just type '4' in some field, since I don't need it to exist in database four > time, just an information that there are four wheels. as I said, it depends on what you want. If you want an inventory (different types of blocks, and how many you have of each) then it's good enough that way. If you want to model actually building stuff with legos, it might not be enough, that's all I'm saying. For an inventory I'd do this: class LegoPiece(Model) has it's data, plus an IntegerField, total amount.. As I said before, with your car example.. if you just want to know how many of a part are in a car, Then what you did is enough, then you could have some cars, and some pieces, say Cars = (Motorcycle, 4x4, Car) Parts = (Tire, Transmission, Door) PartsInCar = ((Motorcycle, Tire, 2),(Motorcycle, Transmission, 1), (4x4, Tire, 4), (4x4, Transmission, 2), (4x4, Door, 2), (Car, Tire, 4), (Car, Transmission, 1), (Car, Door, 4)) This would achieve a description of how may parts you need to make a given car.. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ForeignKey problem
oh, and the advantage is that you could have a car, for example car = Car.objects.get(name="4x4") car.parts.get(name="Transmission").partsincar.amount >> 2 The difference with doing it with another model is that you cannot do this, for example (or not as easily) Car.objects.filter(parts__name="Transmission", partsincar__amount=1) >> Motorcycle + Car -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Returning nothing from a view
Just return an empty response, with a 200 OK code: return HttpResponse("") I'm not sure whether you can omit the "" On Fri, Jul 6, 2012 at 5:44 PM, Larry Martell wrote: > I have a situation where I'm sending an ajax request to a function > that updates a row in database. I then want to return control to the > browser, with no changes to the page that was up. I am not returning > anything from the function, and it's working the way I want, however I > get an error in the browser's console: > > Failed to load resource: the server responded with a status of 500 > (INTERNAL SERVER ERROR) > > > Is there some was to avoid 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-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. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: migration via south for inheritance change -> please help
> The big difference is, -as I see it- I will not get real polymorphism, > as the base class would need to do the join on all it's child classes. > Is that true? with abstract models you won't get polymorphism at all, in the database level (this is, you WON'T be able to do Fruit.objects). You'll mostly just be sharing structure and behavior, saving yourself some repetition. With multi table inheritane (MTI) you get three tables, one for Fruits one for Oranges and one for Apples, Fruits have a row for every Orange and every Apple, so you can do Fruit.objects.all(). Knowing whether this is an orange or an apple is trickier, but not too much -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: migration via south for inheritance change -> please help
> and I do > for fruit in Fruits.objects.all(): fruit.rott() > > will anything happen at all? I know in C++ this would work... ;-) > > on database-level I know how to do it, I just don't know if the django > abstraction handles this automalically. I.. don't know. I'd think yes, at least I wonder otherwise how does the DB keep coherent if you do BaseModel.objects.filter(foo=bar).delete(). "CASCADE" would deal with it in PG, but mysql sometimes lacks that, and sqlite doesn't handle foreign keys at all. but you probably need to make some tests to make sure. It'd be quite easy to do it from the shell > Seems I have too little faith in the capabilities of python ;-) Yah, and about that.. what you said WOULD work for any Objects of a subclassed class in python, as it would in C. Actually, since you don't declare types in python, you don't really know the class of your parameters unless you ask, it is the concept of duck-typing that gets used strongliest in python (you ask the parameter to respond to a certain interface, you don't care what type it is). The question is not whether python is able to know what the real class of an object is, but rather whether django knows the real model of an object it got from a supermodel's table. my_fruit.apple returns the corresponding Apple instance, and my_fruit.orange returns the corresponding Orange instance, but if you call my_fruit.orange on an object that actually represents an Apple, you'll get an Orange.DoesNotExist exception raised. But this behavior is lazy (the Orange table doesn't get hit in the database until you do .orange). -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Problem with DetailView
> Turns out that's the problem. I wanted to use a field from my Car model: > car_id, so the link on the website would look like: > www.blablabla.com/cars/3421, where 3421 is the car_id. Unfortunately, the > car_id is not the same as . Can I achieve something like that with class what's car_id and why isn't it your PK? you should post your full models when asking for help, in general. As a general rule, having a car_id field in a Car model is unnecessary. Models come with ids of their own by default, you don't need to define them. If you have IDs of your own that you want to reflect in your database, first of all, I'd call it just "id", so you can do my_car.id, my_car.car_id sounds a little bit redundant to my taste, and secondly, you can define it as id = models.IntegerField(primary_key=True). If you do that, your pk will be the ID you defined (you can do this with a CharField as well, I think) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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:
Are you importing your listeners.py from anywhere? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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:
> No, I'm not. I didn't think I need to... the only things that are automatically included are your settings file, your site urls file, and your apps' models file, everything else depends on you (or them) to include them. For example, if you don't call admin.autodiscover() sometime soon (your site's urls file is about the soonest it makes sense to do this, and where it's usually done), your ModelAdmins won't get registered. Likewise, unless you include the call to signal.register() (or in your case the @listener decorator), then your listener never gets registered in the signal. The signal itself is working because you included it from your models file in order to .send() it I don't know exactly why is it working from the shell, I'm guessing you included something more when you were fiddling in it, that got it included. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Problem with DetailView
Man... > (r'^sets/(?P\d+)/$', SetDetailView.as_view( > model=Set, > context_object_name="set_details", > template_name='data/set_details.html', > )), > > But the site is empty. Here's my extremely simple template: > > {% block title %}{{ set.text_name }}{% endblock %} > > {% block content %} > Set: > > {{ set.theme }} - {{ set.subtheme }} > {% endblock %} and where, pray, would that 'set' variable be populated when you very explicitly told the DetailView you wanted your context object named 'set_details'? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: urlpatterns
Django isn't able to guess you want your polls urls under a /poll/ path. To achieve this, you do url inclusion you define something like polls/urls.py like you did and then do url(r'^polls/', include('polls.urls')) then your defined urls will work when prepended with a polls/ path. You can change that polls to foo, and then the same views will work under 'foo/' path (localhost:8000/foo/1/results will show the results for poll#1 and so on) On Sun, Jul 8, 2012 at 3:21 PM, Seyfullah Tıkıç wrote: > Yes, in tutorial it is said to be done so. I expect it works as follows, > after the commented lines. > urlpatterns = patterns('', > url(r'^$', > ListView.as_view( > queryset=Poll.objects.order_by('-pub_date')[:5], > context_object_name='latest_poll_list', > template_name='polls/index.html')), > url(r'^(?P\d+)/$', > DetailView.as_view( > model=Poll, > template_name='polls/detail.html')), > url(r'^(?P\d+)/results/$', > DetailView.as_view( > model=Poll, > template_name='polls/results.html'), > name='poll_results'), > url(r'^(?P\d+)/vote/$', 'polls.views.vote'), > ) > urlpatterns += patterns('', > url(r'^admin/', include(admin.site.urls)), > > 2012/7/8 Mario Gudelj >> >> But you've commented out all your URLs that start with /polls/, like >> url(r'^polls/$', 'index')... r'^polls/$' will resolve to >> http://127.0.0.1:8000/polls/, for example. >> >> -m >> >> >> On 8 July 2012 23:01, Seyfullah Tıkıç wrote: >>> >>> http://127.0.0.1:8000/polls/34/ >>> http://127.0.0.1:8000/polls/ >>> http://127.0.0.1:8000/polls/34/results/ >>> 2012/7/8 Mario Gudelj Which url are you trying to access when you get that 404? On Jul 8, 2012 5:36 PM, "Seyfullah Tıkıç" wrote: -- 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. >>> >>> >>> >>> >>> -- >>> SEYFULLAH TIKIÇ >>> >>> -- >>> 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. >> >> >> -- >> 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. > > > > > -- > SEYFULLAH TIKIÇ > > -- > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Model for ListView needed?
> A queryset returns a /list/ of model instances. Thus you should queryset > when you want more then one instance of the model displayed. well, slightly wrong, let's clarify. While it's true a queryset represents a list of model instances (it's not EXACTLY that, it's, more like, a partially set up query that only gets ran when you actually request the objects), in GenericViews the difference between setting up a model and a queryset is that setting up model=Post is the same as setting up queryset=Post.objects.all(). So if you want your view to act upon ALL Post instances, and you don't care about ordering, then you can do model=Post and save yourself some typing. If, however, you want your view to act upon only a SUBSET of objects, you can use queryset. If, for example, you are making a list of books made by a specific author, you can do this: url(r'^books/shakespeare/$', ListView.as_view(queryset=Book.objects.filter(author='shakespeare')),... (of course, this isn't the best example, since it'd be much smarter to make a more specific view that filters authors by a parameter, something like (r'books/(P\w+)/$')), but it serves as example) In the docs' example, the queryset= parameter is used, because they want the view to show only the latest 5 Polls, hence the queryset=Poll.objects.order_by('-pub_date')[:5]. If you wanted ALL, but ordered by -pub_date (and this wasn't the default ordering for the model), you would use the same queryset, but leaving out the [:5] part. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Model for ListView needed?
Oh, and setting up a queryset in a DetailView means that it won't work for instances that are not inside the queryset, if we did url(r'/books/shakespeare/(P\d+)/$', queryset=Book.objects.filter(author='shakespeare')), then /books/shakespeare/1/ would work if the book with pk=1 was Romeo and Juliet, but it wouldn't if it was Crime and Punishment (Fedor Dostoievsky) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Adding a custom validation to Django's auth_user in admin
> Ah. I think the method is overriding the edit page. In other words, you have > click on the editpage to see the effect of my fail code. So it doesn't > trigger if you are on the list view page. Does anyone know what to do with > the editable submission? > It should use the same clean_ method, shouldn't it?? if you want this validation everywhere you should probably do something in the model's .save() method, or even better (to avoid monkey patching) register into the pre_save signal -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: masking only a small part of a template
http://djangosnippets.org/snippets/1376/ this is what you want, I'm using it and it works like a charm you override in templates/path/to/template.html and do {% extends "app:path/to/template.html" %}, and this loader searches in `app`'s template dir by default On Mon, Jul 9, 2012 at 3:06 AM, tWoolie wrote: > Sorry, I should have been clearer. What I have is an external project that > is included "as-is". It has it's templates and it's views are hardcoded > against the template names. > I want to know if it's possible to create a template called, say, > "app/dashboard.html" in the global template dir that then extends > "app/dashboard.html" in the app's template directory, thereby allowing me to > change ONLY the block I need to change, without requiring me to copy-paste > the entire template and re-edit every time I update that app. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/G2ExbPmO4e0J. > > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: rendering modelForms
There's a way, but you'll need to touch the form on the python side quite a lot, changing the default widgets adding them the css classes you want. You can take a look at https://github.com/earle/django-bootstrap and https://github.com/dyve/django-bootstrap-toolkit/ they provide some shortcuts for this -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: getting variable from __init__ into clean_xxx function
also this: http://docs.python.org/tutorial/classes.html On Wed, Jul 11, 2012 at 12:58 PM, Nikolas Stevenson-Molnar wrote: > Change nbi_patch to self.nbi_patch, and you should be set. I.e: > > > class PatchForm1(forms.Form): > def __init__(self, *args, **kwargs): > self.nbi_patch = kwargs.pop('nbi_patch', None) > ... > > def clean_release_number(self): > self.nbi_patch #use however you want here > > _Nik > > > On 7/11/2012 8:06 AM, Leandro Alves wrote: > > Hi, > > I'm sending a variable from my views.py and getting it in my forms.py. > > My form looks like this now: > > class PatchForm1(forms.Form): > def __init__(self, *args, **kwargs): > nbi_patch = kwargs.pop('nbi_patch', None) > super(PatchForm1, self).__init__(*args, **kwargs) > > release_number = forms.CharField(label='Release number:') > > def clean_release_number(self): > #nbi_patch = I want to use the nbi_patch var from __init__ here > release_number = self.cleaned_data.get("release_number") > path = os.path.join(nbi_patch, release_number) > if not os.path.exists(path): > raise forms.ValidationError("Hmm... it looks like %s does not > exist in nbi-patch." % release_number ) > return release_number > > I want to use my var nbi_patch from __init__ inside my > clean_release_number() function. Is that possible? > > I tried pass it as a parameter but it didn't work... > > Thanks!!! > > Leandro > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/90_l6B36fHsJ. > 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. > > > > -- > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Error in blog
Have you done the django tutorial, first? it covers named urls On Thu, Jul 12, 2012 at 11:06 AM, luthur wrote: > why not post your example? It's too abstract. > > -- > luthur > > On Thursday, July 12, 2012 at 9:56 PM, jun wrote: > > > > On Thursday, July 12, 2012 7:40:46 PM UTC+8, lawgon wrote: > > On Wed, 2012-07-11 at 23:29 -0700, jun wrote: >> I was trying out the blog example in Django by Example but ran into >> this error: >> Reverse for 'blog_post_add' with arguments '()' and keyword arguments '{}' >> not found. >> >> I think it has something to do with the urlpatterns since there is >> no /blog/post/add configuration there, and tried a few variations but >> nothing worked. >> >> What should I do next? Any django docs I can refer to, as in how to >> link the blog_post_add with the main url? > > what version of django are you using - is it the same version that is > being used in the example? > -- > regards > Kenneth Gonsalves > > Hi I'm using Django 1.4 now. Understand that the example is using 1.2. Would > this have an effect? > > Regards, > jun > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/Ox4KIBiwce8J. > 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. > > > -- > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: django-admin.py makemessages issue
"django-admin.py makemessages -l de" "django-admin.py makemessages -l es" On Thu, Jul 12, 2012 at 2:59 PM, Phil wrote: > Hi, > > (django version 1.3.1, Python2.7) > > (at the end of my settings file) > > # translation support > ugettext = lambda s: s > > LANGUAGES = ( > ('en', ugettext('English')), > ('es', ugettext('Spanish')), > ('de', ugettext('German')), > ) > > LOCALE_PATHS = ( > '/home/phil/project/locale', > ) > > > I am implementing languages into my django website. It's working fine but > when I run "django-admin.py makemessages" on the command line it gives the > following error > > "Error: This script should be run from the Django SVN tree or your project > or app tree. If you did indeed run it from the SVN checkout or your project > or application, maybe you are just missing the conf/locale (in the django > tree) or locale (for project and application) directory? It is not created > automatically, you have to create it by hand if you want to enable i18n for > your project or application." > > So like it says, I create the "locale" folder manually then(it's in the root > of my project directory) run makemessages again but I just get another error > saying... > > "Error: Type 'django-admin.py help makemessages' for usage information." > > Any idea's where I could be going wrong? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/IukJjVtKua4J. > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Tasking? A fluid user experience with Uploading Media.
Well, first of all, you're gonna have to set up quite a big amount of parallel connections for this to work, > A new user could be uploading media/music files or something at the same > time as uploading a video of themselves. I want it to be efficient and fast > to the point where it all gets updated but the user can leave this task > going and leave the page that is updating the file and just check back in Well, this whole part, I don't see happening, because you need to have some application on the client side sending the data, this is usually the browser, which unless it stays on the sending page, will close all outstanding connections to your server. You'd need a client-side application for something like this to work, like Picasa and Dropbox do. I also would recommend against letting users upload more than one file at any given time, because multiple files per client means multiple connections. Of course, you could add a "send file" link that actually only adds stuff to a queue, but again, this will always depend on the browser page not being closed, or changed, not even refreshed, I've seen this worked-around with popups (have the popup window handle the connection, so the user can keep browsing on his main window, but he cannot close the popup, in that case). As for the actual solution tools for your problem, I don't know them, but I do know enough to just mark that thing up there -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ajax loading html
an "html page" can't be located within the templates directory, an HTML file might, but what is it you want to do, exactly? you want to render a static file? does it make sense going through django for this? URLs point to views, not templates, the views are which decide what templates to use (the same view could use different templates in case there's errors, or depending on whether the user is logged in or not, for example). In any case, you should set up an URL to make your ajax call to, if you want to go through django for this, something like url(r'path/to/tip/$', TemplateView.as_view(template="path/to/template.html"), name="ajax_tooltip") docs on the matter of TemplateViews: https://docs.djangoproject.com/en/dev/ref/class-based-views/base/#django.views.generic.base.TemplateView If you don't want to write an url for this, then you don't want to handle it through django. If that's the case, as someone explained, you can just put the html file somewhere OFF your templates directory, and have your webserver (apache, or nginx, or whatever you're using) serve that url by itself (you'll still have to set up the URL in the webserver's config files) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ajax loading html
On Sat, Jul 14, 2012 at 2:11 PM, ledzgio wrote: > If I use the TemplateViews method, should I have to set anything on the > views.py? and how can I point that file from template? the TemplateView is a view, it's already been written for you, so you can use it without adding anything new. If you want to add some custom behavior to it, you can subclass it, or skip it completely and make a new view, either out of mixin classes, or function-based (though that method's being deprecated in the future). That you'd usually do in your views.py file (bearing in mind that it's not mandatory that it's called that, it's just a convention), but for this case (at least as far as you've described it) I don't think you need any specific behavior. And how can you point what file from which template? That being said: My real recommendation would be go do the tutorial and understand the concepts. Then go read about Class-based views, and understand all that on a conceptual level, as well. I.. don't mean to sound harsh, but all your questions and the place they seem to point to give out a feeling that you're not really understanding django and it's underlying concepts, it'll be very hard for you to ask the right questions unless you figure it out first, and even harder for us to answer them. A template is just some text that can be mixed with some programming structures (loops, ifs, and other template tags and filters) and variables. The HTML you actually send the client could be (and usually is) built from a mixture of a number of different templates, so you should get yourself rid of that concept of "HTML page" = "template file" you seem to be carrying. At this point, I think the best thing you could do is be a little more explicit, tell us what you're trying to do, possibly paste some models and urls files -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: satchmo and django-admin-tools
Yes, you'll need to get your hands dirty, and merge the two admin templates, since both apps redefine templates/admin/index.html and some other templates. The best approach, I think, is just use django-admin-tools' templates and create custom dashboard/modules to duplicate satchmo's templates' behavior On Sun, Jul 15, 2012 at 7:12 PM, אברהם סרור wrote: > Hi, > > I'm trying to use django admin tools with satchmo, I installed satchmo in my > dev machine and made a store with clonesatchmo.py > after that the store seemed to be running fine, so I installed > django-admin-tools using the instructions on their website > > but I didn't manage to make it work, I spent about a week googling, I think > I must be doing some obvious mistake > > anyone had success using both together? where can I see an example > settings.py? > > Also I have in mind grappelli, can the three work together? > > any help is appreciated > thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/PyVTP5tNkqMJ. > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Is Tutorial / Part 4 wrong? (or is it me?)
It's the second time this issue appears in the list in two weeks, maybe it's time to recheck the tutorial? There's no "polls" in your results' url, doesn't the tutorial say you should have two urls file? one in project/urls.py and another one in polls/urls.py ? the polls-specific urls shouldn't start with "^polls/" and be in polls/urls.py, and in project/urls.py there should be a line with url(r'^polls/', include('polls.urls')), On Mon, Jul 16, 2012 at 1:59 PM, Bill Torcaso wrote: > > Django is great, and the tutorial is great. I'm having a problem at the > very end of tutorial-4. > > I try to use generic views, and I get an error when I Redirect from the > POST request in vote() to the Results page. Details below. > > The tutorial code says to put this in my urls.py: > > url(r'^(?P\d+)/results/$', > DetailView.as_view( > model=Poll, > template_name='polls/results.html') > ,name="poll_results" > ), > > And this in my views.py: > > from django.shortcuts import get_object_or_404, render_to_response > from django.http import HttpResponseRedirect, HttpResponse > from django.core.urlresolvers import reverse > from django.template import RequestContext > from polls.models import Choice, Poll > > > def vote(request, poll_id): > p = get_object_or_404(Poll, pk=poll_id) > try: > selected_choice = p.choice_set.get(pk=request.POST['choice']) > except (KeyError, Choice.DoesNotExist): > # Redisplay the poll voting form. > return render_to_response('polls/detail.html', { > 'poll': p, > 'error_message': "You didn't select a choice.", > }, context_instance=RequestContext(request)) > else: > selected_choice.votes += 1 > selected_choice.save() > # Always return an HttpResponseRedirect after successfully dealing > # with POST data. This prevents data from being posted twice if a > # user hits the Back button. > > > > return HttpResponseRedirect(reverse('polls_results', args=(p.id > ,))) > ### OKAY:return HttpResponseRedirect("/polls/%i/results" % > p.id) > ### OKAY:return render_to_response("polls/results.html", > {"poll": p}) > ### BAD: return > HttpResponseRedirect(reverse('polls.views.results', args=(p.id,))) > > > > NoReverseMatch at /polls/4/vote/ > > Reverse for 'polls_results' with arguments '(4,)' and keyword arguments > '{}' not found. > > *Request Method:* > > POST > > *Request URL:* > > http://127.0.0.1:8000/polls/4/vote/ > > *Django Version:* > > 1.4 > > *Exception Type:* > > NoReverseMatch > > *Exception Value:* > > Reverse for 'polls_results' with arguments '(4,)' and keyword arguments > '{}' not found. > > *Exception Location:* > > /Library/Python/2.7/site-packages/django/core/urlresolvers.py in > _reverse_with_prefix, line 407 > > *Python Executable:* > > /usr/bin/python > > *Python Version:* > > 2.7.1 > > *Python Path:* > > ['/Users/s3/Desktop/CODE/APPSS3/EdAssistant/experiments/djtest', > > > > '/Library/Python/2.7/site-packages/mercurial-2.0.2-py2.7-macosx-10.7-intel.egg', > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', > > > > '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', > > '/Library/Python/2.7/site-packages'] > > *Server time:* > > Mon, 16 Jul 2012 11:53:21 -0500 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/f-sjN1OtNuwJ. > 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. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, s
Re: satchmo and django-admin-tools
> I thought they extended the templates instead of trying to replace > everything they don't replace everything. But the admin site's index template is called 'admin/index.html', so it's not easy to extend them. They DO extend admin/base.html. This is my dashboard.py file, where I create a module that emulates satchmo's template additions. https://gist.github.com/3124534 There's a couple of things that are MY PREFERENCES, so it might not all be to your liking, please do try to read, understand, and modify as you like. with this, I just use dashboards' admin/index.html template -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: satchmo and django-admin-tools
> thanks for sharing, I'll try to understand it. > > where should I put this file? inside localsite? > > what admin template are you talking about? the admin tools or the plain > admin? dashboard's (it's part of admin_tools) admin/index template. > I thought of using the admin tools templates and building from that, but all > I got was noReverseMatch erros, looks like the INSTALLED_APPS order is > significative and I don't understand it well. well, I should probably just point you to this: http://django-admin-tools.readthedocs.org/en/latest/index.html and specifically this: http://django-admin-tools.readthedocs.org/en/latest/quickstart.html You probably didn't add dashboard to INSTALLED_APPS and you're probably missing the urls as well. > how can I configure it to ignore the satchmo admin templates? and some of django's documentation as well.. https://docs.djangoproject.com/en/dev/ref/templates/api/#loading-templates The short version is, usually, you put under yourproject/templates/admin/index.html whatever template you want to be used, but do go and read those docs > btw, could I make all this work with grappelli? it seems I could enjoy some > of the image uploading and wysiwyg editor you can most probably make everything work with everything, I don't know what grappelli is, bear in mind you might need to dig deep in the admin templates to make javascript (specially jquery) play nice with every app you use -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Directory indexes are not allowed here. for Grappilli
On Mon, Jul 16, 2012 at 2:56 PM, Dott. Tegagni Alessandro wrote: > > write the urls.py code and var. static in settings.py, please. do as he says. Also you could try asking the grapelli user group, if there is one, this seems to be specific -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Tutorial question
> Do these just get stuck onto the end of my class Poll(models.Model):? like > this... Yes, that's right perhaps you should start here: http://docs.python.org/tutorial/classes.html you should probably at least be comfortable enough with python to know how to define classes before diving into django -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Prepopulating a contact form
user = request.user initial = {} if user.is_authenticated: initial.update({ 'name': user.name, 'email_address': user.email_address }) form = MyContactForm(initial=initial) On Wed, Jul 18, 2012 at 11:23 AM, Sithembewena Lloyd Dube wrote: > Hi everyone, > > I have a contact form in my app and would like to prepopulate it with user > details where a user is logged in. Basically, I do the following: > > reg_user = get_registered_user(request) > # get my form object > > > I would like to do something like: > if reg_user: > my_form.name = reg_user.name > my_form.email_address = reg_user.email_address > # and so on ... > > Any ideas? Thanks ... > > -- > Regards, > Sithembewena Lloyd Dube > > -- > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: one field of modelForm doesn't being displayed
> You could override your ModelForm's save() method to save some data to that > field. And then modify the same ModelForm to exclude that field. For example, or maybe, just maybe, he might show us his model, form, and rendered html so we can actually help him identify and possibly fix his problem! ;) I mean, perhaps he wants to be able to fill that field as well? But unless we know the type and the output, we won't be able to help you -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Query with 3 models
> {Empresa1, Sucursal1, Platillo1, Horario1}, > {Empresa1, Sucursal1, Platillo2, Horario1}, > {Empresa2, Sucursal1, Platillo1, Horario1}... I'm guessing the Sucursal1 in the first and third lines are not the same? I mean, each Sucursal points to only one Empresa, so I'm guessing you want only the related objects if this is the case, you can do something like this: [(empresa, sucursal, platillo, horario) for empresa in Empresa.objects.all().select_related() for sucursal in empresa.sucursal_set.all() for platillo in empresa.platillo_set.all() for horario in empresa.horario_set.all()] that if what you want is a list. If you want just to loop through those, you can do for empresa in Empresa.objects.all().select_related(): for sucursal in empresa.sucursal_set.all(): for platillo in empresa.platillo_set.all(): for horario in empresa.horario_set.all(): do_something(empresa, sucursal, platillo, horario) and about the same thing if you want to cycle through them in a template, in which case you can just pass { 'empresas': Empresa.objects.all().select_related() } and then loop like above on the template side -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Can a method call inside save() display its return on template?
> In my models.py I override the save method like this: > > def save(self, *args, **kwargs): > self.directiondb = get_direction_db(self.nod_id1.id, > self.nod_id2.id) > get_direction_descr(self.nod_id1.id, self.nod_id2.id) > get_vrd_code(self.nod_id1.id, self.nod_id2.id) > self.vrd_id = get_vrd_id(self.nod_id1.id, self.nod_id2.id) > super(Webrequests, self).save(*args, **kwargs) > > and it works fine. > Is it now possible what get_direction_descr() and get_vrd_code() return to well, what does get_vrd_code do? why aren't you saving the value anywhere? same question with get_direction_descr. The easy answer will be: self.vrd_code = get_vrd_code(self.nod_id1.id, self.nod_id2.id) and then use that on the template, but that save() method seems awfully redundant, so.. can you explain what your model does better? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Query with 3 models
> Thanks, the first example is exactly that i want. I try it in the Django > Shell and it works, but; How I show the results in the template? > > Maybe I'm wrong, but I try to pass like { 'empresas': > Empresa.objects.all().select_related() } ,and only can show the 'Empresa' > attributes on the loop. > > I do something like this > > {% for a in empresa%} > a.slogan > a.descripcion > a.platillo.fotografia > {% endfor %} as I said, you need to do a loop like the one I showed in python, but in the template say, for example {% for empresa in empresas %} {# keeping your plurals straight is good practice! #} {% for sucursal in empresa.sucursal_set.all %} {% for platillo in empresa.platillo_set.all %} {% for horario in empresa.horario_set.all %} empresa.slogan empresa.descripcion platillo.fotografia horario.foobar {% endfor %} {% endfor %} {% endfor %} {% endfor %} -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Can a method call inside save() display its return on template?
You can still do self.something = foobar even if "something" is not a database Field. What I mean is, doing self.vdr_code = get_vdr_code() will save it for THIS INSTANCE and then you can use it in your template. If you really need this to be only at .save() (instead of, say, at __init__, because it feels like once the object's been saved this could be get in object initialization), you just have to make sure this is the same instance you pass to the template context. Something like: myobject.save() . render_to_response(template, { 'object': myobject }) then in your template you can do {{ object.vdr_code }} Although all in all, I *really* hope you have a good reason to use db backend-specific SQL instead of making a django model of those DirectionDescr whatever they are --- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Boolean always returns False?
why do you have your own User model? Are you sure you're logging in the right user and loading the right user instance? On Fri, Jul 20, 2012 at 12:37 PM, Sithembewena Lloyd Dube wrote: > Hi everyone, > > I have a user model in which i have a newsletter boolean field. When the > user subscribes to a newsletter, this is checked. > I am then instantiating that user and checking the property, so that if it > is False (i.e. unchecked) = I can display a subscription box. > > In the model: > newsletter = models.BooleanField(verbose_name=u'Sign up to the newsletter', > default=False) > > .. and in the view: > print registered_user.newsletter > > The print outputs False even though this same user's 'newsletter' field > appears checked in the admin. What am I missing? > > Thanks. > > -- > Regards, > Sithembewena Lloyd Dube > > -- > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How is the label_tag's attrs parameter supposed to specified?
{% for field in form %} {{ field.label }}{{ field }} {% endfor %} although I think the custom form class is not such a bad solution -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How To Display Non-Modal Popup From Resulting Asynchronous Javascript Request
your error's got nothing to do with AJAX. As the very helpful error message you're getting, there's no URL that matches your requested path: > Request URL: > > http://127.0.0.1:8000/mediahelp/mediaHelpPopup.html > > Using the URLconf defined in streamingmedia.urls, Django tried these URL > patterns, in this order: > 1.^mymedia/ > 2.^mediaadmin/ > 3.^mediahelp/ ^$ > 4.^mediahelp/ ^comphelp/$ > 5.^admin/ I don't know where did you get the 'mediaHelpPopup.html' part of your URL, but it's quite clear it doesn't match any of those urls you've got set up. So if you give us some more details on your idea for this popup, where does the data come from, and why do you feel the need to make a call to some phantom html file (https://docs.djangoproject.com/en/1.4/topics/http/urls/, and especially http://www.w3.org/Provider/Style/URI). Basically, you need to have a view that renders your popup's HTML, and that view needs to be linked to an URL. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How To Display Non-Modal Popup From Resulting Asynchronous Javascript Request
> The current URL, mediahelp/comphelp/mediaHelpPopup.html, didn't match any of > these. > > The code from the comphelp url view is very basic and looks like this: > def component_help(request): > view = "component_help" > dctnry = {} > reqGET = request.GET.copy() > if reqGET.has_key('fieldId'): > field_value = reqGET['fieldId'] > else: > field_value = "NONE FOUND" > message = "This is a test message!...FIELD-ID="+field_value > dctnry['helpdata'] = message > return HttpResponse(message) then why are you calling /mediahelp/comphelp/mediaHelpPopup.html? what exactly do you think that html filename in the end does to your call? And.. no, I could make a lot of questions trying to lead you slowly to the answer, but what I really think is that you need to do the tutorial again, and understand urlconfs, views and templates. https://docs.djangoproject.com/en/dev/intro/tutorial01/ I'll give you the short of it because I'm not your teacher: what you actually want to do is call '/mediahelp/comphelp/' and from the view you'll want to `return render_to_response('mediaHelpPopup.html', dctnry)` -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column
> as shown in the picture, this i could do by add a method in the model > getTienda1 and return the stock and do it for each store, but i want it to > be created dinamically because the user could create a new store and it will > not be there. > > so this is my cuestion: can i do that? Interesting question. You COULD try the following: in the ProductAdmin ModelAdmin's class' __init__ you can define list_display like from store.models import Tienda for store in Tienda.objects.all(): self.list_display.append('stock_tienda_{id}'.format(id=store.id)) this would give you the list of existing stores at server init time. and then you could define your Product model's __getattr__ method something like this: def __getattr__(self, attr): base = 'stock_tienda_' if attr[:len(base)] == base: return Product.objects.filter(tienda=Tienda.objects.get(id=attr[len(base):])) return super(Product, self).__getattr__(self, attr) this should make the ModelAdmin's hack work finally, you need a way to add new columns for newly created stores, so maybe a post_save signal on Tienda objects @receiver(post_save, sender=Tienda) def add_to_product_list_display(sender, instance, new, **kwargs): if new: # I don't know how to get the ModelAdmin's instance for a given class, # but it must be something in django.contrib.admin.site product_admin.list_display.append('stock_tienda_{id}'.format(id= instance.id)) you probably need another listener before .delete of stores, and I'm not certain the __getattr__ hack will work, but this sounds interesting. Please try on those lines, and let me know if this worked, I'm most interested -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: 'QuerySet' object has no attribute '_meta' ... but I'm not using a QuerySet!
The ArtworkForm AND the full view code would be helpful, yes also, maybe you'll want to install django-extensions, werkzeug, and run your devserver with runserver_plus, that'll give you full debugging capabilities on your browser, and will be able to see what's each object (that instace object, specifically) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: ignore field during form validation
> class Form(forms.Form): > > check = forms.BooleanField( > required=False, > ) > # take into account only when 'check' is True > len = forms.IntegerField( > min_value=3, > max_value=5, > required=True, > ) > > > What I want is to validate the 'len' field only when 'check' is True. > I could define the clean method of the form and validate the required, > min_value and max_value stuff only when 'check' is True but the case when > someone types a non integer value into the input is still there. How could I > skip that? That check is done by the IntegerField. well, you could override clean_len() and not do anything in it, and then override clean() and do your check there. The only problem is that you won't be able to raise the issue as a field-specific error -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Can i use django book
While the things on the djangobook are probably still compatible, they're far of being best practices nowadays, and will lead you down old and abandoned roads, more times than not. As it's been said, I'd rather stay by the official docs, they're very clear and pretty helpful, not purely technical at all. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: REMOVE ME
I'm very sorry. I got completely out of line. It's just something that irritates me a lot, and I'm not a native english speaker, and it may be I don't know the actual "value" of the word, I felt it was more funny than insulting. And I hadn't read your first reply. It won't happen again. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Is there a way to use 'request.user' in a custom template tag without an inclusion tag?
> > class EditableNode(template.Node): > def __init__(self, location_name): > self.location_name = location_name.encode('utf-8').strip("'") > def render(self, context): > obj = Placeholder.objects.filter(location=self.location_name) > if request.user.is_authenticated(): > for x in obj: > return "%sedit" % (x, self.location_name) > else: > for x in obj: > return x > > > > that `request` variable isn't declared anywhere, that's what that "global name `` does not exist" error mean. I *think* you've got to use context['user'], try that. Else, try context['request'].user -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Variable # of fields in a form
maybe this will help? https://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup On Mon, Jul 30, 2012 at 5:06 AM, Alex Strickland wrote: > On 2012/07/25 12:41 PM, Daniel Roseman wrote: > >> You could probably subclass the CheckboxSelectMultiple widget and >> override the `render` method to get what you want. >> >> See the original code here: >> https://github.com/django/django/blob/master/django/forms/widgets.py#L749 >> unfortunately you'll need to copy-and-paste most of that code but that >> should give you the output you need while still leaving Django to do the >> "messy data handling" . > > > Thanks Daniel. I am looking at that code distributed with 1.4, amazing how > different it is in the head version already. > > I think I'll try and do something similar to Select() which caters for > , and if I can make that work then I'll override the > render method to suit my layout purposes (try, being the operative word). > > If I can make it work nicely it might be nice to upgrade it to the same > style as the head version and offer it back as a snippet - that looks a long > way off though! > > -- > Regards > Alex > > > -- > 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. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: access the state of a Model object prior to it's modification ?
uhm, if you register a listener to the pre_save signal, then you can do this: if instance.published: # the instance about to be saved has the published flag on dbojb = MyModel.objects.get(id=instance.id) # did it have it on the database? if not dbobj.published: do_stuff() you probably need to check the "created" argument on the listener that tells you if the object is a new one, or a modification -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Dynamic forms
Just to be clear, sandeep, jQuery is not java, javascript is not java. Get yourself clear on that, because it can become a big confusion. Besides that, yes, without javascript, the only way you've got to do that, is having the user submit a form where he selects the options, and then return another form with the appropriate options rendered. Maybe you can use a form wizard for this -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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.
returning a zip file for download
Down here's the code in which I'm creating a zip file with a bunch of pdf labels, and returning it on the HttpResponse for the user to DL it. The weird thing is that I'm getting just a pdf file (ok, I'm testing with a single file, so I don't know if that's the problem) and I can't set the downloaded filename to anything (it's always "download") Can someone see what I'm doing wrong? files = [] for detail in queryset: for parcel in detail.parceldescription_set.select_related().all(): shipment = parcel.shipment if not shipment.label: try: shipment.download_label(args['username'], args['password']) except Shipment.Wait: self.message_user(_("Failed downloading label for " "shipment {id} because the " "Canada Post server is busy, " "please wait a couple of minutes " "and try again").format( id=shipment.id)) files.append(shipment.label.file) tmp = tempfile.mkstemp(suffix=".zip") tf = zipfile.ZipFile(tmp[1], mode="w") for file in files: filename = os.path.basename(file.name) tf.write(file.name, filename) tf.close() return HttpResponse(open(tmp[1]), mimetype="application/zip") -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: returning a zip file for download
OK, I got it working, I'm not sure what the problem was, but calling the loop variable 'file' was overriding the python default file object class now I'm doing this: response = HttpResponse(File(file(tmp[1])), mimetype="application/zip") response['Content-disposition'] = ('attachment; ' 'filename="{}"').format(os.path.basename(tmp[1])) return response and I'm wondering, what happens with that File object after the response is sent? when does it get closed? isn't there some cleanup code missing? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Noob question
as Kurtis says, drop the explicit Primary Keys, and drop the hungarian notation as well (don't declare the variable type on it's name): I don't need to be reminded that the name of a project will be a string, it's pretty obvious. Also, python standards talk against using underscore in class names, so standard naming would be HeaderEnrich instead of Header_Enrich. Underscores for field names are good. I'd also use less abbreviations. also, I'd name the FK on that model just "projeto", since what you'll get when you do `headerenrichobject.projeto` will be a Projeto object, not it's ID Try to forget the underlying database, the ORM is there to abstract you from it. But all these are style things, the syntax looks good, so it's all your call, but getting used to standardized style will make your life easier, as well as the life of people who try to help you in mailing lists and IRC channels -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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.
showing a second level of indirection in an admin change_form page
Anyone knows of any trick that will let me show a second-level indirection inline via a one2one, so ModelA <-FK- ModelB <-one2one- ModelC, and show A, B-C-B-C-B-C kind of thing? Maybe I can override the get_formsets in the admin? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: DRYing up my forms.py
But if you subclass the widget, then you'll need to override every form's widget with { forms.DateField: MyDateWidget } so overriding and using your own MyDateField would be less verbose and repetitive On Sat, Aug 4, 2012 at 6:17 PM, Melvyn Sopacua wrote: > On 3-8-2012 18:23, Lee Hinde wrote: >> >> On Aug 3, 2012, at 9:01 AM, Melvyn Sopacua wrote: >> >>> On 3-8-2012 17:37, Lee Hinde wrote: >>> self.fields['photo_response'].widget.attrs["class"] = 'date-field input-small' self.fields['photo_response'].widget.format = '%m-%d-%Y' > >> Thanks, that got me looking in the right place. I think I need to >> sublcass the widget, since I'm concerned with the display of the data, >> not how it's saved/stored? > > Yes, if the data doesn't need special handling you can stick to > subclassing the widget. > > -- > Melvyn Sopacua > > -- > 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. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How to override an attribute?
> There is a class (let's call it Foo) which is a subclass of User. > Foo has the following line in its Meta: > proxy = True if you don't provide full minimal data, it's hard for us to help. If I had known you were using a proxy model, I'd have proposed something different. In general, unless you got a good reason, I'd recommend against subclassing User, use a profile instead. If you *really* need to subclass or override it, first go read the docs about overriding the User class, *and* all the documentation about models and model inheritance. Things should be pretty clear, whether you want a proxy model or not, where in the inheritance tree it should be, and how to set it up. THEN, if you have some issue with your class schema, you'll be able to realize what you need, and be sure whether you really need to do what django is complaining about, or if there's a better way of doing it. For the time being, I suggest you drop all the Foos and Bars, post some real code, and explain why do you feel the need to subclass the User model -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How to override an attribute?
I don't mean to say you shouldn't need to ask questions, I just say that using or not "proxy" is not a "let's see what happens" choice, and having the docs read and halfway understood will help you ask *the right* questions -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: multiple profile
Well, it depends on what you want to do exactly, you could create something like this: class UserProfile(models.Model): common_data class ClientProfile(UserProfile): specific_data class StudentProfile(UserProfile): specific_data class TeacherProfile(UserProfile): specific_data ... AUTH_PROFILE_MODULE = 'appname.UserProfile' This would ensure that 3rd party apps that don't know about your 3-user-types system work in your site, but whether you do this, or ignore AUTH_PROFILE_MODULE, you'll have to set up a specific way of creating the profiles on user creation. Save signals are your friend here, probably, and/or the views you use to create the different types of user. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Hot to use widgets with generic views
well, for starters, you won't magically get "on keyup" behavior by adding something on your backend, you'll need to use ajax for this, and, depending on your expected number of elements, it might be better to send everything and do any filtering on the client side (if you're handling, say, up to a few thousands of records, and not up to tens of thousands or more). In any way, you'll need to give your view some parameter to do the filtering. For this, I'd recommend passing a ?q=keywords GET argument to your view, and with that in mind, I link you here: https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-display/#dynamic-filtering Just do something like that, but instead of using self.args or self.kwargs, use self.request.GET for the filtering -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: New to dj: relational limitations
> On Tue, Aug 14, 2012 at 8:49 PM, Russell Keith-Magee > wrote: I'm just glad I didn't come back with a half-assed response -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How well does South work in a team?
Well, if you push without pulling, this might happen, if you always pull before pushing, then you'd have to manually merge both migrations (which would probably mean letting the other migration as 001, and changing yours so it adds your wanted changes on top of THAT And as an answer: using south is always better than NOT using it (unless you want to roll out your own migrations system) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How well does South work in a team?
>> Well, if you push without pulling, this might happen, > > *Implicit git usage* :D Implicit VCS usage, whichever you choose. If you don't, you shouldn't be doing team work -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How well does South work in a team?
>>> Well, if you push without pulling, this might happen, >> >> *Implicit git usage* :D > > Implicit VCS usage, whichever you choose. > > If you don't, you shouldn't be doing team work ah, I see now. CVS wouldn't complain in that scenario... neither would git/hg when you pull, for that case.. yes , you need to be careful, but it's better than the alternative -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: How to create a formset that contains forms with a dropdown? (Crucial)
DropDownMultiple widget http://djangosnippets.org/snippets/747/ -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: django makemessages doesn't recognize trans in templates
> For example for this link > > {% trans "contacts" %} > > I have the msgstr="Contactos". I expect to see "Contactos" in the browser, > but I still see "contacts". Any suggestion? 1) case-sensitive. Are you sure you haven't translated "Contacts" instead of "contacts"? 2) fuzzy-mark. I've noticed that if a translation is marked as "fuzzy", sometimes gettext doesn't use it -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: [old question]NoReverseMatch.. I am sorry.
either remove the quotes from {% url 'blog.views.add_comment' %} (so it's {% url blog.views.add_comment %}) or {% load url from future %} Loading from future is the better option, I think. and for future reference: Reverse for ''blog.views.add_comment'' with arguments '(1L,)' and keyword arguments '{}' not found. notice how there's two single quotes there, not a double quote? that's your clue, right there -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: [old question]NoReverseMatch.. I am sorry.
> But I am confused. > For example, > the following code needs to add single quote. > > {% block content %} > Add Todo items https://docs.djangoproject.com/en/dev/releases/1.3/#changes-to-url-and-ssi also, that won't work with double quotes either, unless you import future, and a bunch of other things. Just import url from future, since this will be the default behavior in the near future -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Full auth solution
> http://www.django-userena.org/ ++ I've successfully combined it with django-social-auth to have facebook/twitter/google/openId login -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Hard time debugging an strange problem
I'd like to see some of your management commands' code. It smells somewhat like you're running a shell subprocess and not waiting for it to be done before going on to the next thing -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: To Use or Not to Use the admin backend
> Anyway, to the question. Once the models, the intermediate models and > the interactions between all of them start getting sufficiently > complex, you will need to put new forms on front. Theoretically, you I've a question about this. I tried to do something like this, but using the main capabilities and hacking on the ModelAdmin classes, changing the formsets and the like, and reusing as much as possible, including of course the admin templates. Of course, it wasn't possible. I was trying to do something as simple as a double-indirection inline, a second-level foreign key, and ended up just showing a link to the other model's admin page, creating, indeed, a complex workflow where none was needed. To what extent and how particularly would one need override a specific admin page to do this kind of thing? Is reusing the templates at all possible if you've customized things? Maybe the templates yes, but the ModelAdmin views are impossible, I was in a hurry so I wasn't able to do a good diagnosis of what would have been needed to do this. Tomas -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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.
Django-admin (was: tastypie - some feedback / comments)
Since this came up, are there any more-or-less packaged alternatives to django-admin? More than twice I've had to give up in something as simple as rendering two-level FK indirections, lest I wanted to override most of the ModelAdmin classes. The thing is that I don't trust myself to be throughout enough with security and the such when rolling my own. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Django-admin (was: tastypie - some feedback / comments)
The admin templates and views themselves are convoluted enough (the price of having them work with anything), and full of enough magic that it's not really feasible to build on top of them to add the required capabilities. Maybe adding new admin views would be a posibility, but what happens when you want an admin page that does not exactly correspond to a given model? You can usually twist things around to make it so, but the fact stands that the admin is in the end just a way of managing the database, and that the user must *really* know what they're doing to avoid screwing up big time. Maybe careful permission handling and/or different admin site instances are a (partial) solution to this, but I haven't played with those myself. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: OR together multiple extra clauses
I haven't done this, so I might be wrong, but... > queryset.extra( > where=['unaccent("table_name"."column_name"::text) LIKE > unaccent(%s)'], > params=['%%%s%%' % value] > ) first, wouldn't just setting params=[value] work? furthermore, isn't that the whole point of the params thing? maybe unaccent(%%%s%%)' params=[value]. secondly.. wouldn't chaining .extra() methods work? -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Django: language in field description in forms won't change
you probably are using ugettext and should be using ugettext_lazy On Sat, Sep 22, 2012 at 8:44 PM, Patrick wrote: > When I change language on my Django-powered site, everything works fine > except the translation of the field descriptions in the forms. The > description is still displayed in the old language. Only the forms already > visited that session are affected. > > It seems like some sort of caching problem, but I don't use any caching (as > far as I know) and all other parts of the site behave as expected (templates > and random text using django.utils.translaction.ugettext work just fine). > > Summarized: > > When I open the site and change language, and then visit a form: everything > works as expected. All text is translated. > When I visit a form, change language and return to the form: everything is > translated, but the form stays in the old language. > Restarting the web server forces the language to change: then Django behaves > as in (1) for the current session. Until the language is changed again. > > Help is appreciated! > > Kind regards, Patrick > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/P3sRNFd-aaAJ. > 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. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Making form label a href
> Is there some way to have the form label be a href? you'll have to change the forms templates to something like {% for field in form %} {{ field.label }} {{ field }} {% endfor %} -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Facebook like button in django
You should probably start by reading this: http://developers.facebook.com/docs/reference/plugins/like/ -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Facebook like button in django
> I want to create a website facebook like, but real simple and I want to have > a button that I can give to blogger to add them on their blog entries. It > have nothing to do with facebook. Ah! so you want your own "facebook button"! It'll be mostly a javascript task, rather than django-specific. In order to protect your users' identities, you won't be giving the client (blog) an actual HTML form, but rather (like the FB button) a link to a JS library, and some markup that the library will use to create an iframe to your website where you'll send the actual rendered markup -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: implement of view
> > how can i implements now these "def sql(request):" into my html code? pls > help me... > you're saying next to nothing, but I *guess* you could do something like return render_to_response("sql.html", { 'row': row }) at the bottom of your sql view, and write an sql.html template that shows it the way you want... Also, you'll better go on and learn that pyodbc library and how to pass parameters into your queries, which will protect you against SQL injection attacks.. and you should probably learn SOME python if you're going to be coding in it. And you shuold *really* at least run through the django tutorial at least once, in order to get a grip on some of the basic django concepts, like forms and models, which will help you a lot -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: implement of view
>> Thank you for your answer. i have chapter 1-4 of >> http://www.djangobook.com/en/2.0/index.html done, but not much time to go >> throught the hole book atm. i will try it with your code. :) the django book is somewhat outdated, and long. https://docs.djangoproject.com/en/dev/intro/tutorial01/ do that tutorial, it's quite short, you can get through it in a couple of hours. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Displaying a custom field (PickledObjectField) in the admin
maybe restate the problem, give some more code, show your models, and your admin files, and someone may be able to help a little -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Displaying a custom field (PickledObjectField) in the admin
Just by the way, I'm looking at django-picklefield code and README https://github.com/gintas/django-picklefield and it says NOTHING about a widget, or an admin representation, so.. maybe it's not DESIGNED to be shown on the admin? it'd make sense, too, since it's.. well, it can be ANYTHING On Wed, Oct 24, 2012 at 3:03 PM, Tomas Neme wrote: > maybe restate the problem, give some more code, show your models, and > your admin files, and someone may be able to help a little > > -- > "The whole of Japan is pure invention. There is no such country, there > are no such people" --Oscar Wilde > > |_|0|_| > |_|_|0| > |0|0|0| > > (\__/) > (='.'=)This is Bunny. Copy and paste bunny > (")_(") to help him gain world domination. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: implement of view
>>> How can i create 2 views on one page? >>> def sql(request): and def portal(request): You can't. A View *is* a page. Do the tutorial. You could use class-based views and have a view that inherits from both, and combines the contexts (this is _not_ in the tuto) -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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.
Modernizing the Tutorial
Now that function-based views are being deprecated, or at least that class-based views are being favored, there should be a tutorial with them in the docs, shouldn't it? I don't mean replacing the current one, because that'd raise the entry point a lot, but cloning the original tutorial, but implementing it with class-based views, possibly placing a link to it in the generic views docs page, would go a long way towards generating "good" habits amongst new users, I think. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Modernizing the Tutorial
> However, there is also scope for a focussed tutorial about class-based views > in general. IMHO one of the biggest uptake problems around class-based This is what I meant. Something that brings in, easy and clearly, the concept of mixins, the different mixins,something that, for example, take two mixins that alter the context, and combines them, stuff like that, simple, but useful, and that gives you a glimpse of "real world" usage and customization. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: 1.5: syntax of AUTH_USER_MODEL
> Thanks, yup! I just figured it out too. I didn't realize all the "apps" are > in the path as well. the apps aren't NECESSARILY in the path. Django has a concept of app label, which is the name of the directory where the models module exists. For example, django-cms has plugins, which in order to use, you need to add to INSTALLED_APPS: 'cms.plugins.text', 'cms.plugins.picture' but the app label of these plugins are just 'text' and 'picture' respectively, and the "app model" path to their models are just 'text.TextPlugin', and 'picture.PicturePlugin'. This is, IMO, the biggest and most stupid problem in django core design, because it stops you from having an otherwise completely legal configurations, like having a 'cms.plugins.picture' app alongside a 'myproject.custom.picture' one which might do something completely different. I.E.: you can't have apps with repeated app labels even if there's no python path conflict between them. I don't know what the reason behind this is. I know it allows you to make a model part of any given app regardless of where it's located (via Meta.app_label), but this could very easily be extended (in a backwards-incompatible way, I'm afraid) to require to be the fully qualified name of the app package -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Django URL pattern - template tags
I'll still answer this just in case. You should have the following in your urls.py: urlpatterns += (.., url(r'(P)\w+/(P)\d+/(P)\[w-]+/', your_view, name='yoururlname'), ) and then you can have in your template {{ n.title }} I hope I didn't make any mistakes. tomas -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Too many TCP connections
shot in the dark: aren't they connections to the database, maybe? On Sat, Sep 3, 2011 at 12:56 AM, shacker wrote: > Hmm, appreciate the feedback, but we don't have KeepAlives enabled on our > Django servers and it's never been a problem. And remember, the other Django > site on the same server doesn't have the problem. As for serving lots of > resources - we're just talking about viewing/saving seven User pages in the > Admin before we've built up over 600 open TCP connections. This is a small > and very lightly trafficked site - just a little bit of Admin activity > triggers this (it's not an end user problem either - I can reproduce it > easily). > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/CDUJ8AzY-awJ. > 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. > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Initial data for ManyToMany field
Look into formsets. It's what the admin inlines use. On Tue, Sep 6, 2011 at 5:40 PM, Nan wrote: > > Because SymptomeForm is a ModelForm, it will initialize its "parent" > field as a ModelMultipleChoiceField, which I believe must be > initialized with a queryset instead of a list. > > On Sep 6, 4:30 pm, Thomas49 wrote: > > Hello, > > > > I have two models, and the second contains a ManyToMany relationship: > > > > class TypeMedical(models.Model): > >... > > > > class Symptome(TypeMedical): > > ... > > parent = > > models.ManyToManyField(TypeMedical,related_name='Parent',blank=True) > > ... > > > > Then, I use a ModelForm in order to save data. > > > > class SymptomeForm(ModelForm): > > class Meta: > > model = Symptome > > > > When I create a form, sometimes I want to select a field in "parent". > > How can I do that? I tried many things but nothing works. Ex: > > sform = SymptomeForm(initial={'parent':["Acupuncture",]}) > > > > I hope someone can help! Thanks, > > > > Thomas. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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: Initial data for ManyToMany field
> Look into formsets. It's what the admin inlines use. that is class TypeMedicalForm(forms.ModelForm): class Meta: model = TypeMedical TypeMedicalFormSet=formset_factory(TypeMedicalForm) take a look at the django docs for more details -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- 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.