Re: outdated django book

2012-04-28 Thread Daniel Roseman
Which, of course, is nothing to do with Django versions, and was true even 
when the Django book was new.

On Saturday, 28 April 2012 03:30:26 UTC+1, jondbaker wrote:
>
> You need to import User from django.contrib.auth.models and login_required 
> from django.contrib.auth.decorators. Hope this helps. 
>
> Sent from my iPhone 
>
> On Apr 27, 2012, at 8:09 PM, knowledge_seeker wrote: 
>
> > My Django book (from the university library) said to add the label 
> > "@login_required" to views that I wish to restrict user access on. 
> > Django 1.4 does not allow this; obviously the book is dated! Is there 
> > a more modern way to get the same effect? 
> > 
> > Similarly, admin does not allow access to my classes, even when I have 
> > created an Admin class; is this a new security feature? 
> > 
> > Finally, when I tried to create a view that allowed web-based user 
> > creation, the views.py file would not recognize the class "User"; is 
> > there something I need to import? 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6ExeXS4aUn8J.
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: Can't find module

2012-04-28 Thread Gerald Klein
Environment:


Request Method: GET
Request URL: http://localhost/search/

Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.flatpages',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'search')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in
get_response
  101. request.path_info)
File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in
resolve
  300. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in
resolve
  209. return ResolverMatch(self.callback, args, kwargs,
self.name)
File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in
callback
  216. self._callback = get_callable(self._callback_str)
File "/usr/lib/python2.7/site-packages/django/utils/functional.py" in
wrapper
  27. result = func(*args)
File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in
get_callable
  105. not
module_has_submodule(import_module(parentmod), submod)):
File "/usr/lib/python2.7/site-packages/django/utils/importlib.py" in
import_module
  35. __import__(name)

Exception Type: ImportError at /search/
Exception Value: No module named search


On Fri, Apr 27, 2012 at 6:46 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Apr 27, 3:56 am, Gerald Klein  wrote:
> > Hi, I am having a strange problem, I have a search module named 'search'
> > but Django states ;No module named search
>
> full traceback please ?
>
> > here is my url
> >
> > url(r'^search/$', 'cms.search.views.search'),
>
> is the cms.search app in your settings.INSTALLED_APPS ? Is there any
> other package or module named "cms" in you sys.path ?
>
> --
> 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.
>
>


-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Linux registered user #548580

-- 
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: Can't find module

2012-04-28 Thread Gerald Klein
Sorry hit the send button
http://dpaste.com/739184/

Here it is and thanks

--jerry

On Fri, Apr 27, 2012 at 6:46 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Apr 27, 3:56 am, Gerald Klein  wrote:
> > Hi, I am having a strange problem, I have a search module named 'search'
> > but Django states ;No module named search
>
> full traceback please ?
>
> > here is my url
> >
> > url(r'^search/$', 'cms.search.views.search'),
>
> is the cms.search app in your settings.INSTALLED_APPS ? Is there any
> other package or module named "cms" in you sys.path ?
>
> --
> 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.
>
>


-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Linux registered user #548580

-- 
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.



how to get the variable in the context

2012-04-28 Thread DanYun Liu
I defined a context processor to pass the login user info to the template.
and, I also need to use it in the view.

is there any way to get the variable from the context?

-- 
Pursuit the freedom of the soul.

-- 
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: Can't find module

2012-04-28 Thread Alagappan
In your installed applications list you have mentioned 'search' as an
application. But in your url pattern you are using 'cms.search'. Either use
'cms' as your installed application or mention it as just
'search.views.search' in your url pattern.

I feel that should do the job.

Thanks,
Alagappan

-- 
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: how to get the variable in the context

2012-04-28 Thread Amao Zhao
Dear DanYun Liu
Django has the biuld-in middlewar with the user.
You can use the user in your templates immediately.

在 2012年4月28日星期六,DanYun Liu 写道:

> I defined a context processor to pass the login user info to the template.
> and, I also need to use it in the view.
>
> is there any way to get the variable from the context?
>
> --
> Pursuit the freedom of the soul.
>
> --
> 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 'django-users@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-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: how to get the variable in the context

2012-04-28 Thread Thomas Rega

Am 28.04.12 11:11, schrieb DanYun Liu:
I defined a context processor to pass the login user info to the 
template. and, I also need to use it in the view.


is there any way to get the variable from the context?



http://stackoverflow.com/questions/41547/always-including-the-user-in-the-django-template-context

good luck,

TR


--


http://www.pyt3ch.com


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Edit-once object in admin?

2012-04-28 Thread Roy Smith
I've got a model that looks something like this:

class Image(Model):
name = CharField(max_length=40)

class ImageVersion(Model):
image = ForeignKey(Image)
upload_date = DateTimeField(auto_now_add=True)
data = ImageField(upload_to="images/learncms")

I want all the data in an ImageVersion to be read-only once it is created. 
 The idea is that the active version of an image is always the latest one, 
and the only way to change an image is to upload a new version.  Existing 
versions can never be changed.  How can I implement this in the admin?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/8S3EkzfiiBwJ.
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: Edit-once object in admin?

2012-04-28 Thread Shawn Milochik

I think you have to change your model.

Override the save() method to raise an exception if "self.id is not None."

This won't prevent developers from using the 'update()' or 'delete()' 
methods of a queryset, but for a single instance it shouldn't be 
editable. It will still be able to be deleted, unless you override 
delete() as well.


--
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: Does adding editable=False to model require a data migration?

2012-04-28 Thread Jerome Baum
On Apr 27, 7:34 pm, Micky Hulse  wrote:
> From the docs:
>
> editable
> Field.editable
> If False, the field will not be editable in the admin or via forms
> automatically generated from the model class. Default is True.
>
> So, it reads like I can add the editable argument to the field without
> having to migrate my data?

Sounds like it. If you are using South then you can also run
"manage.py schemamigration  --auto" and South will tell you
whether it thinks a schema migration is required. If it isn't an
nothing about the semantics of your data has changed, then you also
don't need a data migration.

-- 
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: Edit-once object in admin?

2012-04-28 Thread Roy Smith


On Saturday, April 28, 2012 10:35:40 AM UTC-4, Shawn Milochik wrote:
>
> Override the save() method to raise an exception if "self.id is not 
> None." 
>

But, that still doesn't tell the admin interface to *show* the fields as 
read-only (which is really what I'm interested in).  If I raise an 
exception in save(), the admin interface will let somebody edit the fields 
and then give some sort of error when the click the Save button. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/POzCay3oK0wJ.
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: Can't find module

2012-04-28 Thread Gerald Klein
Ok thanks I will give that a try.


--jerry

On Sat, Apr 28, 2012 at 4:28 AM, Alagappan  wrote:

> In your installed applications list you have mentioned 'search' as an
> application. But in your url pattern you are using 'cms.search'. Either use
> 'cms' as your installed application or mention it as just
> 'search.views.search' in your url pattern.
>
> I feel that should do the job.
>
> Thanks,
> Alagappan
>
> --
> 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.
>



-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Linux registered user #548580

-- 
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: Custom commands for manage.py

2012-04-28 Thread .
> Just redefine your Command class option_list:

> class MyBadCommand(BaseCommand):
>   option_list = () # no options at all...

The problem is that I want to be able to write my own options.

-- 
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: Does adding editable=False to model require a data migration?

2012-04-28 Thread Micky Hulse
Hi Jerome! Thanks for your help, I really appreciate it. :)

On Apr 28, 2012, at 7:59 AM, Jerome Baum  wrote:
> Sounds like it. If you are using South then you can also run
> "manage.py schemamigration  --auto" and South will tell you
> whether it thinks a schema migration is required. If it isn't an

Great! I'm not using south currently. I have used it for another project and it 
sure did make life easier. 

I'm currently doing my schema/data migrations by hand (update model manually, 
create fixture (if needed, modify fixture data to meet schema changes), 
cleardata, drop tables via the sql shell, load fixture and do a syncdb. It can 
be a tedious process... :)

> nothing about the semantics of your data has changed, then you also
> don't need a data migration.

Sounds good to me! Thanks so much for your help!

Have an awesome weekend!

Cheers,
M

-- 
Sent from my Macbook Wheel

-- 
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: outdated django book

2012-04-28 Thread Jonathan Baker
Ah yes, I should have clarified that in my response. @knowledge_seeker, if
you'll check your python code with a tool like
pyflakesit will tell you when
you're referencing modules that have not been
imported (as well as many other common errors). I use the pyflakes for vim
plugin  and it saves
me from a ton of headaches.

On Sat, Apr 28, 2012 at 2:14 AM, Daniel Roseman wrote:

> Which, of course, is nothing to do with Django versions, and was true even
> when the Django book was new.
>
>
> On Saturday, 28 April 2012 03:30:26 UTC+1, jondbaker wrote:
>
>> You need to import User from django.contrib.auth.models and
>> login_required from django.contrib.auth.**decorators. Hope this helps.
>>
>> Sent from my iPhone
>>
>> On Apr 27, 2012, at 8:09 PM, knowledge_seeker wrote:
>>
>> > My Django book (from the university library) said to add the label
>> > "@login_required" to views that I wish to restrict user access on.
>> > Django 1.4 does not allow this; obviously the book is dated! Is there
>> > a more modern way to get the same effect?
>> >
>> > Similarly, admin does not allow access to my classes, even when I have
>> > created an Admin class; is this a new security feature?
>> >
>> > Finally, when I tried to create a view that allowed web-based user
>> > creation, the views.py file would not recognize the class "User"; is
>> > there something I need to import?
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/6ExeXS4aUn8J.
>
> 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.
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Cannot add/save flatpages via admin???

2012-04-28 Thread DjangoKid
I dont know much about Python and Django. Whenever i try to save a
flat page i got error:

ValueError at /admin/flatpages/flatpage/add/
Exception Value: Cannot use None as a query value

http://dpaste.com/739338/

I am using Python 2.7.3 and Django 1.4 ad sqlite3 as database

-- 
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 and oracle --

2012-04-28 Thread gmail

hello django boys,

i hope someone here can help me. i have a problem with django e oracle.
above the code with problem:

insert = """insert into modello (title, descrizione, url, prezzo, 
sconto)  values (:title, :descrizione, :url, 
 :prezzo, :sconto)"""

 try:
  self.c.execute(insert,{'title':item['title'], 
'descrizione':item['descrizione'],  
 'url':item['url'], 
'prezzo':['prezzo'], 'sconto':item['sconto']})


when try this code the system report this error:
ORA-01484:arrays can only be bound to PL/SQL statement

** any items is a list of different values for title,descrizione etc etc

thanks
marco


 /
 /
 



--
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.



@login_required do nothing

2012-04-28 Thread marcelo nicolet

Hi
Following the on-line docs ( 
https://docs.djangoproject.com/en/1.4/topics/auth/ ) I decorated my 
"index" view with @login_required, but nothing happens. In other words, 
it'supossed I would be redirected to a login page, else an exception 
migth raise. But the whole thing keeps doing as always.

What am I doing the wrong way?

TIA

--
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.



URL resolution in a Django template

2012-04-28 Thread LJ
I am using ajax to update a list of participants in my html page,
based on the student id selected.
I am trying to figure out how Django knows what path to look to find
my method.
Does it just go through all of the urls.py files until it finds a
method that matches the url request?

   $('#id_student').change(function(){
var student_id = $(this).val();
$.get('{% url get_required_meeting_participants %}',
{id:student_id}, function(data) {
$(".participants").last().append(data);
});
});

In other words, if I have two methods with the same name, but each in
a different directory, how would Django know which method to call?

-- 
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.



Storing Sorl-thumbnail created images in separate folder

2012-04-28 Thread Swaroop Shankar V
Hello All,
I am using sorl-thumbnail extensively in my project. It works perfectly
fine except for one issue which is regarding the storage. The default
behaviour of sorl-thumbnail is to create the images in the same folder
where the original image is stored. Is it possible to provide
a separate location for storage of generated file rather than the source
folder? I could find a setting called THUMBNAIL_STORAGE, is it the one to
be used? I am not able to figure it out from the documentation. If yes then
should i provide the absolute or relative path?

Thanks and Regards,

Swaroop Shankar V

-- 
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: @login_required do nothing

2012-04-28 Thread Jonathan D. Baker
You have to be sure and import the module at the top of your script: from 
django.contrib.auth.decorators import login_required. Otherwise, it's never in 
scope and thus not available.

Sent from my iPhone

On Apr 28, 2012, at 1:00 PM, marcelo nicolet  wrote:

> Hi
> Following the on-line docs ( 
> https://docs.djangoproject.com/en/1.4/topics/auth/ ) I decorated my "index" 
> view with @login_required, but nothing happens. In other words, it'supossed I 
> would be redirected to a login page, else an exception migth raise. But the 
> whole thing keeps doing as always.
> What am I doing the wrong way?
> 
> TIA
> 
> -- 
> 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.
> 

-- 
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: keep models simple ? where to put the business logic ?

2012-04-28 Thread HarpB
First of all, I think your function is too big if it is doing all of these 
things. Are you able to unit test the function? 

In my view, the logic for extract should not be in the model. I would 
create a class specifically for data extractions. I am assuming that the 
_store does not DB saves to the Feed model, so that logic should not be 
inside Feed. A model should only perform operations on its own model. If 
you want to do operations on 2 different models, then have a helper 
function to do so or put it in the manager of the model, not the model 
itself.

In your case, since the data is stored in 2 different storages, I would put 
the logic in a helper class inside helpers.py.
# helpers.py
class Feeder(object):
def store(data):
#  logix for storing to DB and any other storage.

@classmethod
def extract(cls, url, etag):
try:
#sub-logic here
return data, etag
except (.., ..) as ex:
# handle exceptions

@staticmethod
def extract_feed(feed)
data, etag = Feeder.extract(feed.url, feel.etag)
feed.update_etag(etag)

# models.py
class Feed():
def update_etag(self, etag):
if self.etag != etag:
self.etag = etag
self.save()

I strive for modular code and put business logic in its own classes. I unit 
test each code, so smaller the function, easier to test it and it is much 
more easier to use the code. In the above code, you could test it Feeder 
class without having a Feed model. As a side benefit, by having logic be 
independent of a specific model, you are able to much more easily use same 
piece of code for multiple purposes. i.e If you wanted to allow extracting 
for a specific url and etag from a VIEW or a specific feed from a view, you 
would be able to do both.

Overall, it comes down to what makes sense to you. Once you accept a 
certain way of coding, it is meant to PREVENT YOU from doing guess work as 
to where you placed a specific logic. So when a bug happens and need to 
find the code, you are not opening/closing files to find the logic, you 
know where you put the logic.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/r9aBzSOftAMJ.
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: Display Video inside a Text field -Django Templates

2012-04-28 Thread Pratik Mandrekar
Hi,

You will need to identify the video url in the post, then depending on
the url try do some processing, like getting the title or thumbnail
and render it back to your template. If you want to play the video,
you will need a video player. Eg. If it is a youtube link, then embed
the youtube player and use youtube api's if needed to render and load.


Pratik Mandrekar

On Apr 28, 7:56 am, Nikhil Verma  wrote:
> Hi All
>
> I have a TextField to which after applying css it looks like a markup
> editor where i write some text, paste file links upload image etc.Now  if
> the user paste a video link to that editor the video should display inide
> that editor/TextField like in other websites eg: facebook(On click Video
> link it displays on the same page).
>
> Can anybody tell me the steps how can i play the video inside a TextField ?
>
> I searched lot about iframe.In my template i have the textfield in which
> the user paste the link of video saves it and it displays.Now if the user
> click on that video link the video should display inside  that markup
> editor/textfield.
>
> My views :-
>
> def edit_post(request, post_id):
>
>     from djangobb_forum.templatetags.forum_extras import forum_editable_by
>
>     post = get_object_or_404(Post, pk=post_id)
>     topic = post.topic
>     if not forum_editable_by(post, request.user):
>         return HttpResponseRedirect(post.get_absolute_url())
>     form = build_form(EditPostForm, request, topic=topic, instance=post)
>     if form.is_valid():
>         post = form.save(commit=False)
>         post.updated_by = request.user
>         post.save()
>         return HttpResponseRedirect(post.get_absolute_url())
>
>     return {'form': form,
>             'post': post,
>            }
>
> Template
>
> {% if post.user.forum_profile.signature %}
>
>     
>     
>
>     {{ post.user.forum_profile.signature|safe }} # This is the textfield.
>
>     
>
> {% endif %}
>
> --
> Regards
> Nikhil Verma
> +91-958-273-3156

-- 
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: Display Video inside a Text field -Django Templates

2012-04-28 Thread Nikhil Verma
Hi Pratik

Thanks for the reply

{{ post.user.forum_profile.signature|safe }} contains complete text
including the urls of youtube and other links.

Only youtube links will show video(i have made them displayed in
iframe) and other will open in a new tab.

Currently this task have been achieved by jquery with lots of pain
because i was not able to find any good solution.

Do you think jquery is the write approach.

Can you give some links how do we use youtube api integration with
django templates



On Sun, Apr 29, 2012 at 1:09 AM, Pratik Mandrekar  wrote:

> Hi,
>
> You will need to identify the video url in the post, then depending on
> the url try do some processing, like getting the title or thumbnail
> and render it back to your template. If you want to play the video,
> you will need a video player. Eg. If it is a youtube link, then embed
> the youtube player and use youtube api's if needed to render and load.
>
>
> Pratik Mandrekar
>
> On Apr 28, 7:56 am, Nikhil Verma  wrote:
> > Hi All
> >
> > I have a TextField to which after applying css it looks like a markup
> > editor where i write some text, paste file links upload image etc.Now  if
> > the user paste a video link to that editor the video should display inide
> > that editor/TextField like in other websites eg: facebook(On click Video
> > link it displays on the same page).
> >
> > Can anybody tell me the steps how can i play the video inside a
> TextField ?
> >
> > I searched lot about iframe.In my template i have the textfield in which
> > the user paste the link of video saves it and it displays.Now if the user
> > click on that video link the video should display inside  that markup
> > editor/textfield.
> >
> > My views :-
> >
> > def edit_post(request, post_id):
> >
> > from djangobb_forum.templatetags.forum_extras import
> forum_editable_by
> >
> > post = get_object_or_404(Post, pk=post_id)
> > topic = post.topic
> > if not forum_editable_by(post, request.user):
> > return HttpResponseRedirect(post.get_absolute_url())
> > form = build_form(EditPostForm, request, topic=topic, instance=post)
> > if form.is_valid():
> > post = form.save(commit=False)
> > post.updated_by = request.user
> > post.save()
> > return HttpResponseRedirect(post.get_absolute_url())
> >
> > return {'form': form,
> > 'post': post,
> >}
> >
> > Template
> >
> > {% if post.user.forum_profile.signature %}
> >
> > 
> > 
> >
> > {{ post.user.forum_profile.signature|safe }} # This is the textfield.
> >
> > 
> >
> > {% endif %}
> >
> > --
> > Regards
> > Nikhil Verma
> > +91-958-273-3156
>
> --
> 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.
>
>


-- 
Regards
Nikhil Verma
+91-958-273-3156

-- 
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: @login_required do nothing

2012-04-28 Thread marcelo nicolet

Thanks, but of course the views module does the import.
I'm a python newbie. Just to test it, I commented the import line, and 
the page loads without trouble. I suppose that referencing a symbol not 
imported would raise an exception!


On 04/28/2012 04:18 PM, Jonathan D. Baker wrote:

You have to be sure and import the module at the top of your script: from 
django.contrib.auth.decorators import login_required. Otherwise, it's never in 
scope and thus not available.

Sent from my iPhone

On Apr 28, 2012, at 1:00 PM, marcelo nicolet  wrote:


Hi
Following the on-line docs ( https://docs.djangoproject.com/en/1.4/topics/auth/ ) I 
decorated my "index" view with @login_required, but nothing happens. In other 
words, it'supossed I would be redirected to a login page, else an exception migth raise. 
But the whole thing keeps doing as always.
What am I doing the wrong way?

TIA

--
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.



--
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.



dutch django hoster

2012-04-28 Thread Vidja
I'm looking for a reliable Dutch (speaking) hosting company that is
able to host a Django based website for a small non-profit
organization with ,surprise, ... a low budget. The idea is that when
something goes wrong they can just call a support help desk and they
don't have to deal with maintenance etc. The expected traffic is low.

Any suggestions are welcome.

-- 
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: Cannot add/save flatpages via admin???

2012-04-28 Thread Karen Tracey
This was a bug in the flatpage form validation, where it would throw
an exception rather than give you an error message if you did not
specify any values for the required sites field. Fixed now on git
master. You can also avoid it by being sure to select at least one
site for the page.

Karen
-- 
http://tracey.org/kmt/

-- 
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: URL resolution in a Django template

2012-04-28 Thread Karen Tracey
On Sat, Apr 28, 2012 at 3:04 PM, LJ  wrote:
> In other words, if I have two methods with the same name, but each in
> a different directory, how would Django know which method to call?

By "method" here I think you are meaning "url pattern" (specifically,
get_required_meeting_participants in your example snippet). The answer
is Django would not know which one to call if you have named two
different url patterns with the same name. This case is documented to
be "undefined behavior", see the note under:
https://docs.djangoproject.com/en/1.4/topics/http/urls/#id2

Karen
-- 
http://tracey.org/kmt/

-- 
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.



Databases

2012-04-28 Thread Aurelio
Hi there, I am new to Django and I have set up my models and admin
site working as I want. Perfect!

But, I have a problem; I am making a little project for a search
engine so I have a webcrawler, so my question is: Is there a way to
acces and modify the database with the program? (not with the shell or
admin site)

My Django version is 1.4 and python is 2.6.

-- 
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: Databases

2012-04-28 Thread Shawn Milochik
Assuming your PYTHONPATH is set up properly, and your 
DJANGO_SETTINGS_MODULE is correct or you import your settings file from 
your crawler, then you can just import and use the models.



--
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: @login_required do nothing

2012-04-28 Thread Jonathan Baker
Apologies, as I shouldn't have assumed that the import had not taken place.
Would you mind posting the views.py to pastebin or codepad?

On Sat, Apr 28, 2012 at 2:24 PM, marcelo nicolet
wrote:

> Thanks, but of course the views module does the import.
> I'm a python newbie. Just to test it, I commented the import line, and the
> page loads without trouble. I suppose that referencing a symbol not
> imported would raise an exception!
>
>
> On 04/28/2012 04:18 PM, Jonathan D. Baker wrote:
>
>> You have to be sure and import the module at the top of your script: from
>> django.contrib.auth.decorators import login_required. Otherwise, it's never
>> in scope and thus not available.
>>
>> Sent from my iPhone
>>
>> On Apr 28, 2012, at 1:00 PM, marcelo 
>> nicolet>
>>  wrote:
>>
>>  Hi
>>> Following the on-line docs ( https://docs.djangoproject.**
>>> com/en/1.4/topics/auth/)
>>>  I decorated my "index" view with @login_required, but nothing happens. In
>>> other words, it'supossed I would be redirected to a login page, else an
>>> exception migth raise. But the whole thing keeps doing as always.
>>> What am I doing the wrong way?
>>>
>>> TIA
>>>
>>> --
>>> 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+unsubscribe@*
>>> *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-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: @login_required do nothing

2012-04-28 Thread yati sagade
Hi
Have you set the LOGIN_URL setting in settings.py? That setting should be
assigned a location(e.g., "/login/") to redirect to when your view is
called without the user logged in. Also, you can do this if for some reason
you don't want to have that setting.

@login_required(login_url="/login/")
def index(request):
 


On Sun, Apr 29, 2012 at 10:15 AM, Jonathan Baker <
jonathandavidba...@gmail.com> wrote:

> Apologies, as I shouldn't have assumed that the import had not taken
> place. Would you mind posting the views.py to pastebin or codepad?
>
>
> On Sat, Apr 28, 2012 at 2:24 PM, marcelo nicolet <
> marcelo.nico...@gmail.com> wrote:
>
>> Thanks, but of course the views module does the import.
>> I'm a python newbie. Just to test it, I commented the import line, and
>> the page loads without trouble. I suppose that referencing a symbol not
>> imported would raise an exception!
>>
>>
>> On 04/28/2012 04:18 PM, Jonathan D. Baker wrote:
>>
>>> You have to be sure and import the module at the top of your script:
>>> from django.contrib.auth.decorators import login_required. Otherwise, it's
>>> never in scope and thus not available.
>>>
>>> Sent from my iPhone
>>>
>>> On Apr 28, 2012, at 1:00 PM, marcelo 
>>> nicolet>
>>>  wrote:
>>>
>>>  Hi
 Following the on-line docs ( https://docs.djangoproject.**
 com/en/1.4/topics/auth/)
  I decorated my "index" view with @login_required, but nothing happens. In
 other words, it'supossed I would be redirected to a login page, else an
 exception migth raise. But the whole thing keeps doing as always.
 What am I doing the wrong way?

 TIA

 --
 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+unsubscribe@
 **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-users@googlegroups.com.
>> To unsubscribe from this group, send email to django-users+unsubscribe@**
>> googlegroups.com .
>> For more options, visit this group at http://groups.google.com/**
>> group/django-users?hl=en
>> .
>>
>>
>
>
> --
> Jonathan D. Baker
> Developer
> http://jonathandbaker.com
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Yati Sagade 

Twitter: @yati_itay 

Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869

-- 
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.