Re: Beginner: ManyToManyFields error creating the model / adding values by the Admin Module or the Shell

2014-11-05 Thread Erik Cederstrand
> Den 04/11/2014 kl. 23.07 skrev lnzy3...@gmx.de: > > > Hi Erik, > > the idea was, that one Author can write in more than one language (eg. en and > de), or no one at all. This was the background to use the ManyToManyField. Yes, but then you simply create multiple Interest objects, right? O

How to find the word 'python' in string 'pythonpythonpythonpyth'?

2014-11-05 Thread Віталій Лисенко
How to find the word 'python' in string 'pythonpythonpythonpyth'? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To p

Re: How to find the word 'python' in string 'pythonpythonpythonpyth'?

2014-11-05 Thread Rafael E. Ferrero
a.find('python') -- Rafael E. Ferrero 2014-11-05 8:16 GMT-03:00 Віталій Лисенко : > How to find the word 'python' in string 'pythonpythonpythonpyth'? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and s

Re: How to find the word 'python' in string 'pythonpythonpythonpyth'?

2014-11-05 Thread Віталій Лисенко
Sorry. I asked the question incorrectly. Example. I line 'pythonpythonpyth'. How do I know which word is the foundation line?. Other examples: "DOLORIUMD" --> rigth answer DOLORIUM "HELLOL" --> HELLOL "thewordword" --> thewordword I need to know whether the word in the text is repeated and get it.

Re: How to find the word 'python' in string 'pythonpythonpythonpyth'?

2014-11-05 Thread Denis Darii
Vitaly feel free to look on https://www.python.org/ for a solution to your issue and please keep only django related questions in this "Django users" group. Thank you. Denis. On 5 November 2014 12:41, Віталій Лисенко wrote: > Sorry. I asked the question incorrectly. > Example. > I line 'pythonpy

Django REST Framework: How to add prefix in URL for versioning

2014-11-05 Thread Shoaib Ijaz
I am trying to create version for REST application. Here is my URL Examle www.myapi.com/foo [default version] www.myapi.com/v1/foo [version one] This is the project structure ├── __init__.py├── settings.py├── urls.py├── default_app│ ├── __init__.py│ ├── serializer.py│ ├── models.py│ ├── views

Re: Multiple site package directories for Python and question about apache configuration

2014-11-05 Thread Scot Hacker
You want to establish the path directories in your .wsgi file. Use `addsitedir` to set the path to site-packages and set additional paths with path.append, e.g.: import os, sys, site site.addsitedir('/path/to/site-packages') sys.path.append('/extra/path/1') sys.path.append('/extra/path/2')

Re: How to handle exceptions in RequestContext?

2014-11-05 Thread Daniel Grace
I see where you are coming from Carl, thanks for the information. Do you have a suitable example of where one might put error handling in the view code? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop r

Re: Django REST Framework: How to add prefix in URL for versioning

2014-11-05 Thread Lee Hinde
Swap the urls: url(r'^v1/', include(v1_urls, namespace="v1")) url(r'^', include(default_urls, namespace="default")), On Wed, Nov 5, 2014 at 5:01 AM, Shoaib Ijaz wrote: > I am trying to create version for REST application. Here is my URL Examle > > www.myapi.com/foo [default version] > www.my

Re: How to handle exceptions if RequestContext fails?

2014-11-05 Thread Collin Anderson
Hi Daniel, Would it work to pass in an empty Context? You could also as you say, try using render() to see if it would work. Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from

Re: Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-05 Thread Collin Anderson
Hello, Would it work to import AppAdmin, instantiate it, and then call the methods in a unit test? Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to dj

Django expat error

2014-11-05 Thread Amal Francis
I have a fresh installation of Django 1.7 on virtualenv. When i run the migration python manage.py migrate am getting from xml.sax.expatreader import ExpatParser as _ExpatParser File "/usr/lib/python2.7/xml/sax/expatreader.py", line 24, in raise SAXReaderNotAvailable("expat not suppor

Re: Multiple versions of python on linux server

2014-11-05 Thread Collin Anderson
Hello, > You have to use a mod_wsgi that is built against python3. On > Debian/Ubuntu, the package is called libapache2-mod-wsgi-py3. > Also, there's an Red Hat package of mod_wsgi built against python 3.3 here: http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/repoview/python33-mod_wsg

Re: How to handle exceptions in RequestContext?

2014-11-05 Thread Carl Meyer
Hi Daniel, On 11/05/2014 08:44 AM, Daniel Grace wrote: > I see where you are coming from Carl, thanks for the information. Do > you have a suitable example of where one might put error handling in the > view code? Usually I try to keep view code as short and simple as possible (because it is the

Re: Why does django use mysqldb over mysql-connector?

2014-11-05 Thread Collin Anderson
Hello, > https://github.com/PyMySQL/mysqlclient-python > > I didn't tried that. Someone use it? > I use it. There's a thread about it on django-developers. https://groups.google.com/d/topic/django-developers/n-TI8mBcegE/discussion Collin -- You received this message because you are subscr

Re: Global Variable

2014-11-05 Thread Collin Anderson
Hello, You could also try creating an assignment tag something like: {% get_base_url as base_url %} https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#assignment-tags That way you don't need to deal with context_processors. Collin -- You received this message because you are s

Re: running unit tests with legacy database: Error 1050, Table already exists

2014-11-05 Thread Collin Anderson
Hi David, Interesting. Shouldn't the test database be a separate, fresh, empty database (not a legacy database)? Thanks, Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it,

Using ContentType to link two different objects together

2014-11-05 Thread Some Developer
Hi, I'm trying to write my own implementation of the Django comments framework for various reasons and am wondering how one would link comments to a particular object (model) of another type. For instance I could have a ForeignKey in the Comment model pointing to a Blog post article but that

Re: Using ContentType to link two different objects together

2014-11-05 Thread Carl Meyer
Hi, On 11/05/2014 11:09 AM, Some Developer wrote: > I'm trying to write my own implementation of the Django comments > framework for various reasons and am wondering how one would link > comments to a particular object (model) of another type. For instance I > could have a ForeignKey in the Commen

Django and Ajax, Django not returning posted data.

2014-11-05 Thread G Z
So I'm trying to write an ajax script that post data to django without having to leave the page. Currently it is on submit however eventually im going to put it on a timer. Right now the function outputs to the console as a success but no data is returned from django. Here is my ajax $(docu

Re: Django and Ajax, Django not returning posted data.

2014-11-05 Thread G Z
Another note is I try to return posted data and out put it to the html for testing and that doesn't get returned either. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an e

Re: Using ContentType to link two different objects together

2014-11-05 Thread Some Developer
On 05/11/2014 18:16, Carl Meyer wrote: Hi, On 11/05/2014 11:09 AM, Some Developer wrote: I'm trying to write my own implementation of the Django comments framework for various reasons and am wondering how one would link comments to a particular object (model) of another type. For instance I co

Re: Using ContentType to link two different objects together

2014-11-05 Thread Carl Meyer
On 11/05/2014 11:35 AM, Some Developer wrote: > On 05/11/2014 18:16, Carl Meyer wrote: >> On 11/05/2014 11:09 AM, Some Developer wrote: >>> I'm trying to write my own implementation of the Django comments >>> framework for various reasons and am wondering how one would link >>> comments to a partic

ModelMultipleChoiceField forcing required

2014-11-05 Thread Scot Hacker
I'm having a strange issue with a pair of ManyToManyFields, where they're acting like they're required fields in the admin even though they're not. # In models.py instructors = models.ManyToManyField(Instructor, blank=True) students = models.ManyToManyField(Profile, blank=True) I can

How to restrict a class based view to one user group?

2014-11-05 Thread Daniel Grace
Hi, Say I have a function as follows: def is_supervisor(user): return user.groups.filter(name='supervisor').exists() ...and a CBV for deleting records: class DeleteFlow(DeleteView): # etc... How can I restrict access to this view using the function? I understand that this may be possibl

Re: Django and Ajax, Django not returning posted data.

2014-11-05 Thread G Z
updated my ajax to the following but for somereason it just says something went wrong $(document).ready(function() { $('#get_info').submit(function() { $.ajax({ type: "POST", url: "/vmstatus/", dataType: "json", async:

Re: ModelMultipleChoiceField forcing required

2014-11-05 Thread Carl Meyer
Hi Scot, On 11/05/2014 12:11 PM, Scot Hacker wrote: > I'm having a strange issue with a pair of ManyToManyFields, where > they're acting like they're required fields in the admin even though > they're not. > > > # In models.py > | > instructors =models.ManyToManyField(Instructor,blank=True)

Re: ModelMultipleChoiceField forcing required

2014-11-05 Thread Scot Hacker
On Wednesday, November 5, 2014 11:15:47 AM UTC-8, Carl Meyer wrote: > > So because you are manually creating your `instructors` and `students` > fields on the form, the `blank=True` in the model has no effect; you > need to pass `required=False` to your two form fields. > Got it, right you

Re: Using ContentType to link two different objects together

2014-11-05 Thread Some Developer
On 05/11/2014 18:47, Carl Meyer wrote: On 11/05/2014 11:35 AM, Some Developer wrote: On 05/11/2014 18:16, Carl Meyer wrote: On 11/05/2014 11:09 AM, Some Developer wrote: I'm trying to write my own implementation of the Django comments framework for various reasons and am wondering how one wou

Enter a contest to win a free e-copy of "Web Development with Django Cookbook"

2014-11-05 Thread Aidas Bendoraitis
Hello all, Not long ago my book "Web Development with Django Cookbook" was published and now you have a chance to win a free copy of it. Check http://djangotricks.blogspot.de/2014/11/win-free-copies-of-web-development-with-django-cookbook.html for more details. Cheers, Aidas Bendoraitis --

Re: How to find the word 'python' in string 'pythonpythonpythonpyth'?

2014-11-05 Thread Russell Keith-Magee
Actually - I'd suggest that the Python mailing list isn't the right place either. It sounds like the problem you're describing is called the Longest Repeated Substring problem: http://en.wikipedia.org/wiki/Longest_repeated_substring_problem The solution to this problem is well known, and O(n) -

Re: How to find the word 'python' in string 'pythonpythonpythonpyth'?

2014-11-05 Thread m1chael
does this help? http://www.nltk.org/ On Wed, Nov 5, 2014 at 7:28 PM, Russell Keith-Magee wrote: > > Actually - I'd suggest that the Python mailing list isn't the right place > either. > > It sounds like the problem you're describing is called the Longest Repeated > Substring problem: > > http://e

How access verbose_name of a instance in template?

2014-11-05 Thread Neto
How access verbose_name of a instance in template? I have: car = Car.objects.get(pk=1) In my template: {{ car.color.??? }} {{ car.color }} I wanna print the verbose_name, i want to it: Color: red -- You received this message because you are subscribed to the Google Groups "Django users" gro

Re: How access verbose_name of a instance in template?

2014-11-05 Thread Mike Dewhirst
On 6/11/2014 2:29 PM, Neto wrote: How access verbose_name of a instance in template? I have: car = Car.objects.get(pk=1) Try this in a script somewhere to see if it returns the verbose name def get_verbose_name(obj, field): return obj.__class__()._meta.get_field_by_name('{0}'.format(fie