Don't even worry about factories. They're for when you want a bunch of
forms for the same model on the page at once.
Use the UserCreationForm in django.contrib.auth.forms. It only accepts
a username and password, so you can either subclass it to add the
fields or make your own form and add it to your view so that they both
appear in the same HTML form. You can validate both and do what you
need to do.
You definitely shouldn't be writing validation logic for the password
and username and such -- that's what ModelForms are for.
If you have more specific questions just ask.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Monday, April 1, 2013
djano user registration form and login(full example)
Hello,
I'm just starting with Django. I want to create a user registration form which will take input like username, password, first and last name, email, address etc.
using the same information I want to send a conformation mail to user and authenticate her/him.
I have read Django docs, from what I read either I can create a model and form separately and write authentication and other logic on my own. Other way is
to user 'formset_factory' to directly create form from model. In second case how m I going to handle password(hashing) and authentication of user?
Can Django's *auth module can be used? If yes how ?
It will be great if any one redirect me to appropriate complete example, at least to start with.
Thanx.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
I'm just starting with Django. I want to create a user registration form which will take input like username, password, first and last name, email, address etc.
using the same information I want to send a conformation mail to user and authenticate her/him.
I have read Django docs, from what I read either I can create a model and form separately and write authentication and other logic on my own. Other way is
to user 'formset_factory' to directly create form from model. In second case how m I going to handle password(hashing) and authentication of user?
Can Django's *auth module can be used? If yes how ?
It will be great if any one redirect me to appropriate complete example, at least to start with.
Thanx.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.
Stick a print statement between lines 91 and 92 to show you model_module.__name__ .
(or use pdb if you're comfortable with it). My best guess is that the split() is returning alist of one item. That is, that there is no '.' in model_module.__name__ . Thus an index
of -2 failss: there is no penultimate item.
On Mon, Apr 1, 2013 at 1:48 PM, C Alaric Moore <alaricmeister@gmail.com> wrote:
I just tried this and still have the same error. I also might add that I'm using a mac with an updated os. I also hear that it could be an issue of line breaks, but can't find any /n's or /r's in any of the code anyway. I might just be looking in the wrong places, too.
On Sunday, March 31, 2013 9:33:21 PM UTC-7, jondbaker wrote:When importing Python modules, you don't need to include the '.py' file extension. So,from models.py import UUID...needs to be:from models import UUIDHope this helps,JonathanOn Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore <alaric...@gmail.com> wrote:
Hello,
I am incredibly new to Django, as-of-today new, so forgive me if I've missed something really obvious.
I've been going through the tutorial and did so mostly-successfully and decided to redo it with my own code.
Everything was going fine until I decided that it would be a good idea to type from models.py import UUID, Students into the shell. With this I received the following error:
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc in __new__(cls, name, bases, attrs)
90 # For 'django.contrib.sites.models', this would be 'sites'.
91 model_module = sys.modules[new_class.__module__]
---> 92 kwargs = {"app_label": model_module.__name__.split('.')[-2]}
93 else:
94 kwargs = {}
IndexError: list index out of range
I went onto stackoverflow and found some people had similar issues a year ago, and suggested that a person delete the pyc files, which I did. It was also suggested that you make DEBUGGING = False, or True or whatever is opposite. I did this, too, only to find the same error.
I did some other things too, all to no avail... all the same error. I even checked to make sure I was saving edited files, TWICE. Still, same error.
With this, I ask for your help o' wise ones.
Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.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...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.
I just tried this and still have the same error. I also might add that I'm using a mac with an updated os. I also hear that it could be an issue of line breaks, but can't find any /n's or /r's in any of the code anyway. I might just be looking in the wrong places, too.
On Sunday, March 31, 2013 9:33:21 PM UTC-7, jondbaker wrote:
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
On Sunday, March 31, 2013 9:33:21 PM UTC-7, jondbaker wrote:
--When importing Python modules, you don't need to include the '.py' file extension. So,from models.py import UUID...needs to be:from models import UUIDHope this helps,JonathanOn Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore <alaric...@gmail.com> wrote:
Hello,
I am incredibly new to Django, as-of-today new, so forgive me if I've missed something really obvious.
I've been going through the tutorial and did so mostly-successfully and decided to redo it with my own code.
Everything was going fine until I decided that it would be a good idea to type from models.py import UUID, Students into the shell. With this I received the following error:
/Library/Frameworks/Python.framework/Versions/7.3/lib/ python2.7/site-packages/ django/db/models/base.pyc in __new__(cls, name, bases, attrs)
90 # For 'django.contrib.sites.models', this would be 'sites'.
91 model_module = sys.modules[new_class.__module__]
---> 92 kwargs = {"app_label": model_module.__name__.split('.')[-2]}
93 else:
94 kwargs = {}
IndexError: list index out of range
I went onto stackoverflow and found some people had similar issues a year ago, and suggested that a person delete the pyc files, which I did. It was also suggested that you make DEBUGGING = False, or True or whatever is opposite. I did this, too, only to find the same error.
I did some other things too, all to no avail... all the same error. I even checked to make sure I was saving edited files, TWICE. Still, same error.
With this, I ask for your help o' wise ones.
Thanks.
--
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...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en .
For more options, visit https://groups.google.com/groups/opt_out .
--
Jonathan D. Baker
Developer
http://jonathandbaker.com
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Confusion about Static Files
it is very simple and doesn't require a separate http server like nginx
first you configure in settings.py the variables STATIC_ROOT and STATIC_URL, then configure http server accordingly
STATIC_ROOT is the absolute path in filesystem that stores your static files, you can put that inside django project itself if it is convenient
and then in apache use Alias and Directory accordingly
STATIC_ROOT = '/srv/django/static_files'
STATIC_URL = '/django_static/'
then in apache :
ALias /django_static/ /srv/django/static_files/
<Directory /srv/django/static_files>
Require all granted
</Directory>
On Friday, March 29, 2013 10:36:30 PM UTC+3, David Pitchford wrote:
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
first you configure in settings.py the variables STATIC_ROOT and STATIC_URL, then configure http server accordingly
STATIC_ROOT is the absolute path in filesystem that stores your static files, you can put that inside django project itself if it is convenient
and then in apache use Alias and Directory accordingly
STATIC_ROOT = '/srv/django/static_files'
STATIC_URL = '/django_static/'
then in apache :
ALias /django_static/ /srv/django/static_files/
<Directory /srv/django/static_files>
Require all granted
</Directory>
On Friday, March 29, 2013 10:36:30 PM UTC+3, David Pitchford wrote:
I am experienced with Python but new to Django and web development in general. I am struggling to understand its static files system from the documentation. It seems like I have to set multiple settings variables and create multiple folders in order to get the server to accomplish the simple task of "finding" these files. After toying with it for a few hours I haven't been able to get the static files system to work and and have resorted to the following system which is probably a very bad idea:--In views.py:from django.http import HttpResponsefrom django.shortcuts import render_to_responsefrom django.template import RequestContextimport datetimeimport os.pathimport settingsstatictypes = {".css": "text/css",".js": "text/javascript"}def servestatic(request, filename):fullfilename = os.path.join(settings.STATIC_ROOT, filename) ext = os.path.splitext(filename)[1]return HttpResponse(open(fullfilename).read(), content_type=statictypes[ext]) And in urls.py:from django.conf.urls import patterns, include, urlimport mysite.views as viewsstaticextensions = [ext[1:] for ext in views.statictypes.keys()]staticextstring = '|'.join(staticextensions)urlpatterns = patterns('',...(r"([^/]+\.(?:%s))$" % staticextstring, views.servestatic))This actually works (and I could optimize it by caching the static file contents in memory rather than continually rereading them), but of course it's circumventing Django's built-in system for managing static files. My project architecture looks like this:mysite||--manage.py|--mysite||__init__.py|settings.py|urls.py|views.py|wgsi.py|--static| || |--jquery.js| |--TestFormat.css||--templates||--TestTemplate.htmlAt the beginning, the documentation page mentions, "For small projects, this isn't a big deal, because you can just keep the static files somewhere your web server can find it." This sounds like the simple solution I'm looking for; what does it mean and how do I do it? I'm also frequently confused by how when I created the project it created two nested folders with the same name. Which is considered to be the "project root"?
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
template composition
i read about template inheritance and think it is great
but there is the possibility of including one template output as context variable for another template
for example :
c = new RequestContest()
c['navigation'] = render_to_string('navigation.html', {'links': links})
output = render_to_response('page.html', {}, c)
and then in page.html :
<html>
<body>
<div class="navigation"> {{ navigation }} </div>
<div class="content"> ... </div>
</body>
</html>
so my question is would this method break cache or damage performance or some other problem ?
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
but there is the possibility of including one template output as context variable for another template
for example :
c = new RequestContest()
c['navigation'] = render_to_string('navigation.html', {'links': links})
output = render_to_response('page.html', {}, c)
and then in page.html :
<html>
<body>
<div class="navigation"> {{ navigation }} </div>
<div class="content"> ... </div>
</body>
</html>
so my question is would this method break cache or damage performance or some other problem ?
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Django 1.5 with uwsgi(threaded)/mysql seems to magically cache querysets
So far I don't have this issue at all with 1.4, which makes sense as it started exactly at the 1.5 upgrade time for me.
On Monday, April 1, 2013 7:40:08 AM UTC-6, budl...@gmail.com wrote:
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
On Monday, April 1, 2013 7:40:08 AM UTC-6, budl...@gmail.com wrote:
So I have some stats reports that I run that it almost seems as if each thread has its own queryset cached. Each time I refresh they change. I'm going to revert back to 1.4 due to this bug. I wish I could come up with a simple example, to demonstrate this, the problem is that the underlying database needs to change between the time each thread serves a request.--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Posts (Atom)