Re: Django login() function works in production but not in development

2018-05-21 Thread pieceofkayk2718
I should elaborate even further.. The 'do something' does not show, instead 
the 'do something else' shows.

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/22888574-c869-4b0d-9215-283073229604%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django login() function works in production but not in development

2018-05-21 Thread pieceofkayk2718
Thanks, I probably should elaborate on that.  I determine the user does not 
get logged in through the logic of my template language.  I have {% if 
user.is_authenticated %} do something {% else %} do something else {% endif 
%} where user is passed through the context dictionary of my corresponding 
view displayed above.

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2baac722-e1d1-4c6a-833e-69e69a7542a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django login() function works in production but not in development

2018-05-16 Thread pieceofkayk2718


Hey, Tonghua.

Could you elaborate more on the shared set of databases?  So yes, the login 
session is stored in the database.  But wouldn't my two applications have 
two distinct database files?  My reasoning would be due to having two 
distinct locations for my in-development copy and in-production copy.

Thanks for your time,
K

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/94b3dc4d-b994-4d41-8180-eb86130b1804%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django login() function works in production but not in development

2018-05-14 Thread pieceofkayk2718
Hey All,

So I have a django project in a directory for production.  I have the same 
exact project in a separate repository for development.  I literally have 
copied and pasted my project over and the only changes I have made are 
switching debug from false to true.  So my project has the same database, 
same code, everything.  When I start up my local copy and go to login, the 
login function does not work.  Below is my simple login view.  My code 
returns the print statement 'User is active' when I sign in with a user on 
my project page; however, my user never gets logged in during the next 
step.  Does anyone have any clues as to why this might be?  Thanks for your 
time.


views.py
def friend_login(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)

if user:
if user.is_active:
# the User model is valid and active, so we can log the 
user in
print 'User is active'
login(request, user)
return HttpResponseRedirect(reverse('main:index'))
else:
# An inactive account was used - no logging in!
print 'User is inactive'
return render(request, 'friends/inactive.html', {'user':user
})
else:
# Bad login credentials
return HttpResponse("Invalid login details supplied.")
else:
# Not a POST, so simply display the login form
return render(request, 'friends/login.html', {})


-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8821e5bc-0a14-47e2-82bd-8b229daaf50d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Upload file to a dynamically generated location

2018-01-08 Thread pieceofkayk2718
Hey Friends,

I'm having trouble figuring out how to upload a document model to a 
dynamically generated location.  The following models.py file contains two 
models and a helper function


views.py


# I would like the string inputs to be self.bundle.user, and 
self.bundle.name  where self is the document model.  I know this doesn't 
work which is why I am here asking this question.
def get_user_document_directory():
document_directory = 'media/{0}/{1}/documents/'.format( , _ ) 
return document_directory

class Bundle(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100)

class Document(models.Model):
bundle = models.ForeignKey(Bundle)
name = models.CharField(max_length=100)
description = models.CharField(max_length=100)
document = models.FileField(upload_to=get_user_document_directory(self) 
) # I know passing self doesn't work but just trying to get the point 
across of what I am trying to do.
uploaded_at = models.DateTimeField(auto_now_add=True)



Any comments about how to remedy this situation would be greatly 
appreciated.  

Thanks,
K

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71125202-9b89-4572-a086-ab9fed2b4d01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View to download a tar archive

2017-09-15 Thread pieceofkayk2718
Ahh, thank you James.  :).  Especially for that last link!

>

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ffca0d9c-9e8f-4d45-bd62-6dc8136a11a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


View to download a tar archive

2017-09-14 Thread pieceofkayk2718
Hey guys,

I'm trying to make a view so that my users can download a compressed tar 
archive.  I've seen a ton of examples about downloading files yet cannot 
seem to find anything regarding tar.  Anyone want to drop me an awesome 
example?


for a simple file I have

def download_file(request, pk):
my_model = SomeModel.objects.get(pk=pk)
file_path = my_model.get_file_path()

if os.path.exists(file_path):
with open(file_path, 'rb') as fh:
response = HttpResponse(fh.read(), content_type="")
response['Content-Disposition'] = 'inline; filename=' + os.path.
basename(file_path)
return reponse




-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/642f29c5-8aea-40f4-a6a7-55a8e7bfac83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: include template in a page

2017-08-23 Thread pieceofkayk2718
Do you have an action on your register form?  Like 

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce2a92c4-270a-46c9-9b49-06a2d72cf72b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieving objects created in trasaction

2017-08-23 Thread pieceofkayk2718
Try foo.save() before foo.bars.add(). 

>
>

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39fc5e90-e030-44f4-b129-765def7e985b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Use separate apps or only one app in my project

2017-08-23 Thread pieceofkayk2718
Can you give a more concrete example?  

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ab1d838-b594-4ab2-9a02-edc81f8c7f46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ManyToManyField's add() function is doing nada for me.

2017-08-23 Thread pieceofkayk2718
I am simply trying to add a Bundle model to my Instrument model.  It should 
be really easy but I can't seem to figure out why it's not working.

context.models.py

class Instrument(models.Model):
title = models.CharField(max_length=200)
bundle = models.ManyToManyField(Bundle, blank=True)




build.models.py

class Bundle(models.Model):
title = models.CharField(max_length=200)


views.py

def instrument_host_detail(request, pk_bundle, pk_instrument_host):
form_choose_instruments = ChooseInstrumentsForm()
form_choose_targets = ChooseTargetsForm()
bundle = Bundle.objects.get(pk=pk_bundle)
context_dict = {}

if request.method == 'POST':
form_choose_instruments = ChooseInstrumentsForm(request.POST)
form_choose_targets = ChooseTargetsForm(request.POST)

if form_choose_instruments.is_valid() and 
form_choose_targets.is_valid():
for instrument_name in 
form_choose_instruments.cleaned_data['instrument_list']:
instrument = Instrument.objects.get(title=instrument_name)
print bundle
print '{} -- {}'.format(instrument.pk, instrument)
instrument.bundle.add(bundle)
#instrument.save()
print instrument.bundle

context_dict['bundle'] = bundle
context_dict['form_choose_instruments'] = form_choose_instruments
context_dict['form_choose_targets'] = form_choose_targets


return render(request, 'detail.html', context_dict)

When my view hits print bundle it will print the bundle title.  When my 
view hits print instrument.pk and instrument it will show it is an 
instrument model.  However, if I try to add the bundle to my instrument 
model, I don't get any action.  The print statement returns 
build.Bundle.None (where build_a_bundle is the app that Bundle model lives 
in).  Also in the shell and admin I'm seeing that my bundle model isn't 
being added.  

Note:  The comment on instrument.save() was me toggling whether or not it 
was necessary and in both cases I'm not getting anything.  The 
documentation didn't show that it was necessary.

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6f24c68d-c199-4c47-8ddc-ff1124cf5d35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying Django Tutorials or Guides - mod_wsgi, Apache, Linux

2017-08-22 Thread pieceofkayk2718
I should add Python 2.7, Django 1.11

>
>

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b3ed091d-5679-4710-a106-5a1065e38259%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Deploying Django Tutorials or Guides - mod_wsgi, Apache, Linux

2017-08-22 Thread pieceofkayk2718
Does anyone have any good tutorials or guides on how to deploy a Django 
project using mod_wsgi, Apache, and Linux?  The documentation isn't really 
cutting it for my beginner self.
Thanks in advance!


-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5f80d0bf-bbb9-491c-9066-ff36a6479a50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Permissions: Let only the user who created the model see the detail view for the model

2017-08-07 Thread pieceofkayk2718
Hey,

I am building an app where a user needs to create Bundle models.  I am 
providing a Bundle detail view with options for the user to add components 
or edit the components in their Bundle model.  I currently have it where 
any signed in user can access these bundles.  I would like to restrict 
access to this detail page to only the user who created the Bundle model 
(and the admins as well if possible).  What is the best way to go about 
this?  

models.py
class Bundle(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)

urls.py
from . import views

urlpatterns=[
url(r'^(?P\d+)/$', views.BundleDetail.as_view(), name=
'bundle_detail'),
]

views.py
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.utils.decorators import method_decorator
from django.views import generic
from .models import Bundle

@method_decorator(login_required, name='dispatch')
class BundleDetail(LoginRequiredMixin, generic.DetailView):
model = Bundle




-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/940c11dc-7d91-4041-ad4b-076dcfc85e9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
fml.  Thank you.

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a7c3f5df-ff30-4d5a-a876-f4614ded0feb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
fml.  Thank you.

On Tuesday, August 1, 2017 at 12:55:10 PM UTC-6, Dylan Reinhold wrote:
>
> You have a quoting miss-match in your enctype, that might be messing with 
> the csrf_token
>
>enctype='multipart/form-data">
>
> On Tue, Aug 1, 2017 at 9:57 AM,  
> wrote:
>
>> Hey,
>>
>> I recently started playing with my user registration and login and logout 
>> stuff for an app.  It worked fine before I moved it but now that it's moved 
>> I keep getting the following error:
>>
>>
>> Forbidden (403) 
>>>
>>> CSRF verification failed. Request aborted.
>>> Help 
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>> 
>>>
>>> In general, this can occur when there is a genuine Cross Site Request 
>>> Forgery, or when Django's CSRF mechanism 
>>>  has not been used 
>>> correctly. For POST forms, you need to ensure:
>>>
>>>- Your browser is accepting cookies.
>>>- The view function passes a request to the template's render 
>>>
>>> 
>>>  
>>>method.
>>>- In the template, there is a {% csrf_token %} template tag inside 
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use 
>>>csrf_protect on any views that use the csrf_token template tag, as 
>>>well as those that accept the POST data.
>>>- The form has a valid CSRF token. After logging in in another 
>>>browser tab or hitting the back button after a login, you may need to 
>>>reload the page with the form, because the token is rotated after a 
>>> login.
>>>
>>> You're seeing the help section of this page because you have DEBUG = 
>>> True in your Django settings file. Change that to False, and only the 
>>> initial error message will be displayed. 
>>>
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>
>>
>> The following are my codes.  If I'm missing any useful info just let me 
>> know and I'll add it in.
>>
>> views.py 
>> def register(request):
>> # Boolean value.  Upon successful registration, registered will be 
>> changed to True
>> registered = False
>>
>> user_form = UserForm(data=request.POST or None)
>> profile_form = UserProfileForm(data=request.POST or None)
>>
>> if user_form.is_valid() and profile_form.is_valid():
>> user = user_form.save()
>> user.set_password(user.password)
>> user.save()
>> profile = profile_form.save(commit=False)
>> profile.user = user
>> profile.save()
>> registered = True
>>
>> return render(request, 'friends/register.html', {'user_form':
>> user_form, 'profile_form':profile_form, 'registered':registered})
>>
>>
>> register.html
>> {% extends 'hallo/base-k.html' %}
>> {% load staticfiles %}
>>
>> {% block title_block %}
>> Register
>> {% endblock %}
>>
>> {% block body_block %}
>> 
>> 
>>
>> {% if registered %}
>> 
>> 
>> Thank you for registering!
>> 
>> 
>> 
>> 
>> Return to the homepage.
>> 
>> 
>>
>> {% else %}
>> 
>> 
>> Register here!
>> 
>> 
>> 
>> 
>> > 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> ]
>>
>>
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a324c1bc-4af3-478d-a290-b6cf0c4f5361%40googlegroups.com.
For more options, visit 

csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
Hey,

I recently started playing with my user registration and login and logout 
stuff for an app.  It worked fine before I moved it but now that it's moved 
I keep getting the following error:


Forbidden (403) 
>
> CSRF verification failed. Request aborted.
> Help 
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
> 
>
> In general, this can occur when there is a genuine Cross Site Request 
> Forgery, or when Django's CSRF mechanism 
>  has not been used 
> correctly. For POST forms, you need to ensure:
>
>- Your browser is accepting cookies.
>- The view function passes a request to the template's render 
>
> 
>  
>method.
>- In the template, there is a {% csrf_token %} template tag inside 
>each POST form that targets an internal URL.
>- If you are not using CsrfViewMiddleware, then you must use 
>csrf_protect on any views that use the csrf_token template tag, as 
>well as those that accept the POST data.
>- The form has a valid CSRF token. After logging in in another browser 
>tab or hitting the back button after a login, you may need to reload the 
>page with the form, because the token is rotated after a login.
>
> You're seeing the help section of this page because you have DEBUG = True 
> in your Django settings file. Change that to False, and only the initial 
> error message will be displayed. 
>
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>


The following are my codes.  If I'm missing any useful info just let me 
know and I'll add it in.

views.py 
def register(request):
# Boolean value.  Upon successful registration, registered will be 
changed to True
registered = False

user_form = UserForm(data=request.POST or None)
profile_form = UserProfileForm(data=request.POST or None)

if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
registered = True

return render(request, 'friends/register.html', {'user_form':user_form, 
'profile_form':profile_form, 'registered':registered})


register.html
{% extends 'hallo/base-k.html' %}
{% load staticfiles %}

{% block title_block %}
Register
{% endblock %}

{% block body_block %}



{% if registered %}


Thank you for registering!




Return to the homepage.



{% else %}


Register here!




https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User accessibility to multiple versions of an app.

2017-07-20 Thread pieceofkayk2718
Thanks James.  I'm working with Data Labels =].  Give me a minute to go 
over my project to see which of the two design patterns would best suit my 
needs.  I really appreciate the long and in-depth response.  Will get back 
to you after some analysis.

K

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/18d1f1f7-5d5b-41d8-8d72-45f89d796d9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


User accessibility to multiple versions of an app.

2017-07-20 Thread pieceofkayk2718
Hey, I've been running into issues trying to figure out how a user could be 
able to access multiple versions of an app.  Here is the following example:

I have an app named ANNA.  ANNA is used to build labels and these labels 
are dependent upon different standards that come out.  For example, we have 
standard 1700, standard 1800, standard 1900.  The DjangoProject website has 
a bottom corner button that allows you to go to different versions of the 
django docs.  I would like to implement that into ANNA, however I've come 
across a number of problems.  So ANNA has the following app structure:

my_project
 - ANNA
 - build(development)
 - search (development)

I have tried to implement this versioning by the following partition

*PARTITION 1*

my_project
- ANNA
- build   (development)
- search (development)
- build1700
- search1700
- build1800
- search1800
- build1900
- search1900

Unfortunately, the models used in all versions of build are the same across 
the board, and Django's reverse lookup for these models is giving me 
issues.  For instance if I have a label model in build, I will also have a 
label model in build1700, build1800, etc.  So I have to change the model 
names for each version, which means I have to change all of the business 
code to be version specific -- and I really do not want to do that since 
our label standards are also in development and change quite rapidly (like 
every four months right now).  The versions are also similar enough to 
where when a new one comes out, I would like to be able to pretty much copy 
and paste the last version's code into the new version's code and make my 
changes like so.

Has anyone ever had to do anything like this or have any ideas of how to go 
about it? 

Also, below is my current callback.


Unhandled exception in thread started by 
> Traceback (most recent call last):
>   File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", 
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/usr/lib64/python2.7/site-packages/django/core/management/commands/runserver.py",
>  
> line 125, in inner_run
> self.check(display_num_errors=True)
>   File 
> "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 
> 405, in check
> raise SystemCheckError(msg)
> django.core.management.base.SystemCheckError: SystemCheckError: System 
> check identified some issues:
>
> ERRORS:
> build1700.Bundle.user: (fields.E304) Reverse accessor for 'Bundle.user' 
> clashes with reverse accessor for 'Bundle.user'.
> HINT: Add or change a related_name argument to the definition for 
> 'Bundle.user' or 'Bundle.user'.
> build.Bundle.user: (fields.E304) Reverse accessor for 'Bundle.user' 
> clashes with reverse accessor for 'Bundle.user'.
> HINT: Add or change a related_name argument to the definition for 
> 'Bundle.user' or 'Bundle.user'.
>
>

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4ae70d15-12a3-44bd-9dfe-7666eab9e658%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database validation error - Even after manage.py flush.

2017-06-30 Thread pieceofkayk2718
Hey thanks for that extra input.  I'm currently a student at NMSU making an 
educational app for NASA'S Planetary Data Systems.  Right now I'm the only 
student working on it and the only person in my building that knows Django 
(which I'm learning on the job).  I'm making a blog alongside my app to 
supplement the Django tutorials and reading material we have for the 
following students we bring onto this project.  I've read through my books 
like 20 times already and since they're beginner level books there really 
isn't too much in depth material about migrations or databases in Django.  
So this post will definitely be pinned in our student blog.  You the man 
Guilherme!  

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f904720c-1ecf-45ae-abac-e7dc5da819d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database validation error - Even after manage.py flush.

2017-06-30 Thread pieceofkayk2718

Oh dude you are officially my hero!  I didn't even think about the 
migration files.  That totally worked.  And thank you thank you thank you 
=D <3.

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7ce3e4c-157a-48e1-9da1-d6e0bfb86715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database validation error - Even after manage.py flush.

2017-06-30 Thread pieceofkayk2718
I also did the "If all else fails, reboot your computer" and still have the 
same problem.  Haha.  I think I'm screwed.

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a50cc341-34d5-48e2-880a-f859689a76e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database validation error - Even after manage.py flush.

2017-06-30 Thread pieceofkayk2718
Yes.  At first I tried setting default=True or default=False for my 
BooleanField and kept getting the same error.  So I went back in, deleted 
the model, tried again, got the same error.  Then I deleted my db sqlite3 
file, made new migrations, migrated (with the model not even a part of my 
models.py anymore) and am still getting this error.  

On Friday, June 30, 2017 at 11:37:26 AM UTC-6, Guilherme Leal wrote:
>
> >>>django.core.exceptions.ValidationError: [u"'' value must be either 
> True or False."]
>
>
> Have you tried to set the default value of the BooleanField as True or 
> False? BooleanFields must have a valid boolean as default value and so 
> happends that empty string is not a valid boolean.
>
> Change the default value to False (as exemple), run the migration again, 
> and it should work.
>
>
>

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/07fe41c0-25f9-491a-8af8-b6b4c20c4a09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Database validation error - Even after manage.py flush.

2017-06-30 Thread pieceofkayk2718
So I made the ultimate error.  I put a BooleanField in my models.py, when I 
made migrations I set default col value to the empty string ''.. Then I 
migrated and got a validation error.  However, I have tried to delete the 
model containing BooleanField, delete my database file, and I even ran 
manage.py flush and cannot seem to get rid of this error.  If anyone has 
any experience with BooleanField errors please help.  My traceback from my 
terminal is below:

  Applying build_a_bundle.0012_auto_20170630_1027...Traceback (most recent 
call last):
  File "manage.py", line 22, in 
execute_from_command_line(sys.argv)
  File 
"/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", 
line 363, in execute_from_command_line
utility.execute()
  File 
"/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", 
line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", 
line 283, in run_from_argv
self.execute(*args, **cmd_options)
  File "/usr/lib64/python2.7/site-packages/django/core/management/base.py", 
line 330, in execute
output = self.handle(*args, **options)
  File 
"/usr/lib64/python2.7/site-packages/django/core/management/commands/migrate.py"
, line 204, in handle
fake_initial=fake_initial,
  File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py"
, line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
fake_initial=fake_initial)
  File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py"
, line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=
fake_initial)
  File "/usr/lib64/python2.7/site-packages/django/db/migrations/executor.py"
, line 244, in apply_migration
state = migration.apply(state, schema_editor)
  File 
"/usr/lib64/python2.7/site-packages/django/db/migrations/migration.py", 
line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)
  File 
"/usr/lib64/python2.7/site-packages/django/db/migrations/operations/fields.py"
, line 86, in database_forwards
field,
  File 
"/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", 
line 238, in add_field
self._remake_table(model, create_field=field)
  File 
"/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/schema.py", 
line 113, in _remake_table
self.effective_default(create_field)
  File 
"/usr/lib64/python2.7/site-packages/django/db/backends/base/schema.py", 
line 229, in effective_default
default = field.get_db_prep_save(default, self.connection)
  File 
"/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", 
line 766, in get_db_prep_save
prepared=False)
  File 
"/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", 
line 758, in get_db_prep_value
value = self.get_prep_value(value)
  File 
"/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", 
line 1039, in get_prep_value
return self.to_python(value)
  File 
"/usr/lib64/python2.7/site-packages/django/db/models/fields/__init__.py", 
line 1032, in to_python
params={'value': value},
django.core.exceptions.ValidationError: [u"'' value must be either True or 
False."]



-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc30ad69-a4b8-4163-8f7e-7a5d0d42fbd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Create media directory for each user upon user registration

2017-06-26 Thread pieceofkayk2718
Hey all,

I've been trying to figure out how to create a directory in my media 
directory for each user upon user registration.  I have found a lot of 
resources on how to upload files to a directory but just about none on 
simply how to create the directory.  I would like to be able to have my 
webapp create xml files for each user and then place them in the user's own 
directory.  The second part I am fine with.  Does anyone have any 
suggestions on how to go about adding a directory attribute to a 
UserProfile model?  I can't seem to get anything to work.

Here's some code.  Note that it does not have any directory information 
applied to the code (other than that little line in models.py) because I 
really have no idea how to go about this.

models.py
class UserProfile(models.Model):
user = models.OneToOneField(User)
directory = # something here to have an established user directory

views.py
def register(request):
# A boolean value for telling the template whether registration was 
successful.
# Initially set to False.  Code changes to True when registration 
succeeds.
registered = False


if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)

if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
registered = True
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=
password)
if user is not None:
login(request, user)
return HttpResponseRedirect(reverse('elsa:index'))
else:
return HttpResponse("Error in login after registration.")   
  
else:
# Invalid form or forms - mistakes made
print(user_form.errors, profile_form.errors)
else:
# Not an HTTP POST, so we render our form using two ModelForm 
instances.
# These forms will be blank and ready for user input.
user_form = UserForm()
profile_form = UserProfileForm()

# Render the template depending on the context.
return render(request, 'elsa/register.html', {'user_form': user_form,   
 
  'profile_form': 
profile_form,
  'registered': registered})

forms.py
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
#data_relation = forms.(max_length=8, default='provider', 
help_text='Choose provider or reviewer')
 
class Meta:
model = User
fields = ( 'username', 'email', 'password') #, 'data_relation')



class UserProfileForm(forms.ModelForm):

class Meta:
model = UserProfile
exclude = ('directory', )  # see note on models.py


-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ae06e7f-6c93-4e26-8138-4515788f3a6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModuleNot Found Error

2017-06-26 Thread pieceofkayk2718
Don't forget to add your app to the list of INSTALLED_APPS.  See below.

On Monday, June 26, 2017 at 4:09:00 AM UTC-6, akhil kumar wrote:
>
> this is my polls/urls.py
>
>
> from django.conf.urls import url
> from . import views
>
> urlpatterns=[
> url(r'^$',views.index,name='index'),
>]
>
>
>
> mysite/urls.py
>
>
> from django.conf.urls import include,url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^polls/',include('polls.urls',namespace="polls")),
> url(r'^admin/', admin.site.urls),
>]
>
>
>
> settings.py 
>
>
>
>
> INSTALLED_APPS = [
> 'polls.apps.PollsConfig'
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
>
>  *  'polls',* 

> ]
>
>
>
> models.py
>
>
> from django.db import models
>
> # Create your models here.
> class Question(models.Model):
> question_text=models.CharField(max_length=500)
> pub_date=models.DateTimeField('date published')
>
> class choice(models.Model):
> Question=models.ForeignKey(Question,on_delete=models.CASCADE)
> choice_text=models.CharField(max_length=500)
> votes=models.IntegerField(default=0)
>
>  

-- 
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@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98237392-07e9-4068-8044-14b4e117d053%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.