Re: can't open file 'django-admin.py': [Errno 2] No such file or directory'.
On Oct 30, 6:00 am, sami nathan wrote: > Whenever I try to execute a python script that is located in the > /usr/local/bin, python gives me the error 'python: can't open file > 'django-admin.py': [Errno 2] No such file or directory'. That makes no sense. That message is a Windows error, and Windows doesn't have a /usr/local/bin/ directory. -- 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.
Tracking changes of a model
Hello, I am using Django admin to create/update some records. Now, I need to track changes. After somebody updates a record, I need to see what was changed and then create a text log like: changed `name`: oldvalue -> newvalue, changed `email`: o...@mail.xy -> n...@mail.xy Where is the right place, where I have access to unchanged model values and validated values from the submit form? The place before the model is updated by form values? Another approach would be to save all values into a dictionary after the model is loaded from database and in save() method compare old and new values, but I don't know how how to call a code after load. 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: write a filter for latex that escapes some chars
thx for that. It's not quite what I was looking for but it led me to the solution Thank You. On 29 Paź, 15:42, Brian Bouterse wrote: > We have done this before and used something like the code below. This > sample is pretty basic. > > def fixchar(string,char): > > #fixes chars for latex > > if char == '<': > > newchar = '$<$' > > elif char == '>': > > newchar = '$>$' > > elif char == '~': > > newchar = '\\~{}' > > else: > > newchar = '\\' + char > > string = string.replace(char,newchar) > > return string > > > > > > > > > > On Fri, Oct 29, 2010 at 9:03 AM, SlafS wrote: > > Hi there! > > > I'm trying to write a filter that can be used inside of a template > > that is used for generating latex files. > > > The filter should replace the '|' char with '\'. Simple: > > > @register.filter("verb_safe") > > def verb_safe(val): > > return str(val).replace('|', '\|') > > > is outputting me '\\|' > > > I'm littlle confused about that. > > > Please help > > > Regards > > > -- > > 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 > groups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Brian Bouterse > ITng Services -- 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
Hi Martin, i think this should give you the basic idea: http://stackoverflow.com/questions/1365963/diff-django-model-objects-with-manytomany-fields Greetings, Andreas On 30 Okt., 12:15, Martin Tiršel wrote: > Hello, > > I am using Django admin to create/update some records. Now, I need to > track changes. After somebody updates a record, I need to see what was > changed and then create a text log like: > > changed `name`: oldvalue -> newvalue, > changed `email`: o...@mail.xy -> n...@mail.xy > > Where is the right place, where I have access to unchanged model values > and validated values from the submit form? The place before the model is > updated by form values? Another approach would be to save all values into > a dictionary after the model is loaded from database and in save() method > compare old and new values, but I don't know how how to call a code after > load. > > 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.
table namespace hygiene: should I try to rename auth_* tables, or should I use a separate database?
django 1.2, python 2.6, mysql 5.1, etc. I am sharing a database with others on my project, and I would like to keep the table namespace neat and tidy. After poking around the archives for a while, I can't see any good way to specify names other than the default auth_group, auth_group_permissions, etc. for the auth module. I don't want my tables to get confused with someone else's. "auth" is unfortunately a very generic prefix. One can imagine lots of people making tables named auth_something. Is this renaming something that can be done in a reasonable way? If not, I could create a new database, and devote it to the django stuff. Is that a good solution? Are there significant disadvantages to using a separate mysql database just for the django stuff? Is there maintenance overhead for the dba? (I don't know.) Are there any disadvantages, say, to doing trans-database joins, or having trans- database key constraints, vs. within a single database? Does anyone see any other optimal ways to keep my table namespace clean? Thanks 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: can't open file 'django-admin.py': [Errno 2] No such file or directory'.
On Oct 30, 1:00 am, sami nathan wrote: > Whenever I try to execute a python script that is located in the > /usr/local/bin, python gives me the error 'python: can't open file > 'django-admin.py': [Errno 2] No such file or directory'. Please type the following commands (without the $ prompt) and post the results: $ type python $ type django-admin.py $ head -3 /usr/local/bin/whatever-script-you-want-to-run -- 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
On Oct 30, 11:15 am, Martin Tiršel wrote: > Hello, > > I am using Django admin to create/update some records. Now, I need to > track changes. After somebody updates a record, I need to see what was > changed and then create a text log like: > > changed `name`: oldvalue -> newvalue, > changed `email`: o...@mail.xy -> n...@mail.xy > > Where is the right place, where I have access to unchanged model values > and validated values from the submit form? The place before the model is > updated by form values? Another approach would be to save all values into > a dictionary after the model is loaded from database and in save() method > compare old and new values, but I don't know how how to call a code after > load. > > Thanks, > Martin 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.
Re: Using new classbased generic views in contrib.databrowse
On Sat, Oct 30, 2010 at 2:01 AM, Michael wrote: > Hi, > > Do you think it is relevant to rewrite databrowse to use the new class- > based generic views ? > I'm motivate to work around this and submit a patch, but want first to > discuss about what to do.. > IMHO, contrib.databrowse (using class-based views) can provide a > reusable/extendable "base" for rapid development. > > Do you use databrowse ? and how (extending the classes ? , or just by > providing your own the template ?) > a JSON/CSV/XLS output could be useful too in databrowse (theses two > last formats could also become core.serializers btw.) Hi Michael, Databrowse hasn't seen a whole lot of attention since it was originally added, so there is almost certainly room for improvement. Moving to class-based views might be part of that process. If you want to adopt databrowse as a pet project and improve it, I certainly encourage you to do so. However, please don't just submit a patch that 'replaces function views with class-based views'. Change for the sake of change isn't something we generally encourage. Unless there's a compelling reason to migrate to class-based views, there's not a lot of reason to make changes to code that works. There was a recent discussion about porting the contrib.auth views to class-based views which received a simliar reception. I look forward to any proposals you may have for improving databrowse! Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: server configuration
http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Apache_Requirements >For Apache 2.0 and 2.2, either the single threaded 'prefork' or multithreaded >'worker' Apache MPMs can be used. >To be able to make use of daemon mode of mod_wsgi, either Apache 2.0 or 2.2 is >required and the corresponding Apache runtime (APR) libraries must have been >compiled with support for threading. Actually there is nothing about that is not possible to use worker MPM and daemon mode. So, I'm using it and have no problem at all. ... ServerName vspolny.ru WSGIDaemonProcess vspolny user=www group=www httpd -V Server version: Apache/2.2.15 (FreeBSD) Server built: Jun 12 2010 21:08:00 Server's Module Magic Number: 20051115:24 Server loaded: APR 1.4.2, APR-Util 1.3.9 Compiled using: APR 1.3.9, APR-Util 1.3.9 Architecture: 32-bit Server MPM: Prefork threaded: no forked: yes (variable process count) On Oct 29, 7:22 pm, "bax...@gretschpages.com" wrote: > I'm finding conflicting info regarding preferred server > configurations. > > I'm using Nginx for static, passing off to Apache/mod_wsgi for django > stuff. Currently, wsgi is in daemon, and I'm using the worker MPM. > From some sources I've seen that is ideal, but I notice in the django > docs that prefork MPM is better. But then I read you can't use prefork > if wsgi is in daemon mode. > > So I'm confused, and hoping someone can clarify for me. -- 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: server configuration
> Actually there is nothing about that is not possible to use worker MPM > and daemon mode. Sorry. I meant prefork MPM :) -- 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 develop cms on django
Please try out Live Demo for Django CMS Classcomm ... http://code.google.com/p/classcomm/ and http://classcomm.geekshack.net/handin/ On Oct 29, 1:47 pm, Oivvio Polite wrote: > > i dont have time i need to start development within a month.. > > > plz tell me all those crucial topics that i should learn > > From the little information I have about your situation I'd say your > better of using a readymade CMS like Wordpress. As much as I love > Django, I do think that you'll be settings yourself up for a world of > pain if you need to have a site up withing a month and have no > previous experience with python. > > oivvio > > --http://pipedreams.polite.se/about/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Import csv file in admin
The ordinary user won't have to deal with the command line, you just need to get the CSV file. A ModelForm to which an FileField is added doesn't really have anything to do with that. Instead, you should create a standard form with a single FileField to upload the CSV file, save it temporarily or just keep it as a file object and then process it as Jirka pointed out. Regards, Felix On 29.10.2010 18:31, Jorge wrote: > Jirka > > I need an easy method inside the admin to upload the csv file with an > web interface. I guess with your method the admin will need access to > the server and the command line, and something like this is not what i > try to do, because the admin (not me) is not a django developer, not > even a user get used to command lines. But if my guessing is wrong how > can i do a web interface for your method? > > Regards! > > On Oct 29, 5:44 am, Jirka Vejrazka wrote: >> I must still be missing something here. If all you want to do is to >> read CSV file and save the data in the database, I still don't >> understand why you use the forms machinery. >> >> You only *need* to use the data model, e.g. >> >> from myapp.models import Data >> >> csvfile = csv.reader('something.csv') >> >> for line in csvfile: >> do_necessary_data_conversions_or_checks(line) >> try: >> Data.objects.create(field1=line[0], field2=line[1], ...) >> except (IndexError, IntegrityError): >> print 'Invalid line encountered:\n%s' % line >> >> What am I missing? >> >>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.
Re: Cherokee for home developing
Thanks for all your answer, the topic get a little divergence, but it's ok, I still use Cherokee for developing even if is not so comfortable as I thought. > The best way to save yourself time and effort is really to use the > Django development server when testing out alterations. Yes I guess so, but I had many problems to serve static files, and the :8000 port wasn't so cool so I tried to work with a production web server even for the developing. > Karim, you may find that refreshing your project is easier with uWSGI as > opposed to something > like FastCGI, in reference to your question about having to restart Cherokee > each time you make changes. Yes, I noted that when I edit a url and sometimes the code, I have to kill the fastcgi process to see the result in the browser. I think that I could run the fastcgi as explained in the django documentation: ./manage.py runfcgi method=prefork socket=/home/user/mysite.sock pidfile=django.pid and map in vim file a kill command kill `cat $PIDFILE` Another solution is take a look at the uWSGI configuration Anyway is a nice topic ;-) -- K. Blog Personale: http://www.karimblog.net -- 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.
Poll about geodjango
Hi guys, i will like to much if the users of geodjango (aka django.contrib.gis) can make this poll http://goo.gl/l2od Is for a exposition in college. thanks. -- Diego Andrés Sanabria Ingeniería de Sistemas Universidad Distrital about:me http://www.google.com/profiles/diegueus9 cel 3015290609 -- 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: Cherokee for home developing
Yes, absolutely. :D Good luck! On Oct 30, 2010, at 5:04 PM, Karim Gorjux wrote: > Yes, I noted that when I edit a url and sometimes the code, I have to > kill the fastcgi process to see the result in the browser. I think > that I could run the fastcgi as explained in the django documentation: > > ./manage.py runfcgi method=prefork socket=/home/user/mysite.sock > pidfile=django.pid > > and map in vim file a kill command > > kill `cat $PIDFILE` -- 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
Check out http://bitbucket.org/mhall119/django-audit/wiki/Home -- Michael On Sat, 2010-10-30 at 12:15 +0200, Martin Tiršel wrote: > Hello, > > I am using Django admin to create/update some records. Now, I need to > track changes. After somebody updates a record, I need to see what was > changed and then create a text log like: > > changed `name`: oldvalue -> newvalue, > changed `email`: o...@mail.xy -> n...@mail.xy > > Where is the right place, where I have access to unchanged model values > and validated values from the submit form? The place before the model is > updated by form values? Another approach would be to save all values into > a dictionary after the model is loaded from database and in save() method > compare old and new values, but I don't know how how to call a code after > load. > > 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: overriding save-method
Write a custom model field: http://docs.djangoproject.com/en/dev/howto/custom-model-fields/ Or even better, take already written one: http://djangosnippets.org/snippets/377/ On Oct 27, 9:14 am, Patrick wrote: > hi, > > i am trying to override the save-method of one of my models. i want to > save the json-representation of any object in a text field. somehow it > doesn't seem to work. > > class Setting(models.Model): > name = models.CharField(max_length=100) > value = models.TextField() > > def save(self, *args, **kwargs): > self.value = json.dumps(self.value) > super(Setting, self).save(*args, **kwargs) > > any ideas?! thank you.. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Import csv file in admin
Felix 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: class DataAdmin(admin.ModelAdmin): change_form_template = 'admin/data/data/change_form.html' def get_urls(self): urls = super(DataAdmin, self).get_urls() my_urls = patterns('', ('^add/$', self.admin_site.admin_view(self.add_view)), ) return my_urls + urls def add_view(self, request, extra_content=None): FormInput = DataInput() context = {'form': FormInput} return super(DataAdmin, self).add_view(request, extra_context=context) And the form is: import csv from datetime import datetime class DataInput(forms.Form): file = forms.FileField() place = forms.ModelChoiceField(queryset=Places.objects.all()) def save(self): records = csv.reader(self.cleaned_data["file"]) for line in records: input_data = Data() input_data.place = self.cleaned_data["place"] input_data.time = datetime.strptime(line[1], "%m/%d/%y %H: %M:%S") input_data.data_1 = line[2] input_data.data_2 = line[3] input_data.data_3 = line[4] input_data.save() In the template are the "multipart/data" and "csrftoken" orders. But again... this is a karma the IntegrityError: datas_data.time may not be NULL As i say at the beginning, i feel like taking the dirty way, and obviously not seeing something. Regards! On Oct 30, 5:55 pm, Felix Dreissig wrote: > The ordinary user won't have to deal with the command line, you just > need to get the CSV file. A ModelForm to which an FileField is added > doesn't really have anything to do with that. > > Instead, you should create a standard form with a single FileField to > upload the CSV file, save it temporarily or just keep it as a file > object and then process it as Jirka pointed out. > > Regards, > Felix > > On 29.10.2010 18:31, Jorge wrote: > > > Jirka > > > I need an easy method inside the admin to upload the csv file with an > > web interface. I guess with your method the admin will need access to > > the server and the command line, and something like this is not what i > > try to do, because the admin (not me) is not a django developer, not > > even a user get used to command lines. But if my guessing is wrong how > > can i do a web interface for your method? > > > Regards! > > > On Oct 29, 5:44 am, Jirka Vejrazka wrote: > >> I must still be missing something here. If all you want to do is to > >> read CSV file and save the data in the database, I still don't > >> understand why you use the forms machinery. > > >> You only *need* to use the data model, e.g. > > >> from myapp.models import Data > > >> csvfile = csv.reader('something.csv') > > >> for line in csvfile: > >> do_necessary_data_conversions_or_checks(line) > >> try: > >> Data.objects.create(field1=line[0], field2=line[1], ...) > >> except (IndexError, IntegrityError): > >> print 'Invalid line encountered:\n%s' % line > > >> What am I missing? > > >> 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.