If the operations are model related, why don't move some of those functions
to models.py.
On Mon 19 Jan 2015 at 08:46 Mike Dewhirst wrote:
> On 19/01/2015 6:28 PM, Cheng Guo wrote:
> > Hello,
> >
> > I am new to Django and I have run into an issue with views.py. I
> > understand that there is a
Great, 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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@goo
Great, thanks!
On Monday, 19 January 2015 15:46:40 UTC+8, Mike Dewhirst wrote:
>
> On 19/01/2015 6:28 PM, Cheng Guo wrote:
> > Hello,
> >
> > I am new to Django and I have run into an issue with views.py. I
> > understand that there is a function behind each view. For a view that I
> > am cu
I second moving some (or most) of the functionality to models.py. For
instance, calculating the SHA value should be done as part of the model's
save() function, not done in the view.
Convention dictates that the only code that is placed in the view itself
should be logic related to prepping the te
So in my case, I need to generate a unique id for the file and save it to
disk.
I have a model called UploadFile, so you recommend to add two class methods
to the UploadFile model, like the following?
class UploadFile(models.Model):
@classmethod
def generate_id():
pass
@cla
I wouldn't decorate them as class methods. You would want to call them from
the objects themselves. For the save_to_disk() method, I was actually
referring to the Django save() method (
https://docs.djangoproject.com/en/1.7/topics/db/models/#overriding-predefined-model-methods
).
As you have it no
On Monday, 19 January 2015 07:28:14 UTC, Cheng Guo wrote:
>
> Hello,
>
> I am new to Django and I have run into an issue with views.py. I
> understand that there is a function behind each view. For a view that I am
> currently writing, it accepts a file upload from user and stores the file
> on
I have created user earlier in code with email address and password.
Created users work fine.
Now in later phase I asked more information and would like to fill in
first_name and last_name.
Code shows old first_name and last_name properly if set in admin view, but
logged in user cannot save his
On Monday, 19 January 2015 09:22:02 UTC, joulumaa wrote:
>
> I have created user earlier in code with email address and password.
> Created users work fine.
> Now in later phase I asked more information and would like to fill in
> first_name and last_name.
> Code shows old first_name and last_nam
Ignoring the malformed code, will the call to authenticate() even work
without username? According to the docs,
https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.authenticate
It takes credentials in the form of keyword arguments, for the default
> configuration this
In addition to the other answers, I will suggest that you re-think your
view logic - you haven't handled the case where your IF block fails.
Remember, Django expects every view function to return a HttpResponse
object. Assume that someone's request isn't authorized (yet) or even
rejected. What
I need to include two different contact forms in my app. One a general
contact form and another Report / Feedback form that pre-fills some data
depending on which site it was called from.
So I hit google, found django-contact-form, installed it and after creating
some basic templates (and rest
I guess I'm not clear on what you are trying to achieve. There are a couple
of scenarios to consider.
As it stands with the default contrib.auth authentication backend, sending
both the username and email address entered by the user will only work IF
the user registered/was created using their ema
Right now the "reportForm" variable is pointing to the RequestForm class,
not to an object, so you need to do it like this
reportForm = ReportForm()# Take note of the parenthesis
In your template, your form tag need an action attribute (well, it's not
mandatory but it is highly advised). In t
Thanks for the reply. I was wondering about the if statement about
request.type as well, but I took the code from Stackoverflow and a
combination of the original source code. It calls a Class.as_view() and I
wasn't sure if I need to overwrite that as well. I didn't really want to
write all the
According to the official documentation I'm still unsure if I need to type
anything in my views.py at all.
As far as I understand this, I just need to subclass ContactForm somehow:
class ContactForm(forms.Form): """ The base contact form class from which all
contact form classes should inherit.
Thanks for the reply. I was wondering about the if statement about
request.type as well, but I took the code from Stackoverflow and a
combination of the original source code. It calls a Class.as_view() and I
wasn't sure if I need to overwrite that as well. I didn't really want to
write all the
OK, I read a little of the library documentation, and this is what you have
to do I think
1. subclass the ContactForm (you already have that)
2. subclass the ContactFormView from the library, at least with this:
class ReportFormView(ContactFormView):
form_class = ReportForm
3. Map this view
I managed to do it! Thanks to your help.
Ok all you need to do is this:
views.py:
class ReportFormView(FormView):
form_class = ReportForm
template_name = 'contact_form/contact_form.html'
def form_valid(self, form):
form.save()
return super(ReportFormView, self).form_v
my view:
def aget(request):
if request.is_ajax() :
json_data={}
json_data['messege']= 'sorry'
return HttpResponse(json.dumps(json_data),
content_type='applicaton/json')
my url:
urlpatterns = patterns('',
url(r'^$', 'post.views.home', na
*Hi,*
*What i understood is that you need two different forms on single page. and
later on you want to map feedback form as site specific.*
*So you can do with two different ways:*
*1) define two different form action path.*
* ...form fields... ...form
fields...*
*2) you have will
Hi, I am trying to build a single page, restful application to track
expenses that allows users to sign up, log in, and edit / delete / filter
expenses, all on a single page. I am very new to Django, and all other web
technologies and this app is making my head spin. I have been working on
th
Why would it make sense to switch from different form type?
I use below form to get information that I like to save to user database?
Part of information I need ot update goes to Additional user info class, I
would like to stay in my own form.
-Thanks
maanantai 19. tammikuuta 2015 11.26.47 UTC+2
Quick guess, you are visiting the site in your browser using
http://localhost:8000. I'm betting if you instead visited it using
http://127.0.0.1:8000, the AJAX query would work fine.
You have http://127.0.0.1:8000 hard coded (or being generated) everywhere.
Either change your JavaScript to use loc
I'm using Swampdragon to provide real time updates to the system since I
don't want users to keep refreshing their page to get them. I used the
*ModelPublisherRouter* which causes me to get any updates to a particular
model.
I currently have an Events model with the following attributes:
class
Thanks Mitesh
I thought it might be along those lines. I have tried calling plt.close()
just before I return from the plot creation function, but still get the
same error.
Do you perhaps have a simple code example I can try and follow? (I am
already using the io module for the image storage.
If you don't end up using Celery, another option for a periodic action is
to create a management command and schedule it to run with Task Scheduler
(http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx).
Regards,
Michael Manfre
On Sunday, January 18, 2015 at 11:12:
For single page applications I highly recommend this tutorial, it answers
the typical questions regarding single page apps.
https://thinkster.io/brewer/angular-django-tutorial/
(assuming you are using angularJS)
On Mon, Jan 19, 2015 at 5:08 AM, wrote:
> Hi, I am trying to build a single page,
On Sat, Jan 17, 2015 at 10:03 AM, Larry Martell wrote:
> We have a django app accessed via SSL (i.e. with https). When we went
> to the admin site and it was redirected to admin/login/?next=/admin/
> because we were not logged in, the https was not carried over and the
> request failed. I added
>
Hi,
Are you using AUTH_USER_MODEL?
I assume your logging is set up correctly?
Here's a snippet from one of my projects if you want to try out some
similar code:
def user_save_handler(sender, **kwargs):
user = kwargs['instance']
try:
user.userprofile
except UserProfile.DoesN
Hi,
Yes, looking at the code, it appears that there's nothing preventing you
from creating clashing custom permissions.
Ideally, the unique_together should be on ('content_type__app_name',
'codename') if that's even possible.
Collin
On Friday, January 16, 2015 at 1:37:02 PM UTC-5, Torsten Bro
Hi,
You might be able to do something like:
self.forms[3].add_error('field_name', 'error message')
https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.add_error
Collin
On Saturday, January 17, 2015 at 10:46:27 PM UTC-5, Richard Brockie wrote:
>
> Hi everyone,
>
> In a formse
Hi All,
Also, check out assignment_tags if you haven't seen them.
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#assignment-tags
Collin
On Sunday, January 18, 2015 at 8:09:58 AM UTC-5, James Schneider wrote:
>
> If you need it in all of (or a large majority of) your templates,
Hi,
Here's a nice tutorial:
http://musings.tinbrain.net/blog/2014/sep/21/registration-django-easy-way/
Collin
On Saturday, January 17, 2015 at 1:20:56 PM UTC-5, Ben Gorman wrote:
>
> I've spent the past few weeks trying to set up a custom (but not
> unreasonable) user registration and authentic
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi folks,
after upgrading my project to Django 1.7 it seems my host validation
got a bit out of control. I have tried these possibilities, but my web
server continues to send lots of mail about invalid HTTP_HOST headers:
ALLOWED_HOSTS = [ ".example.c
Sank's for responding, but we already made all, there was no DB after
server crash or something like this.
On Sat, Jan 17, 2015 at 4:12 PM, Collin Anderson
wrote:
> Hi,
>
> Did you figure it out? It looks like you need to configure your urls.py so
> it's connected with django-cms.
>
> Collin
>
>
Something similar is happening with me too: on a post_save of model it
isn't created yet on database, so several
error are raised by functions which expect that it is already on DB.
When the post_save handler ends, the object is saved normally.
On Friday, January 16, 2015 at 4:14:09 PM UTC-2,
Thank you - that looks like what I am looking for! I don't know how I
missed that.
I'm on 1.6 right now - another reason to move to 1.7 :)
R.
On Mon, Jan 19, 2015 at 9:16 AM, Collin Anderson
wrote:
> Hi,
>
> You might be able to do something like:
>
> self.forms[3].add_error('field_name', 'err
Hello
i am trying to use Dkango with Python3.4.2 and mysql
i have downloaded mysqlclient-1.3.4 but i don't know how to install it.
it's a .whl file
Can you help me please?
Many thanks
T.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To
> Den 19/01/2015 kl. 19.55 skrev th.gran...@free.fr:
>
> Hello
>
> i am trying to use Dkango with Python3.4.2 and mysql
>
> i have downloaded mysqlclient-1.3.4 but i don't know how to install it. it's
> a .whl file
>
> Can you help me please?
Just use pip instead. This should get you the lat
On Monday, January 19, 2015 at 7:55:06 PM UTC+1, th.gr...@free.fr wrote:
>
> Hello
>
> i am trying to use Dkango with Python3.4.2 and mysql
>
> i have downloaded mysqlclient-1.3.4 but i don't know how to install it.
> it's a .whl file
>
> Can you help me please?
>
> Many thanks
>
>
Thanks but i
What is the most elegant way to
lock the Django DB while I make a complex transaction (read, decide, write)
... during which no other uwsgi worker should have access (or at least
no write access) to that table?
I am using Django + db.sqlite3 + uwsgi (+ nginx).
Thanks a lot!
Andreas
> Den 19/01/2015 kl. 20.28 skrev th.gran...@free.fr:
> Thanks but i have a problem!
>
> when i launch the install command i get these errors
>
> Downloading mysqlclient-1.3.4.tar.gz (77kB)
>100% || 77kB 356kB/s
>/bin/sh: 1: mysql_config: not found
>Tra
> Den 19/01/2015 kl. 19.24 skrev Andreas Krueger :
>
>
>
> What is the most elegant way to
>
> lock the Django DB while I make a complex transaction (read, decide, write)
>
> ... during which no other uwsgi worker should have access (or at least no
> write access) to that table?
That's a ra
Hello
I'm creating a Django frontend for a legacy school system. The legacy system
has users, but usernames are only unique together with a school:
class LegacyUser(models.Model):
school = models.ForeignKey(School)
username = models.CharField(max_length=40)
class Meta:
unique_to
Just as a case study, Shibboleth does this by having unscoped and
scoped usernames. The scoped username should be globally unique and
takes the form of "u...@school1.edu". Unscopped is not globally
unique, but unique for a particular scope (ie: "user").
It's temping to say "ahh... email address!"
That's an interesting (but understandable) requirement, which means you are
probably in for an interesting time.
Undoubtedly you'll need to roll your own authentication backend (
https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#authentication-backends)
and a custom user that contains
Hmm, yes, Shibboleth will require some extra trickery in multiple views
with redirects to the respective campus portal, etc. I've never done it
myself, but I believe the API is pretty well documented.
-James
On Jan 19, 2015 1:48 PM, "James Schneider" wrote:
> That's an interesting (but understan
Shibboleth 2.0 lets you setup a discovery service (or portal would
perhaps be a better term) letting the user select which ID Provider
(IdP) they will authenticate to. All you have to do on the Service
Provider (SP) side is specify the discovery URL and what IdPs you
allow. Nothing needs to be done
First off: this sounds like a bug, please log an issue on Github with as
much info as possible (router, serializer and model etc. if you can)
I would recommend not using `SelfPublishModel` in this scenario, instead
publish the event manually.
If you do it manually you lose out on having it publi
For a pure authentication scenario where permission checks never go beyond
user.is_authenticated(), that's probably true. If all the OP is doing is
displaying data, they may be able to get away with manually associating the
campus and user within the session after, and displaying data based on
thos
Thanks very much for all the help I am getting from you guys. your help is
very much appreciated.
cheers,
On Mon, Jan 19, 2015 at 8:32 PM, Abraham Varricatt <
abraham.varric...@googlemail.com> wrote:
> In addition to the other answers, I will suggest that you re-think your
> view logic - you ha
Hello James:
Thank you very much for spending the time reading and answering this
question, really appreciated!
I complete understand your suggestion of overriding the "save" method in
the "UploadFile" to generate the id before saving. Thank you for pointing
this out.
On the other hand, I rea
Hello James:
Thank you very much for spending the time reading and answering this
question, really appreciated!
I complete understand your suggestion of overriding the "save" method in
the "UploadFile" to generate the id before saving. Thank you for pointing
this out.
On the other hand, I rea
Thank you Daniel, I didn't know this! I am going to lookup how to use
session. Thanks!
On Monday, 19 January 2015 17:13:10 UTC+8, Daniel Roseman wrote:
>
> On Monday, 19 January 2015 07:28:14 UTC, Cheng Guo wrote:
>>
>> Hello,
>>
>> I am new to Django and I have run into an issue with views.py.
Hi,
I am trying to send an email to several users once a form is submit. I have
done the view.py to update the database once the form is submitted and is
working fine. what i want to accomplish when the form is submitted is to
update the database and at the same time send out email when a user clic
Hi Everyone,
Is there any reliable django stripe payments library that does not require
to run a python manage.py syncdb? The reason I am asking is I am uaing
SQLAlchemy instead of its builtin ORM.
Thanks
--
⚡ Chen Xu ⚡
--
You received this message because you are subscribed to the Google Gr
Damn. That's one heck of an explanation James! And very detailed to boot!
As a programmer, the OP's approach to login a user with either
username/email with ONLY the default auth system seemed flawed (or
incomplete, at best) to me. You've not just validated my opinion, but given
me a wonder exp
Hi guys,
Thanks for a lot of useful answers! My schools use a palette of authentication
systems; regular hashed password check with a hash I have access to, LDAP auth
and WAYF (a Danish educational SSO solution using Shibboleth). Those are the
least of my worries right now, though.
I'll have a
"A pallet of authentication systems..."
Yep, you work for an educational entity, as do I. :-D
You can pursue the LegacyUser model as your custom user model. That would
make your LegacyUser objects the 'local' Django users that have been
referenced. Not sure about the name though, might indicate t
BTW, I reread you're last note. The references to AbstractBaseUser were
meant for inheritance, meaning that your custom user would inherit all of
the same properties and not need to redefine the wheel. You can't inherit
from AbstractUser though because you are modifying the username field.
-James
61 matches
Mail list logo