Re: Import csv file in admin
> I try to follow the ideas, but i feel like taking the dirty way. > Here's my work: > Because i can't replace the modelform created by the admin for the > "Data" model with a standard form as the Django docs says, i created a > view to replace the "add" view generated by the admin and put a > standard form: Jorge, I think you need to get back to basics and try to understand what is run where. All the code you are writing for Django is run on the server and only web pages are *displayed* to users on their machines. This means that in order to import a CSV file, you need to transfer it to the server first and then you'll be able to import it there. Note that this has nothing to do with the admin site. This is a fundamental think to understand. I'd suggest that you forget the admin site for the moment and focus on the "transfer CSV file to server first". Take a look at the email Felix has sent you regarding FileField and try to code the part that handles file upload to the server. Once you have that, you can start thinking about importing the contents of the file into the database. Cheers Jirka P.S. OK, there is a way to import data without uploading them to server first, but it's much more complicated than the one outlined above and involves multiple different technologies that have to work together. -- 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.
Local testing setup with Python 2.7 OS X installer, mod_wsgi and Apache?
the Python 2.7 OS X installer builds a 'fat' Python install, which *should work* with the OS X Apache2 install and mod_wsgi. The Python 2.6 OS X installer didn't support 64 bit architectures, necessitating Apache2 to be trimmed 32 bit ( http://groups.google.com/group/modwsgi/browse_thread/thread/cacddadc0c3c8e93/c92475afc0cc31eb?q= ). For a local mod_wsgi/Django/Apache testing environment with the minimum of work (in this case using the OS X Apache and an OS X Python 2.7 installer), I'd like to hear from anyone with this setup on OS X 10.5, before I ditch my Python 2.6, rebuild mod_wsgi with Python 2.7 and restore 64 bit Apache2. I originally posted this on StackOverflow but had no response, so hopefully someone on this list has been there first: http://stackoverflow.com/questions/4028394/python-2-7-os-x-installer-mod-wsgi-and-apache Dave Everitt -- 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.
minimum system requirements
Hi, I'm developing a project by django 1.2.3. Now it's time to bring the project to production. I'm looking for dedicated servers but i dont know the minimum hardware requirements. There are dedicated options with P4 cpus. Is there any information about requirements? Thanks all, -- 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-registration question: activation_key_expired.boolean = True
This question refers to line 205 here: http://bitbucket.org/ubernostrum/django-registration/src/b6b213d84d32/registration/models.py In a nutshell: class RegistrationProfile(models.Model): def activation_key_expired(self): ... expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS) return self.activation_key == self.ACTIVATED or \ (self.user.date_joined + expiration_date <= datetime.datetime.now()) activation_key_expired.boolean = True # <- what does this do? What does that last line do? I have looked high and low in Django and Python documentation, but I can't find an example or explanation of this pattern. It appears to be clobbering the method 'activation_key_expired()' with a boolean that is always True. Surely there's something else at work here, isn't there? Sorry if this is obvious to everyone but me, but I can't find the answer anywhere. Thanks. Alan btw: James Bennett's django-registration app is great. Elegant, well designed, and does exactly what it needs to. I learned a lot about django and django testing just by reading the code. -- 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.
Executing ssh scripts with django
Hi guys, I'm developing an ISP control panel for my organization. I just finished the web interface based on django admin and now it's time to introduce calls to the "system scripts" in order to make the changes effective on the ISP servers (add users, manage virtualhosts, domains, and all this stuff). To achieve that I was thinking in overriding the save and delete methods from my models ( virtualhost model, domain model..). For example. before saving a new "apache virtualhost" I want to run a proper "create vhost" script through ssh using Paramiko library and if it is successful save the new virtualhost into the database, otherwise send a message to enduser telling that an error has occurred. class Virtualhost(models.Model): def save(self, *args, **kwargs): if not self.id: ssh = Ssh('create_new_virtualhost', self) if ssh.errors: message.add(self.user, 'something wrong was happend') else: super(self, Virtualhost).save(*args, **kwargs) I'm wondering if this approach is the right way for the interaction between django and ISP servers. Moreover, I read that is highly recommended to use a message queue like celery in order to avoid a possible 'long wait' until ssh command ends [1]. Would you execute the save function through celery? Is it safe? or maybe if save() is executed asynchronously it can cause some unexpected behavior? I need some "expert" opinion here :) Would you affront this situation in a similar way or would you take a completely different approach? Many thanks!! [1] http://www.quora.com/How-can-I-remotely-execute-a-script-via-SSH-from-a-Django-view -- Marc -- 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-registration question: activation_key_expired.boolean = True
On Sun, Oct 31, 2010 at 8:48 AM, adj7388 wrote: > What does that last line do? I have looked high and low in Django and > Python documentation, but I can't find an example or explanation of > this pattern. It appears to be clobbering the method > 'activation_key_expired()' with a boolean that is always True. Surely > there's something else at work here, isn't there? Sorry if this is > obvious to everyone but me, but I can't find the answer anywhere. It sets an attribute on the instancemethod object 'activation_key_expired'. Remember: everything is an object, and you can fiddle with attributes on any object. This particular object is used by the admin: http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display Read through that carefully and you'll see the 'boolean' option and a few other useful tricks. -- "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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to make base.html a little more useful?
I am somewhat new to Django, but I have been able to figure out the form, model, view, session flow etc fairly well. I am going to ask this question in an abstract sense, because I really think a simple abstract answer is enough to get my mind in the right place. I have a base.html that has a header, left nav bar, main content area, footer, etc. Of course some views override these sections to drastically alter their content, etc (the main content being the most common of course). One thing that I would like to do is put some more useful nav links in the left sidebar for users who are authenticated. Such as a list of their friends who are also online (even if the data is pulled from third party) or a list of projects they are currently working on so it has hyperlinks to take them directly to those project editing pages. What I am mentally missing is how to get that data fed into base.html with every view call. Each time the left nav in base.html would be rendered it would need to draw data from a couple different apps I have installed on the site. Can someone point me in the right direction? -Wes Wagner -- 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-registration question: activation_key_expired.boolean = True
> This particular object is used by the admin: > > http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contri... > > Read through that carefully and you'll see the 'boolean' option and a > few other useful tricks. Well, this is embarrassing. I had actually read (err, skimmed?) that page looking for the answer, and did not see the needle in the haystack. After a more careful reading, it's perfectly clear. The attribute name 'boolean' threw me off a bit. I thought maybe there was some Python magic happening related to the fact that the function returned a boolean. Now all is clear. Thanks very much. Alan -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to make base.html a little more useful?
Context processors, or a custom template tag, as described in James Bennett's book, "Practical Django Projects." -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to make base.html a little more useful?
That switched the lightbulb on above my head. Thanks! -Wes On Oct 31, 8:16 am, Shawn Milochik wrote: > Context processors, or a custom template tag, as described in James Bennett's > book, "Practical Django Projects." -- 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: Tracking changes of a model
First, I thought that I don't need all the functionality provided by similar applications but after I spend some hours trying to do it myself not being very successfull, I tried this app and after five minutes all was up and running :) Thanks, Martin On Sat, 30 Oct 2010 15:03:48 +0200, Daniel Roseman wrote: On Oct 30, 11:15 am, Martin Tiršel wrote: Sounds like django-reversion would fit the bill: http://github.com/etianen/django-reversion -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Call a function after a model with inlines is created
Hello, I have two models BillingRequest and BillingRequestItem. I am using admin and inlines, so when I am creating BillingRequest, I have some fields for BillingRequestItems. Now, I need to send an email with some information from both models when I create new BillingRequest record. But I don't know, where I should put the code. It have to be after all models are saved, but where/when is it? Thanks, Martin -- 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: minimum system requirements
On Oct 31, 2010, at 7:19 AM, ozgur yilmaz wrote: > Hi, > > I'm developing a project by django 1.2.3. Now it's time to bring the > project to production. I'm looking for dedicated servers but i dont > know the minimum hardware requirements. There are dedicated options > with P4 cpus. Is there any information about requirements? Hi Ozgur, Minimum hardware requirements are relative to the amount of traffic you will be receiving. It is certainly possible to host a Django web site on a single 256MB VPS from e.g. Rackspace, but I would not expect that single VPS to be able to handle more than a very small number of visitors at once. On the other hand, 2 load-balanced 512MB instances serving the Django app plus a larger instance running the database should suffice to handle a much larger number of concurrent users -- depending on how you architected the site. If you have particular views that run lots of database queries and perform a large number of calculations, and those views turn out to be popular destinations for your visitors, you can very rapidly run out of resources. On the other hand, if you have a good caching strategy in place and minimal required computation for your site, small servers can potentially handle a much larger load. You will need determine for yourself how much computing hardware will suffice to handle your particular requirements. You should approach this task by load-testing your application, using such tools as httpperf (http://code.google.com/p/httperf/) and Tsung (http://tsung.erlang-projects.org/) to simulate usage of your app. You will want to test all your views, and also simulate what you think will be the normal use pattern. With the knowledge of how each view responds to load, you can then tune those views individually for better performance. With the knowledge of how your app responds to the normal use pattern, you can gauge how much hardware will be required to handle your estimated number of visitors. In short, profile your app, and make decisions based on that knowledge. As with many questions regarding deployment, the answer is "It depends". ---Peter Herndon -- 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.
Third party object like model field
Hello! I'd like to ask a bit newbie question but cannot realize how to do it. How I can implement following model: class Something(models.Model): name = models.CharField(max_length = 50) # and so on.. # next fields have predefined Django types #... ts = # where ts should be the object created by scikits.timeseries module (http://pytseries.sourceforge.net/) So, in short words, how can I create model with field that contains third party object? Please point me the directions, Thanks in Advance Best Regards Alex -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Third party object like model field
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/ -- 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: Call a function after a model with inlines is created
On Oct 31, 4:46 pm, Martin Tiršel wrote: > Hello, > > I have two models BillingRequest and BillingRequestItem. I am using admin > and inlines, so when I am creating BillingRequest, I have some fields for > BillingRequestItems. Now, I need to send an email with some information > from both models when I create new BillingRequest record. But I don't > know, where I should put the code. It have to be after all models are > saved, but where/when is it? > > Thanks, > Martin If this is only needed for the admin, you probably want to override the ModelAdmin's response_add method. This is called after the add form has been processed and all the resulting objects saved. Be sure to call (and return) the super method after you've done your processing. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Apache config. admin page displays without stylesheets
Django runs as expected using manage.py runserver, but when I run it from apache certain files are not found. This is because the apache user has a different base directory than the user running manage.py. So, I added absolute paths to my setting.py and other files. Now through apache one can access all the modules and pages just fine. But when I try to go to /admin I see there is no css formatting. everything is very plain and not like the version through runserver at all. I assume this is because the css file is not being found. But if the admin code is found, and allows me the properly add items and everything, why isn't the css found? granted, the html code I've written doesn't have any css going on, so I cant say that only the admin pages aren't rendering right. my apache setup looks like: SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/home/libadmin/library/django-ils/','/home/ libadmin/library/django-ils/bookshare'] + sys.path" SetEnv DJANGO_SETTINGS_MODULE bookshare.settings PythonOption django.root /home/libadmin/library/django-ils/bookshare/ PythonDebug On Thinking that a relative path to the css file was being misused I checked the source of the admin login page in firefox. The admin site is looking for this file exsists in both /usr/share/python-support/python-django/django/contrib/admin/media/css/ login.css /var/lib/python-support/python2.5/django/contrib/admin/media/css/ login.css so, is django not finding this file because of an irrendered relative path? and if so, what is wrong with my configuration that this isn't found? (This is being run from a cloned mercurial repo, so I did not start this project on this machine with the django scripts. if this is the issue, is there a way to manually do what the startproject or startapp scripts are supposed to do?) thanks, Elliot -- 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: minimum system requirements
On Sun, Oct 31, 2010 at 12:10 PM, Peter Herndon wrote: > but I would not expect that single VPS to be able to handle more than a very > small number of visitors at once. only if you consider several dozens "a very small number" -- Javier -- 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: Multiple Django/Python developer Positions- Atlanta, GA
On Fri, 2010-10-29 at 22:32 +0530, Venkatraman S wrote: > On Fri, Oct 29, 2010 at 10:27 PM, Kenneth Gonsalves > wrote: > > > On Fri, 2010-10-29 at 07:18 -0700, Jack wrote: > > > only US Citizens or Greencard holders need apply > > > > please do not put things like this on an international list > > > > I hear that there are many many unclaimed H1B slots :) > But OTOH, i dont think its much of a problem when the recruiter > clearly > mentions the criteria; you dont want to get loads of applicants which > do not > satisfy the basic criteria. sorry, I got a bit upset - it is better to put criteria like this in the subject line - not at the end of the mail. Save us some time reading. -- regards Kenneth Gonsalves Senior Associate NRC-FOSS at AU-KBC -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Free Blog built on Django and run in AppEngine
Hi, I just released a source code of my own blog as open source (called 'MeBlog'). Built the blog in django 1.2.3 and run in appengine. This blog has common features for blog, such as manage posts, manage pages, and manage media file. This is the first release, hope anyone enjoy. Feel free to write me any comment, sugggestion, bug report, or feature request. Source code available at http://bitbucket.org/hudarsono/meblog Preview and Real site : http://blog.hudarsono.me (my own 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-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.
cannot setup database
When i run the command python manage.py syncdb i got the follwing error self.connection = Database.connect(**kwargs) sqlite3.OperationalError: unable to open database file Exception exceptions.AttributeError: '_shutdown' in ignoredDATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', MY DB SETUP LOOKS LIKE THIS 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'D:\Python25\Lib\site-packages\django\bin\flyp\sqlite3', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } -- 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.