Re: Efficient way to import many-to-many relations
On 9/17/07, Julio César Carrascal Urquijo <[EMAIL PROTECTED]> wrote: > > def import_from_file(filename): > ... > for r in product_records(file): > p = Product() > p.code = r['code'] > p.parent = Product.get(code = r['parent_code']) > ... > p.save() > for category in r['category_codes']: > c = Category.get(code = category) > c.posts.add(p) This will be slow because each call to c.posts.add() will be a separate insert. This can be significantly sped up if you do all the adds in one hit: c.posts = [... list of post objects (or ids of post objects) ...] This assignment will be performed as a single SQL insert, very similar to the one you describe. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Directed graph implementations for Django
I'm a newbie on Django my self but maybe this is what you are looking for: class Category(models.Model): code = models.CharField(maxlength=200, unique=True) products = models.ManyToManyField('Product') class Product(models.Model): parent = models.ForeignKey('Post') code = models.CharField(maxlength=200, unique=True) I've also read that you can specify signals for most operations on a model (Like when a model is inserted, updated or deleted from the database) though I can't find the URL right now. There's some mention of it here: http://www.djangoproject.com/documentation/db-api/ On Sep 16, 9:54 pm, "Paul Dorman" <[EMAIL PROTECTED]> wrote: > Hi all, > > definite newbie here. I'd like to implement a category type system in > Django. I've looked in the cookbook and Googled a bit, but to no avail. What > I'm after should be pretty simple: a directed graph for categories, where > objects and perhaps categories can be a member of one or more categories. > For example, a 'server' is an 'infrastructure component' (for the techies), > as well as an 'asset' (for the financial types). In my grand scheme when an > object is associated with one or more categories (one is the minimum), the > application will execute method calls stored (with optional parameters) in > the database (serialized as JSON or XML). With the 'server' example, it > might be that being in the 'infrastructure component' category triggers an > email to be sent to the system administrator, and the existence in the > 'asset' category would trigger an automated update to the asset register. > The methods are stored according to the standard CRUD set of operations, so > that a user can create a new category in the view, and then specify actions > which occur when an object is created, read, updated, or deleted (provided > by the application itself). Actions are triggered for both objects (the > things that are categorized) and for child categories (so for example it may > be that a parent category can be locked in such a way as to prevent any more > child categories from being added). > > Note that categories are purely containers with generic actions (for crud > operations on objects in the category) and distinct from objects, which I > imagine would have a category_id FK. And note also that my objects are all > using the same model, with the bulk of data serialized as XML. > > Has anyone out there in Djangoland done something like this? The graph's the > thing - I'm happy to deal with the CRUD triggers myself. If there's a model > out there that would be a good starting point that would be great. > > One additional thing I'm wondering about is how Django can work with stored > procedures. For example, it might be more efficient if the application can > ask the database for the methods to run when an object is created, and > have the database return the methods for not only the object's bottom-level > category, but for all parent categories as well. > > P.S. > > Congratulations on the great sprint! > > P.P.S. I hope I haven't just embarrassed myself with my naïveté. > > -- > "Science fiction writers are the only ones who care about the future" > -- Kurt Vonnegut --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Efficient way to import many-to-many relations
I have the following models (Well, very simplified): class Category(models.Model): code = models.CharField(maxlength=200, unique=True) posts = models.ManyToManyField('Post') class Product(models.Model): parent = models.ForeignKey('Post') code = models.CharField(maxlength=200, unique=True) Now, I have a large file with products that I need to import and each record has a list of categories that need to be associated with the product: def import_from_file(filename): ... for r in product_records(file): p = Product() p.code = r['code'] p.parent = Product.get(code = r['parent_code']) ... p.save() for category in r['category_codes']: c = Category.get(code = category) c.posts.add(p) This sort of works but it is too inefficient to import all products. What I really like to do is something along the lines of: cursor.execute("""insert into store_product (code, parent_id, ...) select %s, id as parent_id, ... from store_product where code = %s""", r['code'] r['parent_code']) and cursor.execute("""insert into store_category_products (product_id, category_id) select %s, id as category_id, ... from store_category where code in (%s)""", p.id, r['category_codes']) Is possible to express this within the django db-api or should I just give up and use raw cursors? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Flatpages With Memcache as storage location
Peter Pluta wrote: > > > > > On Sep 9, 8:52 pm, Brian Morton <[EMAIL PROTECTED]> wrote: >> What happens if you use a simple or dummy cache? >> >> On Sep 9, 2:51 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: >> >> >> >> > On Sep 9, 6:15 am, Thomas Badran <[EMAIL PROTECTED]> wrote: >> >> > > My best guess would be that you are missing the / at the start and >> end >> > > of the url >> >> > > Tom >> >> > > On Sat, 2007-09-08 at 21:00 -0700, Sasha Weberov wrote: >> > > > All of my flatpage pages throw a 404. If I turn debug on which >> > > > disabled cacheing they re-appear. I've tried restarting memcached >> and >> > > > my SCGI server as well as Apache and it did nothing. I've also >> svn'd >> > > > the latest Django trunk; the problem still persists. Anyone got any >> > > > idea what can possibly be causing this? >> >> > > > Here is my settings.py middlewear config. The Middlewear seems to >> be >> > > > in the correct order. >> >> > > > MIDDLEWARE_CLASSES = ( >> > > > 'django.middleware.common.CommonMiddleware', >> > > > 'django.contrib.sessions.middleware.SessionMiddleware', >> > > > 'django.contrib.auth.middleware.AuthenticationMiddleware', >> > > > 'django.middleware.doc.XViewMiddleware', >> > > > 'django.middleware.cache.CacheMiddleware', >> > > > >> 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', >> > > > ) >> >> > > > Any help or suggestions would be greatly appreciated.- Hide quoted >> text - >> >> > > - Show quoted text - >> >> > I've looked at that, all of my urls are /faq/ /tos/ /privacy/ etc. The >> > flat pages load with Debug on, but with it off they don't. I believe >> > this is because Debug On turns cacheing off.- Hide quoted text - >> >> - Show quoted text - > > What would be classified as "simple"? > > > > > > Anyone? I tried again today with the latest svn trunk. -- View this message in context: http://www.nabble.com/Django-Flatpages-With-Memcache-as-storage-location-tf4408034.html#a12728682 Sent from the django-users mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Directed graph implementations for Django
Hi all, definite newbie here. I'd like to implement a category type system in Django. I've looked in the cookbook and Googled a bit, but to no avail. What I'm after should be pretty simple: a directed graph for categories, where objects and perhaps categories can be a member of one or more categories. For example, a 'server' is an 'infrastructure component' (for the techies), as well as an 'asset' (for the financial types). In my grand scheme when an object is associated with one or more categories (one is the minimum), the application will execute method calls stored (with optional parameters) in the database (serialized as JSON or XML). With the 'server' example, it might be that being in the 'infrastructure component' category triggers an email to be sent to the system administrator, and the existence in the 'asset' category would trigger an automated update to the asset register. The methods are stored according to the standard CRUD set of operations, so that a user can create a new category in the view, and then specify actions which occur when an object is created, read, updated, or deleted (provided by the application itself). Actions are triggered for both objects (the things that are categorized) and for child categories (so for example it may be that a parent category can be locked in such a way as to prevent any more child categories from being added). Note that categories are purely containers with generic actions (for crud operations on objects in the category) and distinct from objects, which I imagine would have a category_id FK. And note also that my objects are all using the same model, with the bulk of data serialized as XML. Has anyone out there in Djangoland done something like this? The graph's the thing - I'm happy to deal with the CRUD triggers myself. If there's a model out there that would be a good starting point that would be great. One additional thing I'm wondering about is how Django can work with stored procedures. For example, it might be more efficient if the application can ask the database for the methods to run when an object is created, and have the database return the methods for not only the object's bottom-level category, but for all parent categories as well. P.S. Congratulations on the great sprint! P.P.S. I hope I haven't just embarrassed myself with my naïveté. -- "Science fiction writers are the only ones who care about the future" -- Kurt Vonnegut --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: export data to txt file
On 9/17/07, Joaquin Quintas <[EMAIL PROTECTED]> wrote: > > Gjango users... i am new usign django, and this is my first > requirement, i have not idea.. please HELP! > i have a function that exports data to xml, now the users wants that > the same function exports to tt file.. What exactly do you mean by a 'txt' file? Depending on your desired output format, there are a number of ways that you could do this: - Use the JSON or YAML backend to produce a .txt file - Write a custom serialization backend that formats in your preferred format - Write a view that returns text content, with a template providing the formatted data. All of these would produce 'data exported to a txt file'. The right approach will depend on exactly what you are trying to acheive. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: testing questions
On 9/17/07, john <[EMAIL PROTECTED]> wrote: > > coming from Rails so any help appreciated > > 1) I realize you can use doctests or unit tests - but is one > recommended over the other ? Not particularly. They both have their advantages. doctests are very easy to set up, and are very easy to read (and thus validate); unittests have more infrastructure, so they can make some complex tests easier to set up. A good test suite will probably use elements of both. > 2) Is it recommended to have unit tests within each class in the > models.py file or in a separate testing file ? Unless I'm testing something absolutely trivial, I tend to put them in tests.py (or a tests directory that contains test modules). > 3) Fixtures using json (I assume json is the recommended approach): > can a new object be defined with json with only a few of the fields > defined ? Only if there are default values for the omitted fields, or if NULL is an allowed value for those fields. This is true regardless of the fixture format. > 4) The "Writing your first django app" is very good (thanks) - needs a > section on demonstrating testing (since testing should be one of the > first things done :) I could try to write it but obviously I don't > understand python/django testing too well yet. True. This would make a good 'tutorial 5' type document. It's worth logging as a ticket so that the idea isn't forgotten. And don't underestimate the value of a newcomer writing tutorial documentation - often the best docs come from newcomers, because they don't have a preconceived notion of what is 'obvious'. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
testing questions
coming from Rails so any help appreciated 1) I realize you can use doctests or unit tests - but is one recommended over the other ? 2) Is it recommended to have unit tests within each class in the models.py file or in a separate testing file ? 3) Fixtures using json (I assume json is the recommended approach): can a new object be defined with json with only a few of the fields defined ? 4) The "Writing your first django app" is very good (thanks) - needs a section on demonstrating testing (since testing should be one of the first things done :) I could try to write it but obviously I don't understand python/django testing too well yet. thks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"online/offline status" on user profile
What I want to do is display "online/offline status" on user profile? anybody have an idea how to get information about user is logged in(active session) or not? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Obtaining newforms field values in a template
Collin, Thanks for the response. I don't want to use the built-in rendering, that's the thing. I'm building my form fields with a Javascript library, and using the Django newforms for the server-side validation goodness. As a result, I just want the value that's going to be displayed, bound or unbound. Unfortunately, my reading of the code tells me that I would need to duplicate the logic that the field goes through to determine this. There's no "get_value_to_render" or suchlike to call. Regards, -scott On Sep 16, 9:07 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > What exactly is your use case here? This should all be handled > automatically when you do {{ form.fieldname }}, depending on if it's > bound or not :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting "blank" to one Field?
You've misunderstood - you need blank=True /and/ null=True. blank=True will tell admin to let you pick nothing for it, and null=True will then allow the NULL value to be entered. NULL is what you use to signify "unset" on a ForeignKey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Obtaining newforms field values in a template
What exactly is your use case here? This should all be handled automatically when you do {{ form.fieldname }}, depending on if it's bound or not :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using a filter with many to many relationship
Couple of things so I understand better, What is the attribute of term that contains 'ThemePark' and 'London' ? What are you trying to end up with, all records with themePark or only records with themepark and London ? -richard On Sep 16, 11:36 am, merric <[EMAIL PROTECTED]> wrote: > I can't get this to work for me. > > For example, I have two records which both share the term 'ThemePark", > one of these records also has the additional term "London". > However, when I run your suggestion I get an empty query set. > > Cheers > > On Sep 15, 2:27 am, r_f_d <[EMAIL PROTECTED]> wrote: > > > You are missing Q. > > > try > > from django.db.models import Q (I think that is where it resides but > > cannot verify right now, a quick check of the documentation should > > confirm) > > > Offer.objects.filter(Q(terms__exact = 'term1') & Q(terms__exact = > > 'term2') & Q(terms__exact = 'term3)) > > > On Sep 14, 6:46 pm, Merric Mercer <[EMAIL PROTECTED]> wrote: > > > > I have a model "OFFER" that has has many to many relationship with a > > > model "TERMS". > > > > Class OFFER: > > >terms=models.ManyToMany(Terms) > > > > Assuming I have the following value for 3 records in Term > > > term1=2 > > > term2=5 > > > term3=8 > > > > I want to return ONLY those offers which have ALL three of these terms . > > > I've tried: > > > > qs=Offer.objects.all().filter(terms=term1).filter(terms=term2).filter(terms=term3) > > > but this doesn't work - I always end up with an empty query set. > > > > What am I missing? > > > > Cheers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
VIDEOPERCUMA YANG TERUS HANGAT DIPASARAN !!!!
Salam hormat, Jangan sangka bahan percuma tidak berkualiti! Tapi saya akui yang perkara begini memang jarang berlaku... kerana kebanyakan produk percuma yang diedarkan tidak menepati citarasa saya. Jadi, berikan perhatian kepada apa yang saya ingin kongsi bersama di sini. "Video Percuma Dot Com" adalah produk terbaru keluaran saudara Zamri Nanyan dan Mohd Sufian. Sekali lihat, memang saya tidak menyangka yang ianya diberikan tanpa sebarang caj. 11 Video Tutorial... Percuma? Pasti anda pun kurang percaya. Apa yang saya buat seterusnya ialah mendaftar di laman web tersebut, dan anda juga boleh berbuat demikian di: http://videopercuma.com/r/syahmie Wow! Selepas menonton beberapa video tutorial yang diberikan, saya terkejut kerana saya pernah melihat video tutorial sebegini dijual di internet pada harga USD$24.95. Dan lagi, Video Percuma yang diberikan oleh Zamri Nanyan dan Mohd Sufian adalah di dalam Bahasa Malaysia - sesuatu yang belum pernah dilakukan sebelum ini. Saya menonton satu per satu video tutorial yang diberikan dan terus terang saya katakan yang video-video ini memang hebat dan mampu menerangkan beberapa perkara yang begitu penting untuk seseorang memulakan perniagaan internet pertama mereka. Belum sempat rasa teruja saya hilang, saudara Zamri Nanyan memberikan satu lagi kejutan dengan video tutorial istimewa beliau. Saya tak pasti jika beliau membenarkan saya menceritakan mengenai video istimewa ini di sini, namun saya rasa kurang puas sekiranya saya tidak nyatakannya di sini. "Video Percuma dot Com" bukan sekadar video percuma yang memberikan ilmu yang berguna kepada anda, tetapi ianya juga satu sistem pemasaran viral yang mampu menjana pendapatan tambahan kepada anda... dan segalanya ada dinyatakan di dalam video istimewa ini. Jika anda tidak mempunyai laman web sendiri dan mahu menjana pendapatan sebagai affiliate, inilah laman web yang anda cari-cari selama ini. Cuma ikuti arahan di dalam video istimewa yang disediakan, mulakan promosi dan anda mampu membina pendapatan dari 9 sumber yang disenaraikan. Inilah yang dikatan multiple streams of income. Hebat, bukan? Baiklah, saya tak dapat cerita dengan lebih lanjut mengenai video istimewa ini kerana anda juga boleh menontonnya sendiri. Cuma daftar melalui link di bawah dan pastikan anda menonton ke semua video yang disediakan (termasuk video istimewa yang saya nyatakan di atas). http://videopercuma.com/r/syahmie ikhlas, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
export data to txt file
Gjango users... i am new usign django, and this is my first requirement, i have not idea.. please HELP! i have a function that exports data to xml, now the users wants that the same function exports to tt file.. any ideas? thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Creating link to root
On 9/16/07, Florian Lindner <[EMAIL PROTECTED]> wrote: > This template is used within different paths. Therefore I need to have the > styles.css availabe in every path the template could be used. > An alternative would be give the entire URL href="http://xgm.de/styles.css. > But then I need to change that line everytime when I deploy my app from > localhost to a domain. The 'media' context processor, which is enabled by default and adds the value of the 'MEDIA_URL' setting to every RequestContext. Copy/pasting from my base template: -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Creating link to root
Florian Lindner wrote: > Hello, > a common problem I have is that I have references in my main template like > CSS > or an background image: > > > > This template is used within different paths. Therefore I need to have the > styles.css availabe in every path the template could be used. I'm using a custom tag. I have in all my templates at the top an {% extends base.html %} which contains the DOCTYPE, html header etc. The base.html template is like this: {% load template_extensions %} etc... In my_app/templatetages/ I have template_extensions.py # My custom tag and filter definitions. from django.template import Library import re register = Library() def url_root(): ''' Returns the string for the root URL as set in the settings.py file. ''' try: from django.conf import settings except: return '- Cannot import settings file -' return settings.URL_ROOT and in settings.py I have: URL_ROOT = '/path_to/my_app' # Don't include any trailing / -- Michael Lake Computational Research Support Unit Science Faculty, UTS Ph: 9514 2238 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Today's newform-admin branch, svn version 6364
Hi, Today's version shows 2 problems, the first problem is related to date/time formats in fixtures, the 2nd to at least add forms, e.g. add users. Both using the newform-admin branch. The 1st problem can be created by installing a brand new project, creating an initial_data.json file and run ./manage syncdb again (or ./manage loaddata initial_data.json): Robs-Intel:~/Projects/o2o/mcp rob$ ./manage.py syncdb ... Installing index for auth.Message model Installing index for auth.Permission model Installing index for admin.LogEntry model Loading 'initial_data' fixtures... Installing json fixture 'initial_data' from absolute path. Problem installing fixture 'initial_data.json': [u'Enter a valid date/ time in -MM-DD HH:MM format.'] Looking at the initial_data.json file I think it complains about timestamps such as '2007-09-16 12:34:51.765432'. Removing the sub- second parts fixes it, it accepts a :SS component. This happen in user and some other fixture json records (e.g. log_entries). The 2nd problem, also testable in a brand new project, e.g. trying to add a user: TypeError at /admin/auth/user/add/ instancemethod expected at least 2 arguments, got 0 Request Method: GET Request URL: http://localhost:8000/admin/auth/user/add/ Exception Type: TypeError Exception Value: instancemethod expected at least 2 arguments, got 0 Exception Location: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ copy_reg.py in __newobj__, line 92 Python Executable: /Library/Frameworks/Python.framework/Versions/2.5/Resources/ Python.app/Contents/MacOS/Python Python Version: 2.5.1 Traceback (innermost last) Switch to copy-and-paste view /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/django/core/handlers/base.py in _real_get_response response = callback(request, *callback_args, **callback_kwargs) ... ▶ Local vars Regards, Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
best site for hacking tricks , computer tweak
check this out buddies... a kool site for anti hacking and hacking tips and tricks , computer tweaks to enhance ur pc,small virus creation ,etc it's the best site ... www.realm-of-tricks.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
best site for hacking tricks , computer tweak
check this out buddies... a kool site for anti hacking and hacking tips and tricks , computer tweaks to enhance ur pc,small virus creation ,etc it's the best site ... www.realm-of-tricks.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: User's permissions not updated
To answer my own question: python manage.py syncdb > Hey, > > I added a class "News" to models.py of an installed app. But its > permissions doesn't appear in the Change User View of the admin > interface. Need it to be activated somehow? > As superuser I can use News. > I use .96-pre > > Thanks, Manuel > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Creating link to root
Hello, a common problem I have is that I have references in my main template like CSS or an background image: This template is used within different paths. Therefore I need to have the styles.css availabe in every path the template could be used. An alternative would be give the entire URL href="http://xgm.de/styles.css. But then I need to change that line everytime when I deploy my app from localhost to a domain. Another working solution is to model the regexp in a way that styles.css is always available: r"^.*styles\.css$" It works but makes caching for browsers impossible and clutters the paths. Is there a tag like {% domain %} that gives me the domain and I can construct a path like http://xgm.de/styles.css dynamically (and it changes to http://localhost:8000/styles.css when I am on localhost)? Or how is this problem commonly solved with Django? Thanks, Florian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: filtering based on property
Not without a little work, atleast as far as I know. A custom manger is what you want. Then you could do something like model.current.filter(otherstuff) or make an extra method on the manager and chain model.objects.is_current().filter(otherstuff) class CustManager(models.Manager): def is_current(self): # build the actual filter args here f={'from_date__lte': today, 'to_date__gte': today} return super(CustManager,self).filter(**f) http://www.djangoproject.com/documentation/models/custom_managers/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Creating link to root
Florian Lindner wrote: > Hello, > a common problem I have is that I have references in my main template like > CSS > or an background image: > > > > This template is used within different paths. Therefore I need to have the > styles.css availabe in every path the template could be used. Couldn't you just do href="/styles.css" ? -- Christian Joergensen | Linux, programming or web consultancy http://www.razor.dk | Visit us at: http://www.gmta.info signature.asc Description: OpenPGP digital signature
Re: GeoDjango : Error in admin site with geom fields
Did you have a previous geos installation?? Maybe you have some old .so's that are being linked instead of the new ones. Ariel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Odd behavior of filtering
Does anybody recommend a good workaround - I'm experiencing the same problem On Aug 25, 1:57 pm, Djon <[EMAIL PROTECTED]> wrote: > Is there a ticket for it on the Trac? > How/where can I monitor it so that as soon as a fix is available I > could get the changeset? > > Thanks! > > On Aug 21, 11:45 am, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > On Mon, 2007-08-20 at 22:04 +, Djon wrote: > > > Hi > > > > My model is: > > > > class Tag(models.Model): > > > name = models.CharField(maxlength=30) > > > > class Snippet(models.Model): > > > name = models.CharField(maxlength=30) > > > tags = > > > models.ManyToManyField(Tag,filter_interface=models.HORIZONTAL) > > > > My aim to filter snippets according to multiple tag constraints > > > simultaneously. > > > However, the overlap of two sets just doesn't get filtered properly. > > > E.g.: > > > > In [96]: Snippet.objects.filter(tags__name="home") > > > Out[96]: [, ] > > > > In [97]: Snippet.objects.filter(tags__name="email") > > > Out[97]: [, ] > > > > In [98]: > > > Snippet.objects.filter(tags__name="home").filter(tags__name="email") > > > # SHOULD return [] > > > Out[98]: [] > > > > I tried the exact same idea by using .filter(Q(..),Q(..)) and also > > > with theQ(..)(..) option, as well as by dividing the process into > > > stages and inspecting the first filter's result on the way (it's > > > valid). Everything just ends up with the same empty list... > > > It's a known bug. The SQL query that is constructed doesn't work with > > many to many fields. Work in progress. > > > Regards, > > Malcolm > > > -- > > If Barbie is so popular, why do you have to buy her > > friends?http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Derived, read-only attributes in the admin
For these derived values, I usually have an attribute of the model that is updated at save time. You could have an 'order_total' on your Order model, and whenever you save an OrderLine, it updates the order_total on its associated Order and saves the order. Then it just becomes another attribute of the order (albeit denormalised - although that's not such a bad thing in these cases as you'll save having to recalculate it every time.) Check out slide 17 onwards on the Django Masterclass presentation at http://toys.jacobian.org/presentations/2007/oscon/tutorial/ Hope that helps, Mike [EMAIL PROTECTED] wrote: > Hi > > I have a fairly simple use-case which I feel should be achievable, but > which I'm not able to pull off. What I want is the ability to modify > the base query used by the admin to add some derived properties. For > example, if you have Orders with corresponding OrderLines, it's useful > to add the subtotal for each order in the order list. To achieve this > I tried the following: > > class OrderAdminManager(models.Manager): > def get_query_set(self): > return super(OrderAdminManager, self).get_query_set().extra( > select={'order_total': '(select sum(quantity * item_price) > from webshop_orderline where order_id = webshop_order.id)'}) > > And in the inner Admin class I added this line: > manager = OrderAdminManager() > > The net result of this is that the query result contains the > order_total column, and I can display it in the admin, but only if I > do so using a custom method, which means no sorting and no filtering. > If I try to add "order_total" as a non-editable field it blows up > when Django queries for webshop.order_total. > > Any ideas? > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using a filter with many to many relationship
I can't get this to work for me. For example, I have two records which both share the term 'ThemePark", one of these records also has the additional term "London". However, when I run your suggestion I get an empty query set. Cheers On Sep 15, 2:27 am, r_f_d <[EMAIL PROTECTED]> wrote: > You are missing Q. > > try > from django.db.models import Q (I think that is where it resides but > cannot verify right now, a quick check of the documentation should > confirm) > > Offer.objects.filter(Q(terms__exact = 'term1') & Q(terms__exact = > 'term2') & Q(terms__exact = 'term3)) > > On Sep 14, 6:46 pm, Merric Mercer <[EMAIL PROTECTED]> wrote: > > > I have a model "OFFER" that has has many to many relationship with a > > model "TERMS". > > > Class OFFER: > >terms=models.ManyToMany(Terms) > > > Assuming I have the following value for 3 records in Term > > term1=2 > > term2=5 > > term3=8 > > > I want to return ONLY those offers which have ALL three of these terms . > > I've tried: > > > qs=Offer.objects.all().filter(terms=term1).filter(terms=term2).filter(terms=term3) > > but this doesn't work - I always end up with an empty query set. > > > What am I missing? > > > Cheers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User's permissions not updated
Hey, I added a class "News" to models.py of an installed app. But its permissions doesn't appear in the Change User View of the admin interface. Need it to be activated somehow? As superuser I can use News. I use .96-pre Thanks, Manuel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Derived, read-only attributes in the admin
Hi I have a fairly simple use-case which I feel should be achievable, but which I'm not able to pull off. What I want is the ability to modify the base query used by the admin to add some derived properties. For example, if you have Orders with corresponding OrderLines, it's useful to add the subtotal for each order in the order list. To achieve this I tried the following: class OrderAdminManager(models.Manager): def get_query_set(self): return super(OrderAdminManager, self).get_query_set().extra( select={'order_total': '(select sum(quantity * item_price) from webshop_orderline where order_id = webshop_order.id)'}) And in the inner Admin class I added this line: manager = OrderAdminManager() The net result of this is that the query result contains the order_total column, and I can display it in the admin, but only if I do so using a custom method, which means no sorting and no filtering. If I try to add "order_total" as a non-editable field it blows up when Django queries for webshop.order_total. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango : Error in admin site with geom fields
Hi, I've build up a small geodjango app. Using the admin-site to view the records of my table gives me : /usr/lib/libgeos_c.so: undefined symbol: GEOSGeomFromHEX_buf my geos version is 3.0.0.RC4 my model is : class commune(models.Model, models.GeoMixin): depcom = models.CharField(maxlength=5, primary_key=True) nom = models.CharField(maxlength=100) dep = models.CharField(maxlength=3,db_index=True) cheflieu = models.PositiveSmallIntegerField() ct = models.CharField(maxlength=5) ar = models.CharField(maxlength=4) cdc = models.CharField(maxlength=1,null=True) rang = models.CharField(maxlength=1,null=True) depar = models.CharField(maxlength=4) depct = models.CharField(maxlength=5) pop1999 = models.IntegerField(null=True) uu = models.CharField(maxlength=5,null=True) rang_uu = models.CharField(maxlength=30,null=True) the_geom = models.MultiPolygonField(srid=27572) objects = models.GeoManager() class Admin: pass any idea ? Thanks Guillaume --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting "blank" to one Field?
Shouldn't the empty string be equivalent to blank? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
filtering based on property
Hi, is it possible to do filtering based on a method or a property of the model? Say I have a model with a from_date field and a to_date field and a method, defined within the model, which checks if the model instance is current, that is: from datetime import date @property def is_current(self): return self.from_date <= date.today() and self.to_date >= date.today() is there any way, in the manager, to do something like MyModel.objects.filter(is_current=True) ? Thanks and regards Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: caching and authentication
thanks for the answer. we _are_ doing a redirect on logout. On 16 Sep., 16:17, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 9/13/07, patrickk <[EMAIL PROTECTED]> wrote: > > > if 2 users are logged in, the username is displayed correctly for each > > user. BUT: if a user is logged-out, his/her username is still > > displayed. something doesn´t seem to work here and I can´t figure out > > what´s wrong. > > If a user logs out, the 'request.user' attribute is not updated > immediately; it will become an AnonymousUser instance on the *next* > request, not on the one in which the user is logging out. This is why > it's always a good idea to redirect after doing a logout, because that > "clears" request.user. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: caching and authentication
On 9/13/07, patrickk <[EMAIL PROTECTED]> wrote: > if 2 users are logged in, the username is displayed correctly for each > user. BUT: if a user is logged-out, his/her username is still > displayed. something doesn´t seem to work here and I can´t figure out > what´s wrong. If a user logs out, the 'request.user' attribute is not updated immediately; it will become an AnonymousUser instance on the *next* request, not on the one in which the user is logging out. This is why it's always a good idea to redirect after doing a logout, because that "clears" request.user. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: caching and authentication
does anyone have an idea? we should go online with our site tomorrow and I don´t have a clue on how to solve this problem. thanks, patrick On 13 Sep., 10:23, patrickk <[EMAIL PROTECTED]> wrote: > one additional note: > if 2 users are logged in, the username is displayed correctly for each > user. BUT: if a user is logged-out, his/her username is still > displayed. something doesn´t seem to work here and I can´t figure out > what´s wrong. > > On 13 Sep., 10:14, patrickk <[EMAIL PROTECTED]> wrote: > > > I´ve upgraded to the current trunk and it´s still not working. > > > this is my views: > > > def top_imagegalleries(request): > > ... > > > response = render_to_response('site/container/ > > topimagegalleries.html', { > > 'object_list_left': rendered_object_list_left, > > 'object_list_right': rendered_object_list_right, > > 'category': 'filme', > > 'subcategory': 'bildgalerien', > > 'site_title': 'Bildgalerien', > > 'title': 'Bildgalerien', > > 'sidebar_list': rendered_sidebar_list, > > 'limit': limit.limit, > > }, context_instance=RequestContext(request) ) > > patch_vary_headers(response, ['Cookie']) > > return response > > top_imagegalleries = cache_page(top_imagegalleries, 60 * 15) > > > My username is still displayed on the page when I´m logged out. > > For most of our pages, we use cached blocks within the site, but that > > doesn´t work for all the pages we have. We have to cache some high- > > traffic pages as a "whole" (still displaying the right username > > though). > > > thanks, > > patrick > > > On 29 Aug., 17:33, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > > > > It's clear to me that the docs involving patch_vary_header, cache_page > > > and the cache middleware need to be improved. > > > > I'm using this thread as proof. :) > > > > The cache_page decorator is actually just a wrapper around the cache > > > middleware; think of it as view-specific application ofthe cache > > > middleware. > > > > In any case, thepatch_vary_headers*should* work with the cache_page > > > decorator; the decorator forms the cache key based on the response. > > > This is a separate problem from the unicode issue. > > > > Can you provide any info on what isn't working as expected with > > > thepatch_vary_headerscall? > > > > On 8/29/07, patrickk <[EMAIL PROTECTED]> wrote: > > > > > I´ve been too optimistic - the above code doesn´t work. > > > > (This wholecaching-issue gives me the willies) > > > > > On 29 Aug., 12:21, patrickk <[EMAIL PROTECTED]> wrote: > > > > > it´s a bit late, but I just wanted to tell that it works with > > > > >patch_vary_headers. > > > > > in my opinion, this could be explained better in the docs. > > > > > > so, if one uses a page based on user-authenticationand wants to cache > > > > > that page using the cache_page decorator, here´s the code: > > > > > > def my_view(request): > > > > > > > > > > > response = render_to_response('site/whatever/template.html', { > > > > > ... > > > > > }, context_instance=RequestContext(request) ) > > > > >patch_vary_headers(response, ['Cookie']) > > > > > return response > > > > > my_view = cache_page(may_view, 60 * 15) > > > > > > thanks, > > > > > patrick > > > > > > On 8 Jul., 01:18, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > > > > > > > On 7/7/07, patrick k. <[EMAIL PROTECTED]> wrote: > > > > > > > > I don´t understand why the page_cache is keyed by the vary header > > > > > > > and > > > > > > > the view_cache is not. is there a reason for this? > > > > > > > You mean cache_page rather than page_cache, but what is view_cache? > > > > > > > I think I may have spotted the problem: the cache_page decorator > > > > > > runs > > > > > > before the Vary header gets patched for the session access. > > > > > > > As a test, just before you return your HttpResponse, try adding this > > > > > > to one of your auth views, and try to use the cache_page decorator: > > > > > > > from django.utils.cacheimportpatch_vary_headers > > > > > >patch_vary_headers(response, ('Cookie',)) > > > > > > > (Maye sure to dump yourcachefirst, too.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generating Q objects for different model fields
> I'd like to make a filter composed by ORing several Q objects, each of > which acts on a different model field. > For example I have a model with the fields "name", "title", > "description" and I want to make a Q object like the following: > Q_name = (Q(name__istartswith="hello") & Q(name__icontains="how are > you")) > Q_title = (Q(title__istartswith="hello") & Q(title__icontains="how are > you")) > Q_description = (Q(description__istartswith="hello") & > Q(description__icontains="how are you")) > Q_final = (Q_name | Q_title | Q_description) > > Is it possible to avoid writing a Q object for each field and instead > simply generate it by passing the field (name, title and description) > as parameter? Just as an aside, the Q object takes multiple parameters that get AND'ed together, so those can be written in the form Q_name = Q( name__istartswith='hello', name__icontains='how are you' ) without the need for two diff. objects to "&" together. You can write a helper function and then use keyword expansion to do the heavy lifting if you wanted. That would look something like def start_has(fieldname, start, contain): return { fieldname + '__istartswith': start, fieldname + '__icontains': contain, } Q_name = Q(**start_has('name', 'hello', 'how are you')) Q_description = Q(**start_has('description', 'hello', 'how are you')) Q_title = Q(**start_has('name', 'title', 'how are you')) If this is within a view, you can even exploit closures (I think this is a use of a closure) to do something like def my_view(request, *args, **kwargs): start = 'hello' # assign from request has = 'how are you' # assign from request def start_has(fieldname): return { fieldname + '__istartswith': start, fieldname + '__icontains': has, } things = models.Thing.objects.filter( Q(**start_has('name')) | Q(**start_has('title')) | Q(**start_has('description')) ) The above is 100% untested, but should work from what I've done with Python/Django in the past, perhaps with a few lurking errors I might have missed. -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
OVER 10,000 People Join Every Week! FREE SIGN-UP! CLICK HERE!
OVER 10,000 People Join Every Week! FREE SIGN-UP! CLICK HERE! http://www.blpurl.com/al42 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Generating Q objects for different model fields
Hi, I'd like to make a filter composed by ORing several Q objects, each of which acts on a different model field. For example I have a model with the fields "name", "title", "description" and I want to make a Q object like the following: Q_name = (Q(name__istartswith="hello") & Q(name__icontains="how are you")) Q_title = (Q(title__istartswith="hello") & Q(title__icontains="how are you")) Q_description = (Q(description__istartswith="hello") & Q(description__icontains="how are you")) Q_final = (Q_name | Q_title | Q_description) Is it possible to avoid writing a Q object for each field and instead simply generate it by passing the field (name, title and description) as parameter? One way could be to generate the string and pass it to eval() but I'd like to avoid that. Any help would be appreciated. Thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with generic views (404)
On 9/16/07, Florian Lindner <[EMAIL PROTECTED]> wrote: > {% if Abbreviation_list %} Read the generic views documentation carefully; the default variable name the view will give you is "object_list". -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with generic views (404)
Am Sonntag, 16. September 2007 schrieb Collin Grady: > Do you actually have any Abbreviation objects? > > If you don't tell the view to allow empty results, it'll 404 if it has > nothing to show :) Yes, this was the problem, thanks! However I ran into the next problem just 5 minutes later. I have an template that is used for this generic view: {% if Abbreviation_list %} {% for abbr in Abbreviation_list %} {{ abbr.abbreviation }} {% endfor %} {% else %} No abbreviations are available. {% endif %} That just gives: "No abbrevations...". If I remove the if clause there is just in the HTML source code. But there are objects: [EMAIL PROTECTED] ~/xgm $ ./manage.py shell Python 2.4.4 (#1, May 13 2007, 13:02:35) [GCC 4.1.1 (Gentoo 4.1.1-r3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from xgm.AbbrDB.models import * >>> Abbreviation.objects.all() [, ] Everything is unchanged compared to my previous post. Thanks, Florian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting "blank" to one Field?
I suppose that it were exists. Because if we put no value in the database in one ForeignKey (in admin mode), then we could revert the value to blank. Internally I don't know how store blank values (if null is not True), but I think that it could be set someway Well, thanks, I will change all my blank=True for null=True Thanks a lot, Xan. On Sep 16, 12:33 am, Collin Grady <[EMAIL PROTECTED]> wrote: > There is no such thing as blank, especially on a ForeignKey. > > blank=True has absolutely nothing to do with the database, as the > documentation for it clearly states :) > > It merely makes it so you can give it no value in form validation, > like in admin. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---