Re: Send e-mail with large files from form attached
Oh. I get it, sorry. Any suggestions on my next question about file.read() would be thankful. On Mar 19, 5:20 pm, Paulo Almeida <igcbioinformat...@gmail.com> wrote: > Hi, > > My suggestion to zip the files was to provide a single download link with > all the files. > > - Paulo > > On Fri, Mar 19, 2010 at 1:43 PM, tezro <tezro...@gmail.com> wrote: > > Thanks for reply. I tried both variants before the post :) Nothing > > suited me and the customer. > > > When a-mailng files are uploaded to RAM anyway, zipping files just > > don't really help on binary data. I chosed to save them to a web- > > visible location. > > > On Mar 18, 7:59 pm, Paulo Almeida <igcbioinformat...@gmail.com> wrote: > > > I can't help you with the technical part, but a couple of suggestions: > > > > * Sum the size of the images and send two (or more) e-mails if it exceeds > > a > > > threshold > > > * Forget attachments and just zip the images and make them accessible in > > an > > > URL that is e-mailed to the site admin > > > > - Paulo > > > > On Wed, Mar 17, 2010 at 8:57 AM, tezro <tezro...@gmail.com> wrote: > > > > Hello everyone. I need some help or advice. > > > > > I've got a form with 20 ImageFields - such a form for sending photos > > > > to the site admin as a request for a new user. Well, Django certainly > > > > handles and uploads the, that's OK. But when it comes to sending all > > > > the files as an attachment - I got stuck. > > > > > Here's a simple example of how I tried to do that: > > > > > > > > from django.core.mail import EmailMessage > > > > > email = EmailMessage() > > > > for (k, v) in request.FILES.items(): > > > > email.attach(v.name, v.read()) > > > > > > > > > Small files are read nicely. But when someone "clever" fills out all > > > > the form files (all the twenty) with images each one at least 10 Mb - > > > > Django consumes so much memory... so I'm not in knowledge to handle > > > > that. > > > > > Please, guide me how to handle big files from a form and send them > > > > without memory leaks. Thanks ahead. > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Django users" group. > > > > To post to this group, send email to django-us...@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > > <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com> > > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Send e-mail with large files from form attached
Thanks for reply. I tried both variants before the post :) Nothing suited me and the customer. When a-mailng files are uploaded to RAM anyway, zipping files just don't really help on binary data. I chosed to save them to a web- visible location. On Mar 18, 7:59 pm, Paulo Almeida <igcbioinformat...@gmail.com> wrote: > I can't help you with the technical part, but a couple of suggestions: > > * Sum the size of the images and send two (or more) e-mails if it exceeds a > threshold > * Forget attachments and just zip the images and make them accessible in an > URL that is e-mailed to the site admin > > - Paulo > > On Wed, Mar 17, 2010 at 8:57 AM, tezro <tezro...@gmail.com> wrote: > > Hello everyone. I need some help or advice. > > > I've got a form with 20 ImageFields - such a form for sending photos > > to the site admin as a request for a new user. Well, Django certainly > > handles and uploads the, that's OK. But when it comes to sending all > > the files as an attachment - I got stuck. > > > Here's a simple example of how I tried to do that: > > > > from django.core.mail import EmailMessage > > > email = EmailMessage() > > for (k, v) in request.FILES.items(): > > email.attach(v.name, v.read()) > > > > > Small files are read nicely. But when someone "clever" fills out all > > the form files (all the twenty) with images each one at least 10 Mb - > > Django consumes so much memory... so I'm not in knowledge to handle > > that. > > > Please, guide me how to handle big files from a form and send them > > without memory leaks. Thanks ahead. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Send e-mail with large files from form attached
Hi. All that you say is totally clear to me, but I tried to suit the customer's needs. And, yes, I finished my deals on just saving the images serverside and sending links to files over e-mail. Thanks for that. Another question that bothers me is the following. - for (k, v) in request.FILES.items(): file_data = open('%s/%s' % (dir, filename), 'wb') file_data.write(v.read()) file_data.close() - That's not all the loop but that's enough to understand that I write uploaded files to another location to give a link in e-mail. I'm not really sure if it's correct - the files after upload are saved to temp directory or RAM, but I actually read them again "v.read()" to save to another loaction. Is that ok? Is there other way to save uploaded files without reading them again? Thanks. On Mar 18, 8:19 pm, Jirka Vejrazkawrote: > > I've got a form with 20 ImageFields - such a form for sending photos > > to the site admin as a request for a new user. Well, Django certainly > > handles and uploads the, that's OK. But when it comes to sending all > > thefilesas an attachment - I got stuck. > > Smallfilesare read nicely. But when someone "clever" fills out all > > the formfiles(all the twenty) with images each one at least 10 Mb - > > Django consumes so much memory... so I'm not in knowledge to handle > > that. > > Hi, > > emailis not really suitable for sendinglargeamounts of data. The > fact that people use it that way is a bit sad, but you should not > really follow their example. > > So, you're trying to send up to 200 MB viaemail. That's in fact > some 270 MB, because binary data is base64 encoded in emails, > typically (not always, but often). That is the reason for the memory > problem. > > As Paulo pointed out, created a unique, temporary URL for > downloading those images and send just the link to that URL. > > HTH > > Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Send e-mail with large files from form attached
Hello everyone. I need some help or advice. I've got a form with 20 ImageFields - such a form for sending photos to the site admin as a request for a new user. Well, Django certainly handles and uploads the, that's OK. But when it comes to sending all the files as an attachment - I got stuck. Here's a simple example of how I tried to do that: from django.core.mail import EmailMessage email = EmailMessage() for (k, v) in request.FILES.items(): email.attach(v.name, v.read()) Small files are read nicely. But when someone "clever" fills out all the form files (all the twenty) with images each one at least 10 Mb - Django consumes so much memory... so I'm not in knowledge to handle that. Please, guide me how to handle big files from a form and send them without memory leaks. Thanks ahead. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Humble-structure sites on Django // Suggestion needed
Thanks for reply. The main trouble for me is nearly how to do that "right" with the MVT layer. I'm not really sure how to write models for such a small yet compound structure. How do I make, say, the first and second pages (about and contacs) with some different fields? I will reproduce the method for all other pages and repost here or question it again. On Dec 19, 11:09 pm, Brian McKeever <kee...@gmail.com> wrote: > I'm not sure I'm entirely understanding your question, but yes, that > does look easy to implement with django. > > What part is troubling you? You seem to have a good idea of what you > want. > > On Dec 17, 6:42 am, tezro <tezro...@gmail.com> wrote: > > > Hello everyone. Making well-structured websites on Django is a very > > comprehensive process. All these blogs, news, user-related stuff - > > easy. But what about, say, corporate website? I mean I got a project > > to do, thought it would be great to base it on Django as usual, but... > > > Look at the structure, it's pretty easy. > > > / > > ––/about/ > > ––/contacts/ > > ––/history/ > > ––/projects/ > > /project1/ > > /project2/ > > /project3/ > > > All the pages should have some meta fields, text field to show, slug - > > something that is common for all pages. Now what is different for all > > that pages. > > > Contacts page in addition to common fields should have fields in admin > > to edit: 2-4 phone numbers, link to Gmap, ImageField and a ForeignKey > > for people related to contacts page (separate model with some fields). > > > Projects page should have an ImageField too and a ForeignKey for some > > projects (separate model with some fields). > > > About page should have ImageField, 2-5 FileFields, another TextField > > and some files as a ForeignKey model. > > > So, as you see, there should be a number of different editable... > > things. All of them with differend fields and some with related > > models... > > > Is it really easy to implement using Django? I'm not really sure how > > to do that... > > > Thanks for replies ahead. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Humble-structure sites on Django // Suggestion needed
Hello everyone. Making well-structured websites on Django is a very comprehensive process. All these blogs, news, user-related stuff - easy. But what about, say, corporate website? I mean I got a project to do, thought it would be great to base it on Django as usual, but... Look at the structure, it's pretty easy. / ––/about/ ––/contacts/ ––/history/ ––/projects/ /project1/ /project2/ /project3/ All the pages should have some meta fields, text field to show, slug - something that is common for all pages. Now what is different for all that pages. Contacts page in addition to common fields should have fields in admin to edit: 2-4 phone numbers, link to Gmap, ImageField and a ForeignKey for people related to contacts page (separate model with some fields). Projects page should have an ImageField too and a ForeignKey for some projects (separate model with some fields). About page should have ImageField, 2-5 FileFields, another TextField and some files as a ForeignKey model. So, as you see, there should be a number of different editable... things. All of them with differend fields and some with related models... Is it really easy to implement using Django? I'm not really sure how to do that... Thanks for replies ahead. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
Nope. Sorry for misdescription... Same error is "TypeError: 'slug' is an invalid keyword argument" when using: --- new_element = Element(title="title", date=datetime.now(), source=source_object, slug="slug") new_element.save() --- And the same "_mysql_exceptions.Warning: Field 'slug' doesn't have a default value" when using: --- new_element = Element(title="title", date=datetime.now(), source=source_object) new_element.slug = "slug" new_element.save() --- The same errors from an outer script. From the shell or admin site - works still fine... On Dec 12, 5:56 pm, Shawn Milochik <sh...@milochik.com> wrote: > On Dec 12, 2009, at 8:08 AM, tezro wrote: > > > Nope. Did it again on a clean project with the same models migrated > > then by South. > > > Same error. Any other clues? > > > Thanks for replies. > > When you say "same error," do you mean this one: "Duplicate key name > 'news_element_slug'"? > > If so, then it appears that, despite the clean project, it's not a clean > database. Try using sqlite3 temporarily, or change the model name from News > to NewsTest or something. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
Nope. Did it again on a clean project with the same models migrated then by South. Same error. Any other clues? Thanks for replies. On Dec 12, 3:25 am, Shawn Milochikwrote: > Why did you manually add a 'slug' field to your database after modifying the > model? Django's syncdb does a lot more than just create the field; depending > on which database you're using, it does a few other things and overrides some > defaults. I wonder if there's a disconnect there. If this project is > currently in production and you can't re-run syncdb, then I highly recommend > South (south.aeracode.org) for database migrations. > > I suspect that the problem is because the field was added manually. Try > adding the field with South. It takes care of the nitty gritty details for > you. > > Worst-case, make a copy of the model in question with a different name. Then > try to create new instances of it from your external script. If that works > (after adding that new model to the database with syncdb), then it's almost > definitely due to the way the model and database were modified after-the-fact > manually. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
Oops, sorry. Didn't remove the index. Now it worked. Proceeding :) On Dec 12, 3:51 pm, tezro <tezro...@gmail.com> wrote: > Added a migration with South... Ran it. > > --- > Running migrations for news: > - Migrating forwards to 0002_add_slug. > > news: 0002_add_slug > Traceback (most recent call last): > File "/home/tezro/lib/python2.5/South-0.6.2-py2.5.egg/south/ > migration.py", line 330, in run_migrations > db.execute_deferred_sql() > File "/home/tezro/lib/python2.5/South-0.6.2-py2.5.egg/south/db/ > generic.py", line 120, in execute_deferred_sql > self.execute(sql) > File "/home/tezro/lib/python2.5/South-0.6.2-py2.5.egg/south/db/ > generic.py", line 86, in execute > cursor.execute(sql, params) > File "/home/tezro/apps/apache_django/lib/python2.5/django/db/ > backends/mysql/base.py", line 84, in execute > return self.cursor.execute(query, args) > File "/usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py", > line 166, in execute > self.errorhandler(self, exc, value) > File "/usr/local/lib/python2.5/site-packages/MySQLdb/ > connections.py", line 35, in defaulterrorhandler > raise errorclass, errorvalue > OperationalError: (1061, "Duplicate key name 'news_element_slug'") > --- > > By the way, there was no slug field in the base. I made it the initial > way, just like I've never changed anything. > > On Dec 12, 3:25 am, Shawn Milochik <sh...@milochik.com> wrote: > > > Why did you manually add a 'slug' field to your database after modifying > > the model? Django's syncdb does a lot more than just create the field; > > depending on which database you're using, it does a few other things and > > overrides some defaults. I wonder if there's a disconnect there. If this > > project is currently in production and you can't re-run syncdb, then I > > highly recommend South (south.aeracode.org) for database migrations. > > > I suspect that the problem is because the field was added manually. Try > > adding the field with South. It takes care of the nitty gritty details for > > you. > > > Worst-case, make a copy of the model in question with a different name. > > Then try to create new instances of it from your external script. If that > > works (after adding that new model to the database with syncdb), then it's > > almost definitely due to the way the model and database were modified > > after-the-fact manually. > > > Shawn > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
Added a migration with South... Ran it. --- Running migrations for news: - Migrating forwards to 0002_add_slug. > news: 0002_add_slug Traceback (most recent call last): File "/home/tezro/lib/python2.5/South-0.6.2-py2.5.egg/south/ migration.py", line 330, in run_migrations db.execute_deferred_sql() File "/home/tezro/lib/python2.5/South-0.6.2-py2.5.egg/south/db/ generic.py", line 120, in execute_deferred_sql self.execute(sql) File "/home/tezro/lib/python2.5/South-0.6.2-py2.5.egg/south/db/ generic.py", line 86, in execute cursor.execute(sql, params) File "/home/tezro/apps/apache_django/lib/python2.5/django/db/ backends/mysql/base.py", line 84, in execute return self.cursor.execute(query, args) File "/usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py", line 166, in execute self.errorhandler(self, exc, value) File "/usr/local/lib/python2.5/site-packages/MySQLdb/ connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (1061, "Duplicate key name 'news_element_slug'") --- By the way, there was no slug field in the base. I made it the initial way, just like I've never changed anything. On Dec 12, 3:25 am, Shawn Milochik <sh...@milochik.com> wrote: > Why did you manually add a 'slug' field to your database after modifying the > model? Django's syncdb does a lot more than just create the field; depending > on which database you're using, it does a few other things and overrides some > defaults. I wonder if there's a disconnect there. If this project is > currently in production and you can't re-run syncdb, then I highly recommend > South (south.aeracode.org) for database migrations. > > I suspect that the problem is because the field was added manually. Try > adding the field with South. It takes care of the nitty gritty details for > you. > > Worst-case, make a copy of the model in question with a different name. Then > try to create new instances of it from your external script. If that works > (after adding that new model to the database with syncdb), then it's almost > definitely due to the way the model and database were modified after-the-fact > manually. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
Wooof, thanks for reply. Well, look. I had a "news/models.py" file with definitions of Source (type of news) and Element(the news elements theirselves) with a foreign key "Source". The script I used to gather news from different sites looks like this: --- title = "title" date=datetime.now()) new_element = Element(title=title, date=date, source=source_object) new_element.save() --- Element's "get_absolute_url" returned "/news/2009/jan/12/7788/" according to PK, wich is 7788 here. Then, I decided to make slugs for news elements so that it returned some "useful" urls. I added "slug = models.SlugField(max_length=200)" to the model and added char field "slug" to mysql database. Then, changed the script adding a slug field either to manual or "slugifying it" from title - nothing worked: --- title = "title" date=datetime.now()) slug = "test-slug" #or slugify(title) new_element = Element(title=title, date=date, source=source_object, slug=slug) new_element.save() --- It keeps falling with that TypeError above. And... it throws "_mysql_exceptions.Warning: Field 'slug' doesn't have a default value" - fixing that from model or base doesn't help either. But... the code works from the shell fine. That's all. On Dec 12, 12:58 am, Shawn Milochik <sh...@milochik.com> wrote: > On Dec 11, 2009, at 4:51 PM, tezro wrote: > > > > > Seems like no clues... > > > On Dec 10, 12:21 am, bruno desthuilliers > > <bruno.desthuilli...@gmail.com> wrote: > >> On 9 déc, 18:58, tezro <tezro...@gmail.com> wrote: > >> (snip) > > >>> That throws an error: TypeError: 'slug' is an invalid keyword argument > >>> for this function. > > >>> What am I doing wrong? > > >> Not posting the full traceback - tracebacks are here to help debugging > >> a problem, not to fill your term with random gibberish !-) > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > Tezro, > > What Bruno meant is that, unless you post *all* of the text that printed out > around the error message (not just that one line), you have not provided > enough information for us to help you. > > Anyone on this list can probably tell you exactly what that TypeError means. > But telling you that won't solve your problem. > > This error: > > >>> TypeError: 'slug' is an invalid keyword argument > > means that somewhere in your Python code, the keyword argument slug = "some > value" is being passed to a function. That function doesn't know what to do > with a 'slug' keyword, because that function's definition doesn't accept it, > nor does it have a **kwargs portion. > > So, although I've told you what the problem is, I haven't helped you much > with your question "what am I doing wrong." But if you provide more of the > information about the error, and preferably the section of code that is > generating it, you will get help that is much more useful to solving the > problem. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
Seems like no clues... On Dec 10, 12:21 am, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On 9 déc, 18:58, tezro <tezro...@gmail.com> wrote: > (snip) > > > > > That throws an error: TypeError: 'slug' is an invalid keyword argument > > for this function. > > > What am I doing wrong? > > Not posting the full traceback - tracebacks are here to help debugging > a problem, not to fill your term with random gibberish !-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-tagging - how to get current page number in a template
Firstly, we have simple template. --- {% load pagination_tags %} {% block first_column %} {% autopaginate object_list %} {% paginate %} {% endblock %} --- Suppose, we have "second_column", so how do I get the current page number, number of all pages paginated, or even next/previous page link, if it matters, exactly in other block? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error creating and saving a Django-object from the other script
That was really smart of you, thanks... Here's the traceback, hope it helps. --- Traceback (most recent call last): File "", line 1, in File "robot_parser.py", line 383, in update news = Element(source = the_source, title = title, date = date_published, short = short, full = full, link = link, slug = the_slug) news.save() File "/lib/python2.5/django/db/models/base.py", line 323, in __init__ raise TypeError, "'%s' is an invalid keyword argument for this function" % kwargs.keys()[0] TypeError: 'slug' is an invalid keyword argument for this function --- On Dec 10, 12:21 am, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On 9 déc, 18:58, tezro <tezro...@gmail.com> wrote: > (snip) > > > > > That throws an error: TypeError: 'slug' is an invalid keyword argument > > for this function. > > > What am I doing wrong? > > Not posting the full traceback - tracebacks are here to help debugging > a problem, not to fill your term with random gibberish !-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Error creating and saving a Django-object from the other script
Hi everyone. I'm using Django 1.1.0, importing it and using in another file "robot_parser.py". I've been using it for months. The script aggregates news from different sources and saves them using Django ORM. Presently I used primary key for urls (http://www.site.com/ news/2009/jan/12/72828/), but then decided to use "slugs" (http:// www.site.com/news/2009/jan/12/slug-of-the-news/). I changed the model adding slug field. --- class Element(models.Model): date = models.DateTimeField() title = models.CharField(max_length=200) slug = models.SlugField(max_length=200) --- Also I added a field to MySQL table. Here's the code that adds an element from the "robot_parser.py". --- title = "test title" slug = slugify(title) new_element = Element(title=title, slug=slugify(title), date=datetime.now()) new_element.save() --- That throws an error: TypeError: 'slug' is an invalid keyword argument for this function. What am I doing wrong? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: "django-pagination" and generic.views.date_based.archive_index()
Thanks again. Did it with object_list. Thanks for help :) On Oct 19, 2:16 pm, Михаил Лукин <mihail.lu...@googlemail.com> wrote: > Finally, I see only 3 ways: > 1. copy/paste archive index code and change it's behaviour so it can eat > num_latest=None > 2. patch date_based.py in same way as (1) > 3. use list_detail.object_list > Since 1-2 are dirty, I would recommend 3rd way. I'll let you know if I could > suggest something else :) > > 2009/10/19 tezro <tezro...@gmail.com> > > > > > > > Surely I could use the list_detail.object_list, but the use of date > > based generics though )) > > > On Oct 18, 11:45 pm, Михаил Лукин <mihail.lu...@googlemail.com> wrote: > > > Sorry, didn't look at condition well...:( > > > > So, you see the source and you see that there's no way to get all the > > > records with this view. > > > Why don't you use list_detail.object_list view? If you need just to order > > > list by date, you can use ordering on the model level: > >http://docs.djangoproject.com/en/dev/ref/models/options/#ordering > > > > 2009/10/18 tezro <tezro...@gmail.com> > > > > > Would it? If "latest=None" doesn't it mean that there are no entries? > > > > > By the way, if I pass None to the condition, it returns False, so > > > > latest is None. > > > > > Or isn't it? > > > > > Also the template cannot render it, cause "object of type 'NoneType' > > > > has no len()". > > > > > Anyways, thanks for reply :) > > > > > On Oct 18, 11:04 pm, Mihail Lukin <mihail.lu...@googlemail.com> wrote: > > > > > Look at date_based.py: > > > > > > if date_list and num_latest: > > > > > latest = queryset.order_by('-'+date_field)[:num_latest] > > > > > else: > > > > > latest = None > > > > > > So, if you use num_latest=None, you will always get the whole list. > > > > > > On Aug 30, 2:47 pm, tezro <tezro...@gmail.com> wrote: > > > > > > > Anyone? > > > > > > > On Aug 14, 8:29 am, tezro <tezro...@gmail.com> wrote: > > > > > > > > The question is that > > > > "django.views.generic.date_based.archive_index()" > > > > > > > takes an optional argument "num_latest" which is 15 by default. > > > > > > > Setting it manually to num_latest=10 is way off to > > correct to > > > > > > > me. It works. I suppose that it even doesn't retrieve all the > > tons of > > > > > > > data from the DB, but what if I have 10 + 1 record :) > > > > > > > > What's the right way to use "django-pagination" and the > > > > "archive_index > > > > > > > ()" or am I missing something? > > > > > > > > Example code. > > > > > > > ___ > > > > > > > > def index(request): > > > > > > > qs = News.objects.filter(is_published=1) > > > > > > > return archive_index(request, qs, 'date', > > > > num_latest=1) > > > > > > > ___ > > > > > > > > Thanks. > > > > -- > > > regards, > > > Mihail > > -- > regards, > Mihail --~--~-~--~~~---~--~~ 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-pagination" and generic.views.date_based.archive_index()
Surely I could use the list_detail.object_list, but the use of date based generics though )) On Oct 18, 11:45 pm, Михаил Лукин <mihail.lu...@googlemail.com> wrote: > Sorry, didn't look at condition well...:( > > So, you see the source and you see that there's no way to get all the > records with this view. > Why don't you use list_detail.object_list view? If you need just to order > list by date, you can use ordering on the model > level:http://docs.djangoproject.com/en/dev/ref/models/options/#ordering > > 2009/10/18 tezro <tezro...@gmail.com> > > > > > > > Would it? If "latest=None" doesn't it mean that there are no entries? > > > By the way, if I pass None to the condition, it returns False, so > > latest is None. > > > Or isn't it? > > > Also the template cannot render it, cause "object of type 'NoneType' > > has no len()". > > > Anyways, thanks for reply :) > > > On Oct 18, 11:04 pm, Mihail Lukin <mihail.lu...@googlemail.com> wrote: > > > Look at date_based.py: > > > > if date_list and num_latest: > > > latest = queryset.order_by('-'+date_field)[:num_latest] > > > else: > > > latest = None > > > > So, if you use num_latest=None, you will always get the whole list. > > > > On Aug 30, 2:47 pm, tezro <tezro...@gmail.com> wrote: > > > > > Anyone? > > > > > On Aug 14, 8:29 am, tezro <tezro...@gmail.com> wrote: > > > > > > The question is that > > "django.views.generic.date_based.archive_index()" > > > > > takes an optional argument "num_latest" which is 15 by default. > > > > > Setting it manually to num_latest=10 is way off to correct to > > > > > me. It works. I suppose that it even doesn't retrieve all the tons of > > > > > data from the DB, but what if I have 10 + 1 record :) > > > > > > What's the right way to use "django-pagination" and the > > "archive_index > > > > > ()" or am I missing something? > > > > > > Example code. > > > > > ___ > > > > > > def index(request): > > > > > qs = News.objects.filter(is_published=1) > > > > > return archive_index(request, qs, 'date', > > num_latest=1) > > > > > ___ > > > > > > Thanks. > > -- > regards, > Mihail --~--~-~--~~~---~--~~ 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-pagination" and generic.views.date_based.archive_index()
Would it? If "latest=None" doesn't it mean that there are no entries? By the way, if I pass None to the condition, it returns False, so latest is None. Or isn't it? Also the template cannot render it, cause "object of type 'NoneType' has no len()". Anyways, thanks for reply :) On Oct 18, 11:04 pm, Mihail Lukin <mihail.lu...@googlemail.com> wrote: > Look at date_based.py: > > if date_list and num_latest: > latest = queryset.order_by('-'+date_field)[:num_latest] > else: > latest = None > > So, if you use num_latest=None, you will always get the whole list. > > On Aug 30, 2:47 pm, tezro <tezro...@gmail.com> wrote: > > > Anyone? > > > On Aug 14, 8:29 am, tezro <tezro...@gmail.com> wrote: > > > > The question is that "django.views.generic.date_based.archive_index()" > > > takes an optional argument "num_latest" which is 15 by default. > > > Setting it manually to num_latest=10 is way off to correct to > > > me. It works. I suppose that it even doesn't retrieve all the tons of > > > data from the DB, but what if I have 10 + 1 record :) > > > > What's the right way to use "django-pagination" and the "archive_index > > > ()" or am I missing something? > > > > Example code. > > > ___ > > > > def index(request): > > > qs = News.objects.filter(is_published=1) > > > return archive_index(request, qs, 'date', num_latest=1) > > > ___ > > > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "django-pagination" and generic.views.date_based.archive_index()
Anyone? On Aug 14, 8:29 am, tezro <tezro...@gmail.com> wrote: > The question is that "django.views.generic.date_based.archive_index()" > takes an optional argument "num_latest" which is 15 by default. > Setting it manually to num_latest=10 is way off to correct to > me. It works. I suppose that it even doesn't retrieve all the tons of > data from the DB, but what if I have 10 + 1 record :) > > What's the right way to use "django-pagination" and the "archive_index > ()" or am I missing something? > > Example code. > ___ > > def index(request): > qs = News.objects.filter(is_published=1) > return archive_index(request, qs, 'date', num_latest=1) > ___ > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"django-pagination" and generic.views.date_based.archive_index()
The question is that "django.views.generic.date_based.archive_index()" takes an optional argument "num_latest" which is 15 by default. Setting it manually to num_latest=10 is way off to correct to me. It works. I suppose that it even doesn't retrieve all the tons of data from the DB, but what if I have 10 + 1 record :) What's the right way to use "django-pagination" and the "archive_index ()" or am I missing something? Example code. ___ def index(request): qs = News.objects.filter(is_published=1) return archive_index(request, qs, 'date', num_latest=1) ___ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---