Re: i'm having issues displaying parent.model.childmodel_set.all on my template

2018-05-03 Thread stanley oguazu
Yes all the data in ScrumyUser table displays

-- 
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/7ff6bf1e-480a-4375-9802-ce5b45852a2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: serving admin files in Apache

2018-05-03 Thread sum abiut
Thanks,
i've try that but still doesn't solve the problem

On Fri, May 4, 2018 at 11:51 AM, James Farris 
wrote:

> Did you run
> $ python manage.py collectstatic in your project folder on the server that
> is running Apache?
>
> This add all css, js, and images to the static root folder you specified
> in settings.py
>
> On Thu, May 3, 2018 at 4:40 PM sum abiut  wrote:
>
>> Hi,
>> I have recently setup my django app with Apache. The app files are serve
>> alright but, however when i access the admin page it looks all over the
>> place. Please advise how to i serve the admin files in Apache.
>>
>> Cheers,
>>
>> --
>> 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/CAPCf-y5%2BVkkGo%2BDGHfX2o6Q54Gdfoo_
>> AxNvTcuZEkOziAH2V1A%40mail.gmail.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/CAE-E-_1AaYs5HYKxddZ1bf0YQ%3DbE4gvex2-ePSNB43SjNZtfmg%
> 40mail.gmail.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/CAPCf-y7gHpwnu246na8NWQF_8ZQ3T4yEKuMsbWs7XCiCMtigdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I use a variable from the instance of my data in the upload path for a FileField in my model?

2018-05-03 Thread Alexander Joseph
Thanks! Heres my method now, it works great...

def upload_path(instance, filename):
return os.path.join('uploads/' + 
datetime.datetime.now().strftime('%Y/%m/%d/') + instance.design_ui, 
filename)




On Thursday, May 3, 2018 at 6:59:17 PM UTC-6, James Farris wrote:
>
> I did something very similar in my models.py. I think for the date you 
> have to get the year, month with datetime.
>
> def get_upload_path(self, filename): return 
> 'pictures/{0}/{1}'.format(self.user.username, 
> filename) pet_image = models.ImageField(upload_to=get_upload_path, blank=
> True)
>
> On Thu, May 3, 2018 at 3:20 PM Alexander Joseph  > wrote:
>
>> Actually I figured this out... kind of
>>
>> You have to make a method for assigning the upload path in the model.. 
>> something like
>>
>> def upload_path(instance, filename):
>> return os.path.join('uploads/%Y/%m/%d/' + instance.design_ui, 
>> filename)
>>
>> and instance the method in your FileField...
>>
>> design_document = models.FileField(upload_to=upload_path, blank=True)
>>
>> but for some reason my %Y/%m/%d/  no longer works. If I take out the  
>> %Y/%m/%d/  it works but if I leave it in it throws an exception. Does 
>> anyone know why?
>>
>>
>>
>>
>> On Thursday, May 3, 2018 at 2:50:02 PM UTC-6, Alexander Joseph wrote:
>>>
>>> Not even sure if you can do it this way. I'm thinking theres another way 
>>> like overriding the save or the form_valid function in the view... but I'm 
>>> trying to use a variable from my instance in my upload path for my file 
>>> field. If I should do something like override the save method in the view 
>>> how do I save that in the "upload_to" in my model? 
>>>
>>> Here are my model fields
>>>
>>> design_ui = models.CharField(max_length=255, default='')
>>> design_document = models.FileField(upload_to='uploads/%Y/%m/%d/(Id like 
>>> to put the instance design_ui here)', blank=True)
>>>
>>>
>>> and my view
>>>
>>> class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
>>> fields = ("design_ui", "emitting", "contact_location", 
>>> "optical_power", "design_date", "designer", "design_document", 
>>> "designer_ui", "in_trash", "inactive_date", "notes")
>>> model = GaasWaferDesign
>>> template_name = 
>>> 'engineering/gaas_wafer_designs/gaas_wafer_design_form.html'
>>>
>>> def form_valid(self, form):
>>> object = form.save(commit=False)
>>> object.created_by = self.request.user
>>> object.save()
>>> return super(GaasWaferDesignCreateView, self).form_valid(form)
>>>
>>> i.e. if the design_ui of the specific record is GWD0001 and the date is 
>>> 5/3/18 the upload path would be "2018/05/03/GWD0001/"
>>>
>>>
>>> Thanks again
>>>
>> -- 
>> 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/8173dbcc-8870-44d1-9796-e22b465144e1%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/f11cca2a-d80a-445c-bd2d-446da0a23438%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread James Farris
In looks like there is a syntax error also in your polls/urls.py
Your missing the opening <
This:
path(‘int:question_id>/vote/', views.vote, name='vote'),

Should be this:
path('/vote/', views.vote, name='vote'),

On Thu, May 3, 2018 at 10:12 AM Avitab Ayan Sarmah 
wrote:

> thank you Anthony, now i will try your code and i am sure it will run this
> time
>
> On Thu, May 3, 2018 at 10:37 PM, 'Anthony Flury' via Django users <
> django-users@googlegroups.com> wrote:
>
>> I think the root cause of the errors was due to an incorrect settings -
>> but Fidel is right that your views.py wasn't great either.
>>
>> On 03/05/18 17:36, Avitab Ayan Sarmah wrote:
>>
>>> thank you Fidel, and i will take care of it
>>>
>>> On Thu, May 3, 2018 at 9:57 PM, Fidel Leon > fi...@flm.cat>> wrote:
>>>
>>> Sure:
>>>
>>> from django.http import HttpResponse
>>>
>>> from .models import Question
>>>
>>>
>>> def index(request):
>>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>>> output = ', '.join([q.question_text for q in
>>> latest_question_list])
>>> return HttpResponse(output)
>>>
>>> def detail(request, question_id):
>>> return HttpResponse("You're looking at question %s." % question_id)
>>>
>>> def results(request, question_id):
>>> response = "You're looking at the results of question %s."
>>> return HttpResponse(response % question_id)
>>>
>>> def vote(request, question_id):
>>> return HttpResponse("You're voting on question %s." % question_id)
>>>
>>> As a matter of advice, please use a fixed-width font when pasting
>>> code, because Python is indented with spaces and using any other
>>> type of font makes reading your mail difficult :)
>>>
>>> El jue., 3 may. 2018 a las 18:08, Avitab Ayan Sarmah
>>> (>) escribió:
>>>
>>> hello Fidel Leon can you please rewrite the whole views.py
>>> code so that i can understand what is the exact code is
>>>
>>> On Thu, May 3, 2018 at 9:19 PM, Fidel Leon >> > wrote:
>>>
>>>
>>>
>>> El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah
>>> (>)
>>> escribió:
>>>
>>>
>>> *polls/views.py*:
>>>
>>>
>>> from django.http import HttpResponse
>>> from django.template import loader
>>>
>>> from . models import Question
>>>
>>> def index(request):
>>> return HttpResponse("Hello, world.You're at the polls
>>> index.")
>>> latest_question_list =
>>> Question.objects.order_by('-pub_date')[:5]
>>> output = ', '.join([q.question_text for q in
>>> latest_question_list])
>>> return HttpResponse(output)
>>> latest_question_list =
>>> Question.objects.order_by('-pub_date')[:5]
>>> template = loader.get_template('polls/index.html')
>>> context = {
>>> 'latest_question_list': latest_question_list,
>>> }
>>> return HttpResponse(template.render(context, request))
>>>
>>>
>>> Your function index(request) inside polls/views.py is
>>> badly written (you have three function returns). Seems you
>>> are following the tutorial but not removing the previous
>>> examples:
>>>
>>> def index(request):
>>>   latest_question_list =
>>> Question.objects.order_by('-pub_date')[:5]
>>>   context = {'latest_question_list': latest_question_list}
>>>   return render(request, 'polls/index.html', context)
>>>
>>> -- Fidel Leon
>>> fi...@flm.cat 
>>>
>>> -- You received this message because you are
>>> subscribed to a
>>> topic in the Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit
>>>
>>> https://groups.google.com/d/topic/django-users/5hvN4Lfds-w/unsubscribe
>>> <
>>> https://groups.google.com/d/topic/django-users/5hvN4Lfds-w/unsubscribe>.
>>> To unsubscribe from this group and all its topics, 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
>>>
>>> 

Re: How can I use a variable from the instance of my data in the upload path for a FileField in my model?

2018-05-03 Thread James Farris
I did something very similar in my models.py. I think for the date you have
to get the year, month with datetime.

def get_upload_path(self, filename): return
'pictures/{0}/{1}'.format(self.user.username,
filename) pet_image = models.ImageField(upload_to=get_upload_path, blank=
True)

On Thu, May 3, 2018 at 3:20 PM Alexander Joseph <
alexander.v.jos...@gmail.com> wrote:

> Actually I figured this out... kind of
>
> You have to make a method for assigning the upload path in the model..
> something like
>
> def upload_path(instance, filename):
> return os.path.join('uploads/%Y/%m/%d/' + instance.design_ui, filename)
>
> and instance the method in your FileField...
>
> design_document = models.FileField(upload_to=upload_path, blank=True)
>
> but for some reason my %Y/%m/%d/  no longer works. If I take out the
> %Y/%m/%d/  it works but if I leave it in it throws an exception. Does
> anyone know why?
>
>
>
>
> On Thursday, May 3, 2018 at 2:50:02 PM UTC-6, Alexander Joseph wrote:
>>
>> Not even sure if you can do it this way. I'm thinking theres another way
>> like overriding the save or the form_valid function in the view... but I'm
>> trying to use a variable from my instance in my upload path for my file
>> field. If I should do something like override the save method in the view
>> how do I save that in the "upload_to" in my model?
>>
>> Here are my model fields
>>
>> design_ui = models.CharField(max_length=255, default='')
>> design_document = models.FileField(upload_to='uploads/%Y/%m/%d/(Id like
>> to put the instance design_ui here)', blank=True)
>>
>>
>> and my view
>>
>> class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
>> fields = ("design_ui", "emitting", "contact_location",
>> "optical_power", "design_date", "designer", "design_document",
>> "designer_ui", "in_trash", "inactive_date", "notes")
>> model = GaasWaferDesign
>> template_name =
>> 'engineering/gaas_wafer_designs/gaas_wafer_design_form.html'
>>
>> def form_valid(self, form):
>> object = form.save(commit=False)
>> object.created_by = self.request.user
>> object.save()
>> return super(GaasWaferDesignCreateView, self).form_valid(form)
>>
>> i.e. if the design_ui of the specific record is GWD0001 and the date is
>> 5/3/18 the upload path would be "2018/05/03/GWD0001/"
>>
>>
>> Thanks again
>>
> --
> 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/8173dbcc-8870-44d1-9796-e22b465144e1%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/CAE-E-_1j%3DRszvw9T09egv9KnzWmjJRsyPYSUWm8fubOkm3wuWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: serving admin files in Apache

2018-05-03 Thread James Farris
Did you run
$ python manage.py collectstatic in your project folder on the server that
is running Apache?

This add all css, js, and images to the static root folder you specified in
settings.py

On Thu, May 3, 2018 at 4:40 PM sum abiut  wrote:

> Hi,
> I have recently setup my django app with Apache. The app files are serve
> alright but, however when i access the admin page it looks all over the
> place. Please advise how to i serve the admin files in Apache.
>
> Cheers,
>
> --
> 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/CAPCf-y5%2BVkkGo%2BDGHfX2o6Q54Gdfoo_AxNvTcuZEkOziAH2V1A%40mail.gmail.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/CAE-E-_1AaYs5HYKxddZ1bf0YQ%3DbE4gvex2-ePSNB43SjNZtfmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: i'm having issues displaying parent.model.childmodel_set.all on my template

2018-05-03 Thread James Farris
If you add {{ my_users }} to your template do you get any output? If not,
you’re query set has no results.

On Thu, May 3, 2018 at 4:51 PM stanley oguazu  wrote:

> //My template is only displaying the parent table, and not displaying
> child table
>
>  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/02500f66-1283-49a9-b4c3-4fe723a497d0%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/CAE-E-_0PmeXwuGgAGBT6m5KqeMahSvPyu%2BCajkL_8wAeAQM4Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Upgrading from 1.11 to 2.0: "sqlite3.OperationalError: no such table"

2018-05-03 Thread Michael Gauland
I've got a project that's been developed using django 1.11. I've tried 
upgrading to 2.0, but now I'm getting an error I haven't been able to track 
down.

My database engine is sqlite3. I have three database files:
  - db.sqlite3 is the default. This is the only one that django manages, 
and the only one that is writable.
  - components.sqlite3 contains a library of engineering component data. 
  - slat_constants.sqlite3 contains constants used by the project. In 
particular, the 'slat_locations' table holds information about sites in NZ.

I have a Model that exposes the location data:
class Location(models.Model):
location = models.CharField(max_length=128)
z = models.FloatField()
min_distance = models.FloatField(null = True)
max_disstance = models.FloatField(null = True)

class Meta:
managed = False
db_table = 'slat_location'

and another that uses it:
class NZ_Standard_Curve(models.Model):
SOIL_CLASS_A = 'A'
SOIL_CLASS_B = 'B'
SOIL_CLASS_C = 'C'
SOIL_CLASS_D = 'D'
SOIL_CLASS_E = 'E'
SOIL_CLASS_CHOICES = (
(SOIL_CLASS_A, 'A'),
(SOIL_CLASS_B, 'B'),
(SOIL_CLASS_C, 'C'),
(SOIL_CLASS_D, 'D'),
(SOIL_CLASS_E, 'E')
)

soil_class = models.CharField(max_length=1,
  choices=SOIL_CLASS_CHOICES,
  default=SOIL_CLASS_A)
period = models.FloatField(default=1.5)
location = models.ForeignKey(Location, on_delete=PROTECT, 
null=False)

...and a test script that creates an NZ_Standard_Curve, and tries to save 
it:

location = Location.objects.get(location='Christchurch')
curve = NZ_Standard_Curve(location=location, 
   soil_class='C',
   period=1.5)
curve.save()

If I don't try to save the curve, the test passes. The save() call fails 
with:

sqlite3.OperationalError: no such table: main.slat_location

Again, this all works with django 1.11.13. I've tried creating a fresh 
database, and making new migrations, but that hasn't helped. 

I've wondered if the leading 'main.' in the table name is a clue, but that 
hasn't led me anywhere yet.

Any suggestions? 

Kind Regards,
Michael Gauland

-- 
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/7f89596e-c7f0-44ff-a13f-a5779701a80a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: OperationalError

2018-05-03 Thread Gerald Brown

Thanks for the reply.  Will check it out.  Just printed the documentation.


On Friday, 04 May, 2018 03:08 AM, 'Anthony Flury' via Django users wrote:

Django 2.0 docs suggest using reportlab :

https://docs.djangoproject.com/en/2.0/howto/outputting-pdf/

I had some success with : pupeteer - 
http://django-puppeteer-pdf.readthedocs.io/en/latest/ - which works by 
having a CBV type framework - so you subclass a PDF template view - 
and that will autogenerate a PDF for you - you just need to have 
unique urls for the PDFs.




On 03/05/18 13:22, Gerald Brown wrote:


FINALLY. SUCCESS!!! What I ended up doing to correct the problem was 
to drop the whole database (NO RECORDS YET). When I tried to run 
migrations it said there were no changes.  I then had to run 
makemigrations  and migrate  so I am now back 
in business!!!


Now does anyone know of an *easy* way to create PDF documents in 
Django???


Thanks to all for the suggestions and ideas!!!

On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:

    I finally discovered what I think is the cause of my problem.
    *DJANGO MIGRATIONS ARE NOT WORKING.*On the system that has the
    problem is where I made migration to change some of the field
    names.  The fields that were not found where the ones that did get
    changed but the old unchanged names were still there.  On another
    system that is working NONE of the fields names were changed so it
    didn't have any unknown fields. Both systems had migrations run
    against the model file where some fields had changes made and the
    other one NO changes were made and on a third machine all changes
    were made.

    /Who knows what evil lurks in the heart of the computer? *The
    Shadow knows!!!* /


    On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:

    I have a Django application that I am having problems with.  In
    the Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1
    option to "Add/Change".  In 2 of them when I click on the option
    it works fine. The third gives me the following error "
    *1054, "Unknown column 'xyz_xyz.first_name' in "field list" *The
    Exception location is:
*/home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/*MySQLdb*/connections.py
    in query, line 277* On another system (both running the same
    code) I was also getting a different error also in
    *site-packages/MySQLdb* but I was able correct that by installing
    2 DEV packages and then  installing MySQLClient, which I also 
did on this computer.  The other

    system does NOT give this error.

    Any ideas, suggestions, solutions on how to solve this error and 
any other errors in the Django code?


    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@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/74790172-8bf5-43b6-9bad-bab68ae11a4a%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/e17d8d56-d57c-4f3d-ae6f-a004a5beda70%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/1b0f87d9-620e-3b4e-f848-538a665276cc%40gmail.com.
For more options, visit 

i'm having issues displaying parent.model.childmodel_set.all on my template

2018-05-03 Thread stanley oguazu
//My template is only displaying the parent table, and not displaying child 
table


serving admin files in Apache

2018-05-03 Thread sum abiut
Hi,
I have recently setup my django app with Apache. The app files are serve
alright but, however when i access the admin page it looks all over the
place. Please advise how to i serve the admin files in Apache.

Cheers,

-- 
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/CAPCf-y5%2BVkkGo%2BDGHfX2o6Q54Gdfoo_AxNvTcuZEkOziAH2V1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nullable vs empty strings

2018-05-03 Thread George Lubaretsi
Short answer: because you'll know when you need it. And unless that's the
case - there's no good reason to do it.

Long answer:

Because there's really no reason to do it except for when you have unique
constraint on that column. It's just a convention. When you have a
`CharField`, you expect returned type to be a string and do string
operations on it. But then you allow null values and suddenly you get
NoneType instead of string. This convention just means that you don't need
it, so don't use it.

The only time where you need nullable text columns, is when you need to
allow for empty values (or unknown values) in the DB, but also need to have
a unique constraint on that column.

Imagine where you have a model that stores phone number in a text field.
That field is not required, so it can be empty, but at the same time, if
it's provided, it must be unique. That's the only time where you need to
set `null=True`, because every `null` has unique, distinct value in DB
(empty string does not). So you'll make that column not required, but at
the same time, enforce uniqueness. And because you know that this field is
optional and may be missing, you'll be explicitly checking for `None`
values before you do any string operations on it. But if you don't need
phone numbers to be unique, you'll be checking for `None` values
explicitly, when simply an empty string will be enough.

On Thu, May 3, 2018 at 11:37 PM Nick Sarbicki 
wrote:

> Thanks for the replies both.
>
> I know the difference between a NULL value and an empty string :-D. My
> question was more why Django recommends _never_ using null=True on
> CharFields.
>
> From both replies it sounds like neither of you agree with this
> guideline...
>
> On Thursday, May 3, 2018 at 2:18:32 PM UTC+1, Jani Tiainen wrote:
>
>> And then you find out that Oracle implicitly converts empty strings to
>> NULLs which causes all kind of hassle. :)
>>
>> On Thu, May 3, 2018 at 3:39 PM, Ken Whitesell 
>> wrote:
>>
> Nick,
>>>
>>>  A null string (string with length 0) is _not_ the same as a null
>>> field (no string). The two are distinct, and (can) serve two very different
>>> functions.
>>>
>>> Take a look at this for some more detailed information:
>>> https://softwareengineering.stackexchange.com/questions/32578/sql-empty-string-vs-null-value
>>>
>>> Ken
>>>
>>>
>>> On Thursday, May 3, 2018 at 5:17:35 AM UTC-4, Nick Sarbicki wrote:

 I just saw this in the docs:
 https://docs.djangoproject.com/en/2.0/ref/models/fields/#null

 Suggesting that you should never set a CharField to null unless using a
 unique index.

 Is this generally accepted? Historically I've always nulled a CharField
 because using empty strings, as opposed to letting a column be nullable,
 has felt very dirty to me.

 I would have expected (not suggesting this as a change) an empty string
 to fail if the field isn't nullable.

 Am I on my own here?

>>> --
>>> 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/23e3a4dc-345a-4fb9-8122-0dba7b99bb4d%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
> --
> 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/c445d4ab-abf6-4cd6-9123-f9f2d0d8900d%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 

Re: How can I use a variable from the instance of my data in the upload path for a FileField in my model?

2018-05-03 Thread Alexander Joseph
Actually I figured this out... kind of

You have to make a method for assigning the upload path in the model.. 
something like

def upload_path(instance, filename):
return os.path.join('uploads/%Y/%m/%d/' + instance.design_ui, filename)

and instance the method in your FileField...

design_document = models.FileField(upload_to=upload_path, blank=True)

but for some reason my %Y/%m/%d/  no longer works. If I take out the  
%Y/%m/%d/  it works but if I leave it in it throws an exception. Does 
anyone know why?




On Thursday, May 3, 2018 at 2:50:02 PM UTC-6, Alexander Joseph wrote:
>
> Not even sure if you can do it this way. I'm thinking theres another way 
> like overriding the save or the form_valid function in the view... but I'm 
> trying to use a variable from my instance in my upload path for my file 
> field. If I should do something like override the save method in the view 
> how do I save that in the "upload_to" in my model? 
>
> Here are my model fields
>
> design_ui = models.CharField(max_length=255, default='')
> design_document = models.FileField(upload_to='uploads/%Y/%m/%d/(Id like 
> to put the instance design_ui here)', blank=True)
>
>
> and my view
>
> class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
> fields = ("design_ui", "emitting", "contact_location", 
> "optical_power", "design_date", "designer", "design_document", 
> "designer_ui", "in_trash", "inactive_date", "notes")
> model = GaasWaferDesign
> template_name = 
> 'engineering/gaas_wafer_designs/gaas_wafer_design_form.html'
>
> def form_valid(self, form):
> object = form.save(commit=False)
> object.created_by = self.request.user
> object.save()
> return super(GaasWaferDesignCreateView, self).form_valid(form)
>
> i.e. if the design_ui of the specific record is GWD0001 and the date is 
> 5/3/18 the upload path would be "2018/05/03/GWD0001/"
>
>
> Thanks again
>

-- 
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/8173dbcc-8870-44d1-9796-e22b465144e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin site and ModelAdmin

2018-05-03 Thread jt . oldnews
Thanks for the response Mike.

I generally don't like it when a design has to change to fit a framework, 
however, in this case I decided to try your solution. I ran into a couple 
of problems though :-(
 1) The fields that I'm looking up were required fields. Validation failed 
and error messages were displayed until I changed my model to not require 
those fields (which creates other problems I'd need to fix). Is there a way 
to hook in before validation? I over-road the model save function. Would 
the pre-save signal method fix this problem? Or maybe ModelAdmin.save_model?
 2) The desired result of the lookup would be to display the change form so 
that the information could be verified. In other words, if doing the 
lookup, 'SAVE' (and 'Save and add another') should behave as if 'Save and 
continue editing' had been selected.


-- 
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/26f88b4c-b2dd-4bce-aea7-d885295aa609%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I use a variable from the instance of my data in the upload path for a FileField in my model?

2018-05-03 Thread Alexander Joseph
Not even sure if you can do it this way. I'm thinking theres another way 
like overriding the save or the form_valid function in the view... but I'm 
trying to use a variable from my instance in my upload path for my file 
field. If I should do something like override the save method in the view 
how do I save that in the "upload_to" in my model? 

Here are my model fields

design_ui = models.CharField(max_length=255, default='')
design_document = models.FileField(upload_to='uploads/%Y/%m/%d/(Id like to 
put the instance design_ui here)', blank=True)


and my view

class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
fields = ("design_ui", "emitting", "contact_location", "optical_power", 
"design_date", "designer", "design_document", "designer_ui", "in_trash", 
"inactive_date", "notes")
model = GaasWaferDesign
template_name = 
'engineering/gaas_wafer_designs/gaas_wafer_design_form.html'

def form_valid(self, form):
object = form.save(commit=False)
object.created_by = self.request.user
object.save()
return super(GaasWaferDesignCreateView, self).form_valid(form)

i.e. if the design_ui of the specific record is GWD0001 and the date is 
5/3/18 the upload path would be "2018/05/03/GWD0001/"


Thanks again

-- 
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/d436a98f-19ec-4c15-a504-688cb49923a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upload of file with FileField working in admin but not in template

2018-05-03 Thread Alexander Joseph
That was it, thank you!

On Thu, May 3, 2018 at 12:35 PM, Andréas Kühne 
wrote:

> Hi,
>
> The problem isn't CBV's, it's probably your template.
>
> You have the following:
>  
>
> But it should be:
>  
>
> Otherwise the browser doesn't know how to encode the files
>
> Regards,
>
> Andréas
>
> 2018-05-03 18:44 GMT+02:00 Alexander Joseph 
> :
>
>> I'm using CBVs and trying to upload a file with a FileField. It seems to
>> work in admin but not in my template. It doesnt give any errors when
>> creating the record and it saves the rest of the data in the form, but it
>> doesnt save the attachment
>>
>> Heres my model
>>
>> class LaserMaskDesign(models.Model):
>> laser_mask_design_ui = models.CharField(max_length=60, unique=True)
>> # Wafer Design UI
>> mask_layers = models.CharField(max_length=255, default='',
>> blank=True, null=True)
>> design_date = models.DateTimeField(blank=True, null=True)
>> designer = models.CharField(max_length=255, default='', blank=True,
>> null=True)
>> pcm = models.CharField(max_length=255, default='', blank=True,
>> null=True)
>> critical_dimensions = models.DecimalField(max_digits=20,
>> decimal_places=4, default=0., blank=True, null=True)
>> dimensions = models.CharField(max_length=255, default='')
>> thickness = models.DecimalField(max_digits=20, decimal_places=4,
>> default=0., blank=True, null=True)
>> material = models.CharField(max_length=255, default='', blank=True,
>> null=True)
>> number_of_products = models.IntegerField(default=0, blank=True,
>> null=True)
>> chip_list = models.CharField(max_length=255, default='', blank=True,
>> null=True)
>> design_document = models.FileField(blank=True, null=True)
>> notes = models.TextField(blank=True, null=True, default='')
>> created_at = models.DateTimeField(auto_now_add=True)
>> created_by = models.ForeignKey(settings.AUTH_USER_MODEL)
>> in_trash = models.BooleanField(default=False)
>> inactive_date = models.DateTimeField(blank=True, null=True)
>>
>> class Meta:
>> ordering = ['laser_mask_design_ui', ]
>>
>> def __str__(self):
>> return self.laser_mask_design_ui
>>
>> def get_absolute_url(self):
>> return reverse("engineering:laser_mask_design_detail",
>> kwargs={"pk": self.pk})
>>
>>
>>
>> and my view
>>
>> class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
>> fields = ("design_ui", "emitting", "contact_location",
>> "optical_power", "design_date", "designer", "design_document",
>> "designer_ui", "in_trash", "inactive_date", "notes")
>> model = GaasWaferDesign
>> template_name = 'engineering/gaas_wafer_design
>> s/gaas_wafer_design_form.html'
>>
>> def form_valid(self, form):
>> object = form.save(commit=False)
>> object.created_by = self.request.user
>> object.save()
>> return super(GaasWaferDesignCreateView, self).form_valid(form)
>>
>>
>> and my template
>>
>> {% extends "pages/layout.html" %}
>> {% load static from staticfiles %}
>> {% load widget_tweaks %}
>> {% block title %}{% if not form.instance.pk %}Add GaAs Wafer Design{%
>> else %}Edit GaAs Wafer Design - {{ gaaswaferdesign.design_ui }}{{
>> form.instance.gaas_wafer_design.design_ui }}{% endif %}{% endblock %}
>> {% load django_bootstrap_breadcrumbs %}
>>
>> {% block breadcrumb %}
>>   {% block breadcrumbs %}
>>   {{ block.super }}
>>   {% endblock %}
>> {% endblock %}
>>
>> {% block content %}
>> 
>>   
>>   {% if not form.instance.pk %}Add GaAs Wafer
>> Design{% else %}Edit GaAs Wafer Design{% endif %}
>>   
>> 
>> 
>> 
>> 
>>   
>>   {% csrf_token %}
>>   
>>   GaAs Wafer Design
>>   Form
>>   
>>   
>> Bold are required *
>> {{ form.non_field_errors }}
>> 
>>   
>> 
>>   GaAs
>> Wafer Design UI
>>   {% render_field form.design_ui class+="form-control" %}
>>   {{ form.design_ui.errors }}
>> 
>>   
>> 
>> 
>> 
>>   
>> 
>>   Emitter Type
>>   {% render_field form.emitting class+="form-control" %}
>>   {{ form.emitting.errors }}
>> 
>>   
>>   
>> 
>>   Contact Location
>>   {% render_field form.contact_location
>> class+="form-control" %}
>>   {{ form.contact_location.errors }}
>> 
>>   
>>   
>> 
>>   Optical Power
>>   {% render_field form.optical_power
>> class+="form-control" %}
>>   {{ form.optical_power.errors }}
>> 
>>   
>> 
>> 
>>  

Re: Nullable vs empty strings

2018-05-03 Thread Nick Sarbicki
Thanks for the replies both.

I know the difference between a NULL value and an empty string :-D. My 
question was more why Django recommends _never_ using null=True on 
CharFields.

>From both replies it sounds like neither of you agree with this guideline...

On Thursday, May 3, 2018 at 2:18:32 PM UTC+1, Jani Tiainen wrote:
>
> And then you find out that Oracle implicitly converts empty strings to 
> NULLs which causes all kind of hassle. :)
>
>
> On Thu, May 3, 2018 at 3:39 PM, Ken Whitesell  > wrote:
>
>> Nick,
>>
>>  A null string (string with length 0) is _not_ the same as a null 
>> field (no string). The two are distinct, and (can) serve two very different 
>> functions. 
>>
>> Take a look at this for some more detailed information: 
>> https://softwareengineering.stackexchange.com/questions/32578/sql-empty-string-vs-null-value
>>
>> Ken
>>
>>
>> On Thursday, May 3, 2018 at 5:17:35 AM UTC-4, Nick Sarbicki wrote:
>>>
>>> I just saw this in the docs: 
>>> https://docs.djangoproject.com/en/2.0/ref/models/fields/#null
>>>
>>> Suggesting that you should never set a CharField to null unless using a 
>>> unique index.
>>>
>>> Is this generally accepted? Historically I've always nulled a CharField 
>>> because using empty strings, as opposed to letting a column be nullable, 
>>> has felt very dirty to me.
>>>
>>> I would have expected (not suggesting this as a change) an empty string 
>>> to fail if the field isn't nullable.
>>>
>>> Am I on my own here?
>>>
>> -- 
>> 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/23e3a4dc-345a-4fb9-8122-0dba7b99bb4d%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>

-- 
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/c445d4ab-abf6-4cd6-9123-f9f2d0d8900d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Djangocon Europe plans?

2018-05-03 Thread Jani Tiainen
Hi.

I'm staying in Holiday Inn at city centre. Not sure is it any closer than
confrence hotels.

I got my room reserved at the beginning of March though.

to 3. toukokuuta 2018 klo 19.59 C. Kirby  kirjoitti:

> Who is going? where are you staying? etc
>
> I'll be flying in on Tuesday from DC.
> I'm in for the conference but not the sprints. Will be giving a talk at
> the end of the first day.
>
> I haven't booked my hotel yet. I usually like staying closer to the venue
> so I can walk and not deal with public transport first thing in the
> morning. Anyone staying closer to the Stadthalle Heidelberg than the
> conference hotels?
>
> Chaim
>
> --
> 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/f3cb3125-4307-4b52-8e5a-39a26c7bba82%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/CAHn91oeKnAf-RZW0a39EqEix_%3D6FHwN19g8GB7AcpZPB-zYG9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: OperationalError

2018-05-03 Thread 'Anthony Flury' via Django users

Django 2.0 docs suggest using reportlab :

https://docs.djangoproject.com/en/2.0/howto/outputting-pdf/

I had some success with : pupeteer - 
http://django-puppeteer-pdf.readthedocs.io/en/latest/ - which works by 
having a CBV type framework - so you subclass a PDF template view - and 
that will autogenerate a PDF for you - you just need to have unique urls 
for the PDFs.




On 03/05/18 13:22, Gerald Brown wrote:


FINALLY. SUCCESS!!! What I ended up doing to correct the problem was 
to drop the whole database (NO RECORDS YET). When I tried to run 
migrations it said there were no changes.  I then had to run 
makemigrations  and migrate  so I am now back 
in business!!!


Now does anyone know of an *easy* way to create PDF documents in Django???

Thanks to all for the suggestions and ideas!!!

On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:

I finally discovered what I think is the cause of my problem.
*DJANGO MIGRATIONS ARE NOT WORKING.*On the system that has the
problem is where I made migration to change some of the field
names.  The fields that were not found where the ones that did get
changed but the old unchanged names were still there.  On another
system that is working NONE of the fields names were changed so it
didn't have any unknown fields. Both systems had migrations run
against the model file where some fields had changes made and the
other one NO changes were made and on a third machine all changes
were made.

/Who knows what evil lurks in the heart of the computer? *The
Shadow knows!!!* /


On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:

I have a Django application that I am having problems with.  In
the Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1
option to "Add/Change".  In 2 of them when I click on the option
it works fine. The third gives me the following error "
*1054, "Unknown column 'xyz_xyz.first_name' in "field list" *The
Exception location is:

*/home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/*MySQLdb*/connections.py
in query, line 277* On another system (both running the same
code) I was also getting a different error also in
*site-packages/MySQLdb* but I was able correct that by installing
2 DEV packages and then  installing MySQLClient, which I also did on this 
computer.  The other
system does NOT give this error.

Any ideas, suggestions, solutions on how to solve this error and any other 
errors in the Django code?

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@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/74790172-8bf5-43b6-9bad-bab68ae11a4a%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/e17d8d56-d57c-4f3d-ae6f-a004a5beda70%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.



--
--
Anthony Flury
email : *anthony.fl...@btinternet.com*
Twitter : *@TonyFlury *

--
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/ce2f9885-bb30-3386-0411-b4b022cafca2%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upload of file with FileField working in admin but not in template

2018-05-03 Thread Andréas Kühne
Hi,

The problem isn't CBV's, it's probably your template.

You have the following:
 

But it should be:
 

Otherwise the browser doesn't know how to encode the files

Regards,

Andréas

2018-05-03 18:44 GMT+02:00 Alexander Joseph :

> I'm using CBVs and trying to upload a file with a FileField. It seems to
> work in admin but not in my template. It doesnt give any errors when
> creating the record and it saves the rest of the data in the form, but it
> doesnt save the attachment
>
> Heres my model
>
> class LaserMaskDesign(models.Model):
> laser_mask_design_ui = models.CharField(max_length=60, unique=True) #
> Wafer Design UI
> mask_layers = models.CharField(max_length=255, default='',
> blank=True, null=True)
> design_date = models.DateTimeField(blank=True, null=True)
> designer = models.CharField(max_length=255, default='', blank=True,
> null=True)
> pcm = models.CharField(max_length=255, default='', blank=True,
> null=True)
> critical_dimensions = models.DecimalField(max_digits=20,
> decimal_places=4, default=0., blank=True, null=True)
> dimensions = models.CharField(max_length=255, default='')
> thickness = models.DecimalField(max_digits=20, decimal_places=4,
> default=0., blank=True, null=True)
> material = models.CharField(max_length=255, default='', blank=True,
> null=True)
> number_of_products = models.IntegerField(default=0, blank=True,
> null=True)
> chip_list = models.CharField(max_length=255, default='', blank=True,
> null=True)
> design_document = models.FileField(blank=True, null=True)
> notes = models.TextField(blank=True, null=True, default='')
> created_at = models.DateTimeField(auto_now_add=True)
> created_by = models.ForeignKey(settings.AUTH_USER_MODEL)
> in_trash = models.BooleanField(default=False)
> inactive_date = models.DateTimeField(blank=True, null=True)
>
> class Meta:
> ordering = ['laser_mask_design_ui', ]
>
> def __str__(self):
> return self.laser_mask_design_ui
>
> def get_absolute_url(self):
> return reverse("engineering:laser_mask_design_detail",
> kwargs={"pk": self.pk})
>
>
>
> and my view
>
> class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
> fields = ("design_ui", "emitting", "contact_location",
> "optical_power", "design_date", "designer", "design_document",
> "designer_ui", "in_trash", "inactive_date", "notes")
> model = GaasWaferDesign
> template_name = 'engineering/gaas_wafer_designs/gaas_wafer_design_
> form.html'
>
> def form_valid(self, form):
> object = form.save(commit=False)
> object.created_by = self.request.user
> object.save()
> return super(GaasWaferDesignCreateView, self).form_valid(form)
>
>
> and my template
>
> {% extends "pages/layout.html" %}
> {% load static from staticfiles %}
> {% load widget_tweaks %}
> {% block title %}{% if not form.instance.pk %}Add GaAs Wafer Design{%
> else %}Edit GaAs Wafer Design - {{ gaaswaferdesign.design_ui }}{{
> form.instance.gaas_wafer_design.design_ui }}{% endif %}{% endblock %}
> {% load django_bootstrap_breadcrumbs %}
>
> {% block breadcrumb %}
>   {% block breadcrumbs %}
>   {{ block.super }}
>   {% endblock %}
> {% endblock %}
>
> {% block content %}
> 
>   
>   {% if not form.instance.pk %}Add GaAs Wafer
> Design{% else %}Edit GaAs Wafer Design{% endif %}
>   
> 
> 
> 
> 
>   
>   {% csrf_token %}
>   
>   GaAs Wafer Design
>   Form
>   
>   
> Bold are required *
> {{ form.non_field_errors }}
> 
>   
> 
>   GaAs
> Wafer Design UI
>   {% render_field form.design_ui class+="form-control" %}
>   {{ form.design_ui.errors }}
> 
>   
> 
> 
> 
>   
> 
>   Emitter
> Type
>   {% render_field form.emitting class+="form-control" %}
>   {{ form.emitting.errors }}
> 
>   
>   
> 
>   Contact Location
>   {% render_field form.contact_location
> class+="form-control" %}
>   {{ form.contact_location.errors }}
> 
>   
>   
> 
>   Optical Power
>   {% render_field form.optical_power class+="form-control"
> %}
>   {{ form.optical_power.errors }}
> 
>   
> 
> 
> 
>   
> 
>   Design Date
>   {% render_field form.design_date class+="form-control" %}
>   {{ form.design_date.errors }}
> 
>   
>   
> 

Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread Avitab Ayan Sarmah
thank you Anthony, now i will try your code and i am sure it will run this
time

On Thu, May 3, 2018 at 10:37 PM, 'Anthony Flury' via Django users <
django-users@googlegroups.com> wrote:

> I think the root cause of the errors was due to an incorrect settings -
> but Fidel is right that your views.py wasn't great either.
>
> On 03/05/18 17:36, Avitab Ayan Sarmah wrote:
>
>> thank you Fidel, and i will take care of it
>>
>> On Thu, May 3, 2018 at 9:57 PM, Fidel Leon  fi...@flm.cat>> wrote:
>>
>> Sure:
>>
>> from django.http import HttpResponse
>>
>> from .models import Question
>>
>>
>> def index(request):
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> output = ', '.join([q.question_text for q in
>> latest_question_list])
>> return HttpResponse(output)
>>
>> def detail(request, question_id):
>> return HttpResponse("You're looking at question %s." % question_id)
>>
>> def results(request, question_id):
>> response = "You're looking at the results of question %s."
>> return HttpResponse(response % question_id)
>>
>> def vote(request, question_id):
>> return HttpResponse("You're voting on question %s." % question_id)
>>
>> As a matter of advice, please use a fixed-width font when pasting
>> code, because Python is indented with spaces and using any other
>> type of font makes reading your mail difficult :)
>>
>> El jue., 3 may. 2018 a las 18:08, Avitab Ayan Sarmah
>> (>) escribió:
>>
>> hello Fidel Leon can you please rewrite the whole views.py
>> code so that i can understand what is the exact code is
>>
>> On Thu, May 3, 2018 at 9:19 PM, Fidel Leon > > wrote:
>>
>>
>>
>> El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah
>> (>)
>> escribió:
>>
>>
>> *polls/views.py*:
>>
>>
>> from django.http import HttpResponse
>> from django.template import loader
>>
>> from . models import Question
>>
>> def index(request):
>> return HttpResponse("Hello, world.You're at the polls
>> index.")
>> latest_question_list =
>> Question.objects.order_by('-pub_date')[:5]
>> output = ', '.join([q.question_text for q in
>> latest_question_list])
>> return HttpResponse(output)
>> latest_question_list =
>> Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = {
>> 'latest_question_list': latest_question_list,
>> }
>> return HttpResponse(template.render(context, request))
>>
>>
>> Your function index(request) inside polls/views.py is
>> badly written (you have three function returns). Seems you
>> are following the tutorial but not removing the previous
>> examples:
>>
>> def index(request):
>>   latest_question_list =
>> Question.objects.order_by('-pub_date')[:5]
>>   context = {'latest_question_list': latest_question_list}
>>   return render(request, 'polls/index.html', context)
>>
>> -- Fidel Leon
>> fi...@flm.cat 
>>
>> -- You received this message because you are
>> subscribed to a
>> topic in the Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/5hvN4Lfds-w/
>> unsubscribe
>> > unsubscribe>.
>> To unsubscribe from this group and all its topics, 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/CAHXg%3DN2SNu
>> yAsAzk7mYfBB5rahtD3fRSa4vTbL92BQf5CHg-Nw%40mail.gmail.com
>> > uyAsAzk7mYfBB5rahtD3fRSa4vTbL92BQf5CHg-Nw%40mail.gmail.com?
>> utm_medium=email_source=footer>.
>>
>>
>> For more options, visit https://groups.google.com/d/optout
>> 

Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread 'Anthony Flury' via Django users
I think the root cause of the errors was due to an incorrect settings - 
but Fidel is right that your views.py wasn't great either.


On 03/05/18 17:36, Avitab Ayan Sarmah wrote:

thank you Fidel, and i will take care of it

On Thu, May 3, 2018 at 9:57 PM, Fidel Leon > wrote:


Sure:

from django.http import HttpResponse

from .models import Question


def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
    output = ', '.join([q.question_text for q in
latest_question_list])
    return HttpResponse(output)

def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)

def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)

As a matter of advice, please use a fixed-width font when pasting
code, because Python is indented with spaces and using any other
type of font makes reading your mail difficult :)

El jue., 3 may. 2018 a las 18:08, Avitab Ayan Sarmah
(>) escribió:

hello Fidel Leon can you please rewrite the whole views.py
code so that i can understand what is the exact code is

On Thu, May 3, 2018 at 9:19 PM, Fidel Leon > wrote:



El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah
(>)
escribió:


*polls/views.py*:

from django.http import HttpResponse
from django.template import loader

from . models import Question

def index(request):
return HttpResponse("Hello, world.You're at the polls
index.")
latest_question_list =
Question.objects.order_by('-pub_date')[:5]
output = ', '.join([q.question_text for q in
latest_question_list])
return HttpResponse(output)
latest_question_list =
Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {
'latest_question_list': latest_question_list,
}
return HttpResponse(template.render(context, request))


Your function index(request) inside polls/views.py is
badly written (you have three function returns). Seems you
are following the tutorial but not removing the previous
examples:

def index(request):
  latest_question_list =
Question.objects.order_by('-pub_date')[:5]
  context = {'latest_question_list': latest_question_list}
  return render(request, 'polls/index.html', context)

-- 
Fidel Leon

fi...@flm.cat 

-- 
You received this message because you are subscribed to a

topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit

https://groups.google.com/d/topic/django-users/5hvN4Lfds-w/unsubscribe

.
To unsubscribe from this group and all its topics, 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/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa4vTbL92BQf5CHg-Nw%40mail.gmail.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 

Djangocon Europe plans?

2018-05-03 Thread C. Kirby
Who is going? where are you staying? etc

I'll be flying in on Tuesday from DC. 
I'm in for the conference but not the sprints. Will be giving a talk at the 
end of the first day.

I haven't booked my hotel yet. I usually like staying closer to the venue 
so I can walk and not deal with public transport first thing in the 
morning. Anyone staying closer to the Stadthalle Heidelberg than the 
conference hotels?

Chaim

-- 
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/f3cb3125-4307-4b52-8e5a-39a26c7bba82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread 'Anthony Flury' via Django users

Serves me right for writing code without testing :-(

It of course should be :

            import os
            top_dir = os.path.join(os.getcwd(), 'python_created_me')
            os.makedirs(top_dir)

Glad you have it sorted - and glad it turned out not to be Django ...

On 03/05/18 17:06, Duška Miloradović wrote:

Anthony, I got this:

D:\projectdir>python create_dir.py
Traceback (most recent call last):
  File "create_dir.py", line 2, in 
    top_dir = path.join(os.getcwd(), 'python_created_me')
NameError: name 'path' is not defined

I searched for it through windows explorer again and I actually *found 
it* on this strange location: C:\VTRoot\HarddiskVolume1\projectdir\mysite

Do you have any clue how this happened?
How to make things right? :)

On Thu, May 3, 2018 at 5:08 PM, Anthony Flury 
> 
wrote:


On 03/05/18 08:06, Anthony Flury wrote:

On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:

    I tried what you suggested and got this:
    D:\projectdir>python create_dir.py
    Traceback (most recent call last):
      File "create_dir.py", line 1, in 
        from os import mkdirs
    ImportError: cannot import name 'mkdirs'

Sorry - that should be :

            import os
            top_dir = path.join(os.getcwd(), 'python_created_me')
            os.makedirs(top_dir)


Copy that to a python file called '*create_dir.py*' in your
*projectdir* - and run it by this command '*python create_dir.py*'

One you run it you should have a new empty directory called
'python_created_me' - running the comand again should result
in an error.

The reason for doing this is to check that the Python code
that Django is using does work ok.

The other thing you could do is to use the File Manager search to
see if 'my_site' has been created else where on your system


-- 
-- 
Anthony Flury

email : *anthony.fl...@btinternet.com
*
Twitter : *@TonyFlury >*


--
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/CAJ0SFUA52autPYk95a9s4t%2BHXzdx-OYgj%3DzLyfynYX9XiM%3D6NQ%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.



--
--
Anthony Flury
email : *anthony.fl...@btinternet.com*
Twitter : *@TonyFlury *

--
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/5aeed66b-25ef-200f-22fc-4a0775ea0779%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.


Upload of file with FileField working in admin but not in template

2018-05-03 Thread Alexander Joseph
I'm using CBVs and trying to upload a file with a FileField. It seems to 
work in admin but not in my template. It doesnt give any errors when 
creating the record and it saves the rest of the data in the form, but it 
doesnt save the attachment

Heres my model

class LaserMaskDesign(models.Model):
laser_mask_design_ui = models.CharField(max_length=60, unique=True) # 
Wafer Design UI
mask_layers = models.CharField(max_length=255, default='', blank=True, 
null=True)
design_date = models.DateTimeField(blank=True, null=True)
designer = models.CharField(max_length=255, default='', blank=True, 
null=True)
pcm = models.CharField(max_length=255, default='', blank=True, 
null=True)
critical_dimensions = models.DecimalField(max_digits=20, 
decimal_places=4, default=0., blank=True, null=True)
dimensions = models.CharField(max_length=255, default='')
thickness = models.DecimalField(max_digits=20, decimal_places=4, 
default=0., blank=True, null=True)
material = models.CharField(max_length=255, default='', blank=True, 
null=True)
number_of_products = models.IntegerField(default=0, blank=True, 
null=True)
chip_list = models.CharField(max_length=255, default='', blank=True, 
null=True)
design_document = models.FileField(blank=True, null=True)
notes = models.TextField(blank=True, null=True, default='')
created_at = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(settings.AUTH_USER_MODEL)
in_trash = models.BooleanField(default=False)
inactive_date = models.DateTimeField(blank=True, null=True)

class Meta:
ordering = ['laser_mask_design_ui', ]

def __str__(self):
return self.laser_mask_design_ui

def get_absolute_url(self):
return reverse("engineering:laser_mask_design_detail", 
kwargs={"pk": self.pk})



and my view

class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,):
fields = ("design_ui", "emitting", "contact_location", "optical_power", 
"design_date", "designer", "design_document", "designer_ui", "in_trash", 
"inactive_date", "notes")
model = GaasWaferDesign
template_name = 
'engineering/gaas_wafer_designs/gaas_wafer_design_form.html'

def form_valid(self, form):
object = form.save(commit=False)
object.created_by = self.request.user
object.save()
return super(GaasWaferDesignCreateView, self).form_valid(form)


and my template

{% extends "pages/layout.html" %}
{% load static from staticfiles %}
{% load widget_tweaks %}
{% block title %}{% if not form.instance.pk %}Add GaAs Wafer Design{% else 
%}Edit GaAs Wafer Design - {{ gaaswaferdesign.design_ui }}{{ 
form.instance.gaas_wafer_design.design_ui }}{% endif %}{% endblock %}
{% load django_bootstrap_breadcrumbs %}

{% block breadcrumb %}
  {% block breadcrumbs %}
  {{ block.super }}
  {% endblock %}
{% endblock %}

{% block content %}

  
  {% if not form.instance.pk %}Add GaAs Wafer 
Design{% else %}Edit GaAs Wafer Design{% endif %}
  




  
  {% csrf_token %}
  
  GaAs Wafer Design
  Form
  
  
Bold are required *
{{ form.non_field_errors }}

  

  GaAs 
Wafer Design UI
  {% render_field form.design_ui class+="form-control" %}
  {{ form.design_ui.errors }}

  



  

  Emitter 
Type
  {% render_field form.emitting class+="form-control" %}
  {{ form.emitting.errors }}

  
  

  Contact Location
  {% render_field form.contact_location 
class+="form-control" %}
  {{ form.contact_location.errors }}

  
  

  Optical Power
  {% render_field form.optical_power class+="form-control" 
%}
  {{ form.optical_power.errors }}

  



  

  Design Date
  {% render_field form.design_date class+="form-control" %}
  {{ form.design_date.errors }}

  
  

  Designer
  {% render_field form.designer class+="form-control" %}
  {{ form.owner.errors }}

  



  

  Designer 
UI
  {% render_field form.designer_ui class+="form-control" %}
  {{ form.designer_ui.errors }}

  
  

  Design Document
  {% 

Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread Avitab Ayan Sarmah
thank you Fidel, and i will take care of it

On Thu, May 3, 2018 at 9:57 PM, Fidel Leon  wrote:

> Sure:
>
> from django.http import HttpResponse
>
> from .models import Question
>
>
> def index(request):
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> output = ', '.join([q.question_text for q in latest_question_list])
> return HttpResponse(output)
>
> def detail(request, question_id):
> return HttpResponse("You're looking at question %s." % question_id)
>
> def results(request, question_id):
> response = "You're looking at the results of question %s."
> return HttpResponse(response % question_id)
>
> def vote(request, question_id):
> return HttpResponse("You're voting on question %s." % question_id)
>
> As a matter of advice, please use a fixed-width font when pasting code,
> because Python is indented with spaces and using any other type of font
> makes reading your mail difficult :)
>
> El jue., 3 may. 2018 a las 18:08, Avitab Ayan Sarmah (<
> avitabay...@gmail.com>) escribió:
>
>> hello Fidel Leon can you please rewrite the whole views.py code so that i
>> can understand what is the exact code is
>>
>> On Thu, May 3, 2018 at 9:19 PM, Fidel Leon  wrote:
>>
>>>
>>>
>>> El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah (<
>>> avitabay...@gmail.com>) escribió:
>>>

 *polls/views.py*:

 from django.http import HttpResponse
 from django.template import loader

 from . models import Question

 def index(request):
 return HttpResponse("Hello, world.You're at the polls index.")
 latest_question_list = Question.objects.order_by('-pub_date')[:5]
 output = ', '.join([q.question_text for q in latest_question_list])
 return HttpResponse(output)
 latest_question_list = Question.objects.order_by('-pub_date')[:5]
 template = loader.get_template('polls/index.html')
 context = {
 'latest_question_list': latest_question_list,
 }
 return HttpResponse(template.render(context, request))


>>> Your function index(request) inside polls/views.py is badly written (you
>>> have three function returns). Seems you are following the tutorial but not
>>> removing the previous examples:
>>>
>>> def index(request):
>>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>>> context = {'latest_question_list': latest_question_list}
>>> return render(request, 'polls/index.html', context)
>>>
>>> --
>>> Fidel Leon
>>> fi...@flm.cat
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/django-users/5hvN4Lfds-w/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa
>>> 4vTbL92BQf5CHg-Nw%40mail.gmail.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/CAEx5wm7VMMa3C2%3DyWA%3DQu%
>> 3DhihJiWujwvoA59Xx4ru59Zdc0UVg%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Fidel Leon
> fi...@flm.cat
> Phone: +34 622 26 44 92
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/5hvN4Lfds-w/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAHXg%3DN3-8kKboqLD8cFRympuLvtTgj0uh6Bxbf
> Mr8FtfyNEojA%40mail.gmail.com
> 

Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Duška Miloradović
Ha! I will try to see what will happen when I disable Comodo. I hope it
will work properly then.

Thanks Fidel Leon.

On Thu, May 3, 2018 at 6:24 PM, Fidel Leon  wrote:

> As part of its protection, Comodo Antivirus has something named
> “sandboxing”, so when you execute anything, Comodo catches it, runs it
> inside a protected environment and if it finds it’s not malware, runs the
> actual command.
>
> Seems Comodo is mapping your D: drive to that C:\VTRoot\HarddiskVolume1
> thing, so django-admin gets fooled.
>
> I haven’t used Comodo for decades so I can’t help with this exact issue,
> sorry - maybe disabling the antivirus while you’re at Django? O:-)
>
> Fidel Leon
> fi...@flm.cat
>
>
> El 3 de mayo de 2018 a las 18:19:06, Duška Miloradović (
> daisyfields...@gmail.com) escribió:
>
> Yes? :/
>
> On Thu, May 3, 2018 at 6:09 PM, Fidel Leon  wrote:
>
>> Are you using Comodo Antivirus?
>>
>> https://forums.malwarebytes.com/topic/181573-cvtroot/
>>
>>
>>
>> El jue., 3 may. 2018 a las 18:06, Duška Miloradović (<
>> daisyfields...@gmail.com>) escribió:
>>
>>> Anthony, I got this:
>>>
>>> D:\projectdir>python create_dir.py
>>> Traceback (most recent call last):
>>>   File "create_dir.py", line 2, in 
>>> top_dir = path.join(os.getcwd(), 'python_created_me')
>>> NameError: name 'path' is not defined
>>>
>>> I searched for it through windows explorer again and I actually *found
>>> it* on this strange location: C:\VTRoot\HarddiskVo
>>> lume1\projectdir\mysite
>>> Do you have any clue how this happened?
>>> How to make things right? :)
>>>
>>> On Thu, May 3, 2018 at 5:08 PM, Anthony Flury <
>>> anthony.fl...@btinternet.com> wrote:
>>>
 On 03/05/18 08:06, Anthony Flury wrote:

> On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:
>
> I tried what you suggested and got this:
> D:\projectdir>python create_dir.py
> Traceback (most recent call last):
>   File "create_dir.py", line 1, in 
> from os import mkdirs
> ImportError: cannot import name 'mkdirs'
>
> Sorry - that should be :

 import os
 top_dir = path.join(os.getcwd(), 'python_created_me')
 os.makedirs(top_dir)

>
> Copy that to a python file called '*create_dir.py*' in your
> *projectdir* - and run it by this command '*python create_dir.py*'
>
> One you run it you should have a new empty directory called
> 'python_created_me' - running the comand again should result in an error.
>
> The reason for doing this is to check that the Python code that Django
> is using does work ok.
>
> The other thing you could do is to use the File Manager search to see
 if 'my_site' has been created else where on your system


 --
 --
 Anthony Flury
 email : *anthony.fl...@btinternet.com*
 Twitter : *@TonyFlury *


>>> --
>>> 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/ms
>>> gid/django-users/CAJ0SFUA52autPYk95a9s4t%2BHXzdx-OYgj%
>>> 3DzLyfynYX9XiM%3D6NQ%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Fidel Leon
>> fi...@flm.cat
>> Phone: +34 622 26 44 92
>> --
>> 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/ms
>> gid/django-users/CAHXg%3DN3rH--NCcJ9TLbLJsjtVv0%3D0KoJLh5x01
>> W%2BmrhzNz0oJw%40mail.gmail.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.
> 

Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread Fidel Leon
Sure:

from django.http import HttpResponse

from .models import Question


def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
output = ', '.join([q.question_text for q in latest_question_list])
return HttpResponse(output)

def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)

def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)

As a matter of advice, please use a fixed-width font when pasting code,
because Python is indented with spaces and using any other type of font
makes reading your mail difficult :)

El jue., 3 may. 2018 a las 18:08, Avitab Ayan Sarmah ()
escribió:

> hello Fidel Leon can you please rewrite the whole views.py code so that i
> can understand what is the exact code is
>
> On Thu, May 3, 2018 at 9:19 PM, Fidel Leon  wrote:
>
>>
>>
>> El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah (<
>> avitabay...@gmail.com>) escribió:
>>
>>>
>>> *polls/views.py*:
>>>
>>> from django.http import HttpResponse
>>> from django.template import loader
>>>
>>> from . models import Question
>>>
>>> def index(request):
>>> return HttpResponse("Hello, world.You're at the polls index.")
>>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>>> output = ', '.join([q.question_text for q in latest_question_list])
>>> return HttpResponse(output)
>>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>>> template = loader.get_template('polls/index.html')
>>> context = {
>>> 'latest_question_list': latest_question_list,
>>> }
>>> return HttpResponse(template.render(context, request))
>>>
>>>
>> Your function index(request) inside polls/views.py is badly written (you
>> have three function returns). Seems you are following the tutorial but not
>> removing the previous examples:
>>
>> def index(request):
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> context = {'latest_question_list': latest_question_list}
>> return render(request, 'polls/index.html', context)
>>
>> --
>> Fidel Leon
>> fi...@flm.cat
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/5hvN4Lfds-w/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa4vTbL92BQf5CHg-Nw%40mail.gmail.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/CAEx5wm7VMMa3C2%3DyWA%3DQu%3DhihJiWujwvoA59Xx4ru59Zdc0UVg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Fidel Leon
fi...@flm.cat
Phone: +34 622 26 44 92

-- 
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/CAHXg%3DN3-8kKboqLD8cFRympuLvtTgj0uh6BxbfMr8FtfyNEojA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Fidel Leon
As part of its protection, Comodo Antivirus has something named
“sandboxing”, so when you execute anything, Comodo catches it, runs it
inside a protected environment and if it finds it’s not malware, runs the
actual command.

Seems Comodo is mapping your D: drive to that C:\VTRoot\HarddiskVolume1
thing, so django-admin gets fooled.

I haven’t used Comodo for decades so I can’t help with this exact issue,
sorry - maybe disabling the antivirus while you’re at Django? O:-)

Fidel Leon
fi...@flm.cat


El 3 de mayo de 2018 a las 18:19:06, Duška Miloradović (
daisyfields...@gmail.com) escribió:

Yes? :/

On Thu, May 3, 2018 at 6:09 PM, Fidel Leon  wrote:

> Are you using Comodo Antivirus?
>
> https://forums.malwarebytes.com/topic/181573-cvtroot/
>
>
>
> El jue., 3 may. 2018 a las 18:06, Duška Miloradović (<
> daisyfields...@gmail.com>) escribió:
>
>> Anthony, I got this:
>>
>> D:\projectdir>python create_dir.py
>> Traceback (most recent call last):
>>   File "create_dir.py", line 2, in 
>> top_dir = path.join(os.getcwd(), 'python_created_me')
>> NameError: name 'path' is not defined
>>
>> I searched for it through windows explorer again and I actually *found
>> it* on this strange location: C:\VTRoot\HarddiskVolume1\projectdir\mysite
>> Do you have any clue how this happened?
>> How to make things right? :)
>>
>> On Thu, May 3, 2018 at 5:08 PM, Anthony Flury <
>> anthony.fl...@btinternet.com> wrote:
>>
>>> On 03/05/18 08:06, Anthony Flury wrote:
>>>
 On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:

 I tried what you suggested and got this:
 D:\projectdir>python create_dir.py
 Traceback (most recent call last):
   File "create_dir.py", line 1, in 
 from os import mkdirs
 ImportError: cannot import name 'mkdirs'

 Sorry - that should be :
>>>
>>> import os
>>> top_dir = path.join(os.getcwd(), 'python_created_me')
>>> os.makedirs(top_dir)
>>>

 Copy that to a python file called '*create_dir.py*' in your
 *projectdir* - and run it by this command '*python create_dir.py*'

 One you run it you should have a new empty directory called
 'python_created_me' - running the comand again should result in an error.

 The reason for doing this is to check that the Python code that Django
 is using does work ok.

 The other thing you could do is to use the File Manager search to see
>>> if 'my_site' has been created else where on your system
>>>
>>>
>>> --
>>> --
>>> Anthony Flury
>>> email : *anthony.fl...@btinternet.com*
>>> Twitter : *@TonyFlury *
>>>
>>>
>> --
>> 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/CAJ0SFUA52autPYk95a9s4t%2BHXzdx-OYgj%3DzLyfynYX9XiM%
>> 3D6NQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Fidel Leon
> fi...@flm.cat
> Phone: +34 622 26 44 92
> --
> 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/CAHXg%3DN3rH--NCcJ9TLbLJsjtVv0%
> 3D0KoJLh5x01W%2BmrhzNz0oJw%40mail.gmail.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/CAJ0SFUC8dLCRZuq%2BF62o29i5MGGi%2B9E13i0gQ%2BvLkwO%3D1KM7OQ%40mail.gmail.com

.
For more 

Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Duška Miloradović
Yes? :/

On Thu, May 3, 2018 at 6:09 PM, Fidel Leon  wrote:

> Are you using Comodo Antivirus?
>
> https://forums.malwarebytes.com/topic/181573-cvtroot/
>
>
>
> El jue., 3 may. 2018 a las 18:06, Duška Miloradović (<
> daisyfields...@gmail.com>) escribió:
>
>> Anthony, I got this:
>>
>> D:\projectdir>python create_dir.py
>> Traceback (most recent call last):
>>   File "create_dir.py", line 2, in 
>> top_dir = path.join(os.getcwd(), 'python_created_me')
>> NameError: name 'path' is not defined
>>
>> I searched for it through windows explorer again and I actually *found
>> it* on this strange location: C:\VTRoot\HarddiskVolume1\projectdir\mysite
>> Do you have any clue how this happened?
>> How to make things right? :)
>>
>> On Thu, May 3, 2018 at 5:08 PM, Anthony Flury <
>> anthony.fl...@btinternet.com> wrote:
>>
>>> On 03/05/18 08:06, Anthony Flury wrote:
>>>
 On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:

 I tried what you suggested and got this:
 D:\projectdir>python create_dir.py
 Traceback (most recent call last):
   File "create_dir.py", line 1, in 
 from os import mkdirs
 ImportError: cannot import name 'mkdirs'

 Sorry - that should be :
>>>
>>> import os
>>> top_dir = path.join(os.getcwd(), 'python_created_me')
>>> os.makedirs(top_dir)
>>>

 Copy that to a python file called '*create_dir.py*' in your
 *projectdir* - and run it by this command '*python create_dir.py*'

 One you run it you should have a new empty directory called
 'python_created_me' - running the comand again should result in an error.

 The reason for doing this is to check that the Python code that Django
 is using does work ok.

 The other thing you could do is to use the File Manager search to see
>>> if 'my_site' has been created else where on your system
>>>
>>>
>>> --
>>> --
>>> Anthony Flury
>>> email : *anthony.fl...@btinternet.com*
>>> Twitter : *@TonyFlury *
>>>
>>>
>> --
>> 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/CAJ0SFUA52autPYk95a9s4t%2BHXzdx-OYgj%3DzLyfynYX9XiM%
>> 3D6NQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Fidel Leon
> fi...@flm.cat
> Phone: +34 622 26 44 92
>
> --
> 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/CAHXg%3DN3rH--NCcJ9TLbLJsjtVv0%
> 3D0KoJLh5x01W%2BmrhzNz0oJw%40mail.gmail.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/CAJ0SFUC8dLCRZuq%2BF62o29i5MGGi%2B9E13i0gQ%2BvLkwO%3D1KM7OQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Fidel Leon
Are you using Comodo Antivirus?

https://forums.malwarebytes.com/topic/181573-cvtroot/



El jue., 3 may. 2018 a las 18:06, Duška Miloradović (<
daisyfields...@gmail.com>) escribió:

> Anthony, I got this:
>
> D:\projectdir>python create_dir.py
> Traceback (most recent call last):
>   File "create_dir.py", line 2, in 
> top_dir = path.join(os.getcwd(), 'python_created_me')
> NameError: name 'path' is not defined
>
> I searched for it through windows explorer again and I actually *found it*
> on this strange location: C:\VTRoot\HarddiskVolume1\projectdir\mysite
> Do you have any clue how this happened?
> How to make things right? :)
>
> On Thu, May 3, 2018 at 5:08 PM, Anthony Flury <
> anthony.fl...@btinternet.com> wrote:
>
>> On 03/05/18 08:06, Anthony Flury wrote:
>>
>>> On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:
>>>
>>> I tried what you suggested and got this:
>>> D:\projectdir>python create_dir.py
>>> Traceback (most recent call last):
>>>   File "create_dir.py", line 1, in 
>>> from os import mkdirs
>>> ImportError: cannot import name 'mkdirs'
>>>
>>> Sorry - that should be :
>>
>> import os
>> top_dir = path.join(os.getcwd(), 'python_created_me')
>> os.makedirs(top_dir)
>>
>>>
>>> Copy that to a python file called '*create_dir.py*' in your *projectdir*
>>> - and run it by this command '*python create_dir.py*'
>>>
>>> One you run it you should have a new empty directory called
>>> 'python_created_me' - running the comand again should result in an error.
>>>
>>> The reason for doing this is to check that the Python code that Django
>>> is using does work ok.
>>>
>>> The other thing you could do is to use the File Manager search to see if
>> 'my_site' has been created else where on your system
>>
>>
>> --
>> --
>> Anthony Flury
>> email : *anthony.fl...@btinternet.com*
>> Twitter : *@TonyFlury *
>>
>>
> --
> 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/CAJ0SFUA52autPYk95a9s4t%2BHXzdx-OYgj%3DzLyfynYX9XiM%3D6NQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Fidel Leon
fi...@flm.cat
Phone: +34 622 26 44 92

-- 
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/CAHXg%3DN3rH--NCcJ9TLbLJsjtVv0%3D0KoJLh5x01W%2BmrhzNz0oJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread Avitab Ayan Sarmah
hello Fidel Leon can you please rewrite the whole views.py code so that i
can understand what is the exact code is

On Thu, May 3, 2018 at 9:19 PM, Fidel Leon  wrote:

>
>
> El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah (<
> avitabay...@gmail.com>) escribió:
>
>>
>> *polls/views.py*:
>>
>> from django.http import HttpResponse
>> from django.template import loader
>>
>> from . models import Question
>>
>> def index(request):
>> return HttpResponse("Hello, world.You're at the polls index.")
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> output = ', '.join([q.question_text for q in latest_question_list])
>> return HttpResponse(output)
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = {
>> 'latest_question_list': latest_question_list,
>> }
>> return HttpResponse(template.render(context, request))
>>
>>
> Your function index(request) inside polls/views.py is badly written (you
> have three function returns). Seems you are following the tutorial but not
> removing the previous examples:
>
> def index(request):
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> context = {'latest_question_list': latest_question_list}
> return render(request, 'polls/index.html', context)
>
> --
> Fidel Leon
> fi...@flm.cat
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/5hvN4Lfds-w/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa
> 4vTbL92BQf5CHg-Nw%40mail.gmail.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/CAEx5wm7VMMa3C2%3DyWA%3DQu%3DhihJiWujwvoA59Xx4ru59Zdc0UVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Duška Miloradović
Anthony, I got this:

D:\projectdir>python create_dir.py
Traceback (most recent call last):
  File "create_dir.py", line 2, in 
top_dir = path.join(os.getcwd(), 'python_created_me')
NameError: name 'path' is not defined

I searched for it through windows explorer again and I actually *found it*
on this strange location: C:\VTRoot\HarddiskVolume1\projectdir\mysite
Do you have any clue how this happened?
How to make things right? :)

On Thu, May 3, 2018 at 5:08 PM, Anthony Flury 
wrote:

> On 03/05/18 08:06, Anthony Flury wrote:
>
>> On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:
>>
>> I tried what you suggested and got this:
>> D:\projectdir>python create_dir.py
>> Traceback (most recent call last):
>>   File "create_dir.py", line 1, in 
>> from os import mkdirs
>> ImportError: cannot import name 'mkdirs'
>>
>> Sorry - that should be :
>
> import os
> top_dir = path.join(os.getcwd(), 'python_created_me')
> os.makedirs(top_dir)
>
>>
>> Copy that to a python file called '*create_dir.py*' in your *projectdir*
>> - and run it by this command '*python create_dir.py*'
>>
>> One you run it you should have a new empty directory called
>> 'python_created_me' - running the comand again should result in an error.
>>
>> The reason for doing this is to check that the Python code that Django is
>> using does work ok.
>>
>> The other thing you could do is to use the File Manager search to see if
> 'my_site' has been created else where on your system
>
>
> --
> --
> Anthony Flury
> email : *anthony.fl...@btinternet.com*
> Twitter : *@TonyFlury *
>
>

-- 
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/CAJ0SFUA52autPYk95a9s4t%2BHXzdx-OYgj%3DzLyfynYX9XiM%3D6NQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Fidel Leon
Please try to create a different project specifying -v 3:
$ django-admin startapp -v 3 mytest

The output should tell you where django-admin is creating its files and
could be a clue about where is your mysite :)

El jue., 3 may. 2018 a las 14:24, Duška Miloradović (<
daisyfields...@gmail.com>) escribió:

> Ayser, thank you very much but that did not help neither. It is still the
> same - command ends successfully but still I do not see new folder created.
>
> On Thu, May 3, 2018 at 8:13 AM, Ayser shuhaib 
> wrote:
>
>> Create your projectdir manually then inside the projectdir folder (right
>> click with your mouse and open command window here)
>> After that continue with Django commands
>> django-admin startproject ...
>>
>> On Thu, 03 May 2018 at 07:59, Daisy  wrote:
>>
>>> Thank you very much for your reply, and here I my answers:
>>>   * Does the directory show up when you do a *dir* command in projectdir
>>> ? It does not show up, although it says that there are 2 directories
>>> (see attachment).
>>>
>>>   * Can you do anything on the *mysite* directory - can you rename it,
>>> or even delete it ? I can't - system cannot find the file specified.
>>>   * Can you see it in File explorer - No.
>>>   * Can you manually create a directory in your *projectdir* ? - Yes,
>>> and it is displayed after command *dir*.
>>>
>>>   * Can you create a different projectdir - and run *django-admin
>>> startproject mysite* in there ? - I tried creating it on different
>>> paths, both on C and D disk, but it was the same behavior.
>>>
>>> What can I do now? :)
>>>
>>> четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:
>>>
 Lets troubleshoot:

   * Does the directory show up when you do a *dir* command in
 projectdir ?
   * Can you do anything on the *mysite* directory - can you rename it,
 or even delete it ?
   * Can you see it in File explorer
   * Can you manually create a directory in your *projectdir* ?
   * Can you create a different projectdir - and run *django-admin
 startproject mysite* in there ?

 My gut feeling is that this is a diskdrive/OS type issue - rather than
 Django specific

 You may have a corrupted directory - or a bad section of disk; try the
 troubleshooting steps above first.



 On 02/05/18 22:09, Daisy wrote:
 > I installed django according to provided instructions and I am trying
 > to follow the Django article: Writing your first Django app, part 1
 >  but I am
 > stuck at Creating a project with command: django-admin startproject
 > mysite.
 > The problem is that I CAN execute command but when I try to access
 > directory with cd mysite I get the message "The system cannot find
 the
 > path specified." although when I try to execute command startproject
 > again I get the message that it already exists. (see attachment)
 > I cannot find new directory via windows explorer neither.
 > I have installed django 2.0.5 version and python 3.6.3 (32-bit).
 > --
 > 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/c574d479-a1b6-4c20-91ab-208ae42d4996%40googlegroups.com
 > <
 https://groups.google.com/d/msgid/django-users/c574d479-a1b6-4c20-91ab-208ae42d4996%40googlegroups.com?utm_medium=email_source=footer>.

 > For more options, visit https://groups.google.com/d/optout.


 --
 --
 Anthony Flury

>>> email : *anthon...@btinternet.com*

>>> Twitter : *@TonyFlury *

 --
>>> 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/c93769b1-55ca-47f7-9f8f-474ab07ede88%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --

Re: Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" th

2018-05-03 Thread Fidel Leon
El jue., 3 may. 2018 a las 17:38, Avitab Ayan Sarmah ()
escribió:

>
> *polls/views.py*:
>
> from django.http import HttpResponse
> from django.template import loader
>
> from . models import Question
>
> def index(request):
> return HttpResponse("Hello, world.You're at the polls index.")
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> output = ', '.join([q.question_text for q in latest_question_list])
> return HttpResponse(output)
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> template = loader.get_template('polls/index.html')
> context = {
> 'latest_question_list': latest_question_list,
> }
> return HttpResponse(template.render(context, request))
>
>
Your function index(request) inside polls/views.py is badly written (you
have three function returns). Seems you are following the tutorial but not
removing the previous examples:

def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
context = {'latest_question_list': latest_question_list}
return render(request, 'polls/index.html', context)

-- 
Fidel Leon
fi...@flm.cat

-- 
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/CAHXg%3DN2SNuyAsAzk7mYfBB5rahtD3fRSa4vTbL92BQf5CHg-Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Working through the Django tutorial and have run into a problem I cannot figure out. Help would be appreciated. What am I missing here? whenever is search the url "http://127.0.0.1:8000/polls/" the si

2018-05-03 Thread Avitab Ayan Sarmah
*mysite/urls.py:*

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('', include('polls.urls')),
path('admin/', admin.site.urls),
]

*polls/templates/polls/index.html*:

{% if latest_question_list %}
  
  {% for question in latest_question_list %}
{{
question.question_text }}
  {% endfor %}
  
{% else %}
  No polls are available.
{% endif %}

*polls/urls.py*:

from django.urls import path

from . import views

urlpatterns = [
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('/', views.detail, name='detail'),
#ex: /polls/5/results/
path('/results/', views.results, name='results'),
#ex: /polls/5/vote/
path('int:question_id>/vote/', views.vote, name='vote'),
]

*polls/views.py*:

from django.http import HttpResponse
from django.template import loader

from . models import Question

def index(request):
return HttpResponse("Hello, world.You're at the polls index.")
latest_question_list = Question.objects.order_by('-pub_date')[:5]
output = ', '.join([q.question_text for q in latest_question_list])
return HttpResponse(output)
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {
'latest_question_list': latest_question_list,
}
return HttpResponse(template.render(context, request))
def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)

def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)

def vote(request, question_id):
return HttpResponse("You're voting on question %s." % question_id)


i've attached the command prompt below.Please check,your help would be very 
helpfull

-- 
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/aac07da3-a242-4799-8919-608370a2056b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread 'Anthony Flury' via Django users

On 03/05/18 08:06, Anthony Flury wrote:

On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:

I tried what you suggested and got this:
D:\projectdir>python create_dir.py
Traceback (most recent call last):
  File "create_dir.py", line 1, in 
    from os import mkdirs
ImportError: cannot import name 'mkdirs'


Sorry - that should be :

            import os
            top_dir = path.join(os.getcwd(), 'python_created_me')
            os.makedirs(top_dir)


Copy that to a python file called '*create_dir.py*' in your 
*projectdir* - and run it by this command '*python create_dir.py*'


One you run it you should have a new empty directory called 
'python_created_me' - running the comand again should result in an error.


The reason for doing this is to check that the Python code that Django 
is using does work ok.


The other thing you could do is to use the File Manager search to see if 
'my_site' has been created else where on your system


--
--
Anthony Flury
email : *anthony.fl...@btinternet.com*
Twitter : *@TonyFlury *

--
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/4ae66204-5ad6-dfa4-28f7-d93b671bb7fb%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.


Re: Use self-increasing arguments in numeric for-loop in Django

2018-05-03 Thread Peter of the Norse
First of all, this is a terrible idea.  You should fix up graphobject in your 
view to do what you want, not try to massage it in your template.

Second, you can’t use template tags inside a template.  That’s not how it works 
at all.

Third, you are not the first to have this terrible idea.  You can search the 
web and find many examples of people “solving” this non-problem.

- Peter of the Norse

> On Apr 20, 2018, at 7:49 AM, Bill Torcaso  wrote:
> 
> 
> I an new-ish to Django, and I ask this to hear from more experienced users 
> whether this would work at all, and whether it would be considered a good or 
> bad practice.
> 
> Goal: given an object and an integer index, retrieve the sub-object at that 
> index within the incoming object.
> 
> Method:  Write a custom tag.  Provide the tag with the larger object, and the 
> integer index.  Return the sub-object at that index (or whatever field(s) are 
> needed).
> 
> Usage:
> 
>   {% for i in metarange %}
> {% graphobject_get_by_index graphobject {{ i }} %}
>   {% endfor %}
> 
> 
> In this particular case, there is an issue about whether the sub-object can 
> be null, for some definition of null.  There are various ways to deal with 
> that.
> 
> Again, I am new-ish to Django.  Is there a similar approach in which 
> 'get_by_index' is a method on class Graphobject, such that this would work?
> 
> {% graphobject.get_by_index {{ i }} %}
> 
> Thanks for any explanation about these approaches.
> 
> 
>> On Thursday, April 19, 2018 at 12:01:37 PM UTC-4, shaw...@gmail.com wrote:
>> I am currently working on django.
>> 
>> I have a list of values which stored in 'graphobject', and 'metarange' is 
>> defined as range(0,59). In that case, how could I use numbers as argument to 
>> display the value stored in graphobject? I tried using following codes but 
>> it doesn't work
>> 
>> 
>> 
>> {% for i in metarange %}
>> {% if graphobject.i != '' %}
>> {{ graphobject.i }}
>> {% endif %}
>> {% endfor %}
>> 
>> 
>> Please tell me how could I do this?
>> 
> 
> -- 
> 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/9c162dd2-201b-4370-bac0-f3afb3db163a%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/5A9432AF-BA0B-47C5-BF9F-DA4A5DDDB259%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble raising forms.ValidationError in save() override in admin.py

2018-05-03 Thread Gonzalo Amadio
This is very old, but in the case someone red this.

If you do it on the save method of the admin, you MUST save the model.

So you should override admin's form. 

Check it here how to do it : http://itegram.com/2018/05/03/
add-extra-control-to-admin-save-method/ 


El jueves, 31 de marzo de 2011, 8:10:40 (UTC-3), Daniel Roseman escribió:
>
> On Thursday, March 31, 2011 11:09:17 AM UTC+1, Lloyd Dube wrote:
>>
>> Hi Shawn,
>>
>> Thanks for the feedback. I read the docs and defined a clean_audio_file 
>> method in my ModelAdmin class.
>
>
> That's not what the docs say. They say you should create it on the Form. 
> And where did you get the idea that the clean method takes any of those 
> parameters?
> --
> DR.
>

-- 
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/b73a0f49-2716-42f1-b026-6dd3a935d8fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: model permission assignment via groups requires further config at model level?

2018-05-03 Thread gibsonal2026
that is good


On Monday, April 30, 2018 at 7:08:16 AM UTC-5, Rob B wrote:
>
> Thanks George - I understand now.  I never thought it would only apply to 
> the admin interface but should have.  Kind regards,
>
> Rob
>
>
> On Sun, Apr 29, 2018, 10:05 PM George Lubaretsi,  > wrote:
>
>> Django permissions are only enforced in Admin interface by default. You 
>> have to enforce them in your views by using `has_perm` method of `user` 
>> instance - `user.has_perm('.')`
>>
>> Here's the documentation for permissions - 
>> https://docs.djangoproject.com/en/dev/topics/auth/default/#permissions-and-authorization
>>
>> Also, take a look at this blog post for some alternatives to built-in 
>> permissions system - 
>> https://www.vinta.com.br/blog/2016/controlling-access-a-django-permission-apps-comparison/
>>
>> On Monday, April 30, 2018 at 5:04:04 AM UTC+4, rsbaxter wrote:
>>>
>>> I'm trying to confirm if this is correct: I create a group with no 
>>> permissions in it, and assign this group to a user.  This user is not 
>>> "staff status" nor is the user "superuser status" - they are only active.  
>>> The user is not a member of any other groups - just the one with no 
>>> permissions.  Upon login, this user is still able to add, update and delete 
>>> all models in the app.  I think I'm misunderstanding the group 
>>> functionality - is it correct that permissions assigned via groups are not 
>>> automatically enforced by django and that further configuration is required 
>>> to enforce the permissions assigned via the group(s) assigned to the 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...@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/2c0bd344-cc7b-4691-9a73-4bd39ff7c538%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/64a6e7b5-b40b-428a-bcf3-bf37c7a27ec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Duška Miloradović
I wrote what versions I have installed in first post, but here is a result
of what you've asked:
For the first command output is: Python 3.6.3 and for the second: 2.0.5

On Thu, May 3, 2018 at 3:43 PM, James Farris  wrote:

> If you run these two commands from your command line, what is the output?
>
> *python -V*
> *django-admin.py version*
>
>
> On May 3, 2018, at 5:23 AM, Duška Miloradović 
> wrote:
>
> Ayser, thank you very much but that did not help neither. It is still the
> same - command ends successfully but still I do not see new folder created.
>
> On Thu, May 3, 2018 at 8:13 AM, Ayser shuhaib 
> wrote:
>
>> Create your projectdir manually then inside the projectdir folder (right
>> click with your mouse and open command window here)
>> After that continue with Django commands
>> django-admin startproject ...
>>
>> On Thu, 03 May 2018 at 07:59, Daisy  wrote:
>>
>>> Thank you very much for your reply, and here I my answers:
>>>   * Does the directory show up when you do a *dir* command in projectdir
>>> ? It does not show up, although it says that there are 2 directories
>>> (see attachment).
>>>
>>>   * Can you do anything on the *mysite* directory - can you rename it,
>>> or even delete it ? I can't - system cannot find the file specified.
>>>   * Can you see it in File explorer - No.
>>>   * Can you manually create a directory in your *projectdir* ? - Yes,
>>> and it is displayed after command *dir*.
>>>
>>>   * Can you create a different projectdir - and run *django-admin
>>> startproject mysite* in there ? - I tried creating it on different
>>> paths, both on C and D disk, but it was the same behavior.
>>>
>>> What can I do now? :)
>>>
>>> четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:
>>>
 Lets troubleshoot:

   * Does the directory show up when you do a *dir* command in
 projectdir ?
   * Can you do anything on the *mysite* directory - can you rename it,
 or even delete it ?
   * Can you see it in File explorer
   * Can you manually create a directory in your *projectdir* ?
   * Can you create a different projectdir - and run *django-admin
 startproject mysite* in there ?

 My gut feeling is that this is a diskdrive/OS type issue - rather than
 Django specific

 You may have a corrupted directory - or a bad section of disk; try the
 troubleshooting steps above first.



 On 02/05/18 22:09, Daisy wrote:
 > I installed django according to provided instructions and I am trying
 > to follow the Django article: Writing your first Django app, part 1
 >  but I am
 > stuck at Creating a project with command: django-admin startproject
 > mysite.
 > The problem is that I CAN execute command but when I try to access
 > directory with cd mysite I get the message "The system cannot find
 the
 > path specified." although when I try to execute command startproject
 > again I get the message that it already exists. (see attachment)
 > I cannot find new directory via windows explorer neither.
 > I have installed django 2.0.5 version and python 3.6.3 (32-bit).
 > --
 > 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/c574d479-a1b6
 -4c20-91ab-208ae42d4996%40googlegroups.com
 > .
 > For more options, visit https://groups.google.com/d/optout.


 --
 --
 Anthony Flury

>>> email : *anthon...@btinternet.com*

>>> Twitter : *@TonyFlury *

 --
>>> 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/ms
>>> gid/django-users/c93769b1-55ca-47f7-9f8f-474ab07ede88%40googlegroups.com
>>> 

Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread James Farris
If you run these two commands from your command line, what is the output?

python -V 
django-admin.py version


> On May 3, 2018, at 5:23 AM, Duška Miloradović  
> wrote:
> 
> Ayser, thank you very much but that did not help neither. It is still the 
> same - command ends successfully but still I do not see new folder created.
> 
>> On Thu, May 3, 2018 at 8:13 AM, Ayser shuhaib  
>> wrote:
>> Create your projectdir manually then inside the projectdir folder (right 
>> click with your mouse and open command window here)
>> After that continue with Django commands
>> django-admin startproject ...
>> 
>>> On Thu, 03 May 2018 at 07:59, Daisy  wrote:
>>> Thank you very much for your reply, and here I my answers:
>>>   * Does the directory show up when you do a *dir* command in projectdir ? 
>>> It does not show up, although it says that there are 2 directories (see 
>>> attachment). 
>>> 
>>>   * Can you do anything on the *mysite* directory - can you rename it, 
>>> or even delete it ? I can't - system cannot find the file specified.
>>>   * Can you see it in File explorer - No.
>>>   * Can you manually create a directory in your *projectdir* ? - Yes, and 
>>> it is displayed after command *dir*.
>>> 
>>>   * Can you create a different projectdir - and run *django-admin 
>>> startproject mysite* in there ? - I tried creating it on different 
>>> paths, both on C and D disk, but it was the same behavior.
>>> 
>>> What can I do now? :)
>>> 
>>> четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:
 Lets troubleshoot: 
 
   * Does the directory show up when you do a *dir* command in projectdir ? 
   * Can you do anything on the *mysite* directory - can you rename it, 
 or even delete it ? 
   * Can you see it in File explorer 
   * Can you manually create a directory in your *projectdir* ? 
   * Can you create a different projectdir - and run *django-admin 
 startproject mysite* in there ? 
 
 My gut feeling is that this is a diskdrive/OS type issue - rather than 
 Django specific 
 
 You may have a corrupted directory - or a bad section of disk; try the 
 troubleshooting steps above first. 
 
 
 
 On 02/05/18 22:09, Daisy wrote: 
 > I installed django according to provided instructions and I am trying 
 > to follow the Django article: Writing your first Django app, part 1 
 >  but I am 
 > stuck at Creating a project with command: django-admin startproject 
 > mysite. 
 > The problem is that I CAN execute command but when I try to access 
 > directory with cd mysite I get the message "The system cannot find the 
 > path specified." although when I try to execute command startproject 
 > again I get the message that it already exists. (see attachment) 
 > I cannot find new directory via windows explorer neither. 
 > I have installed django 2.0.5 version and python 3.6.3 (32-bit). 
 > -- 
 > 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/c574d479-a1b6-4c20-91ab-208ae42d4996%40googlegroups.com
 >  
 > .
 >  
 > For more options, visit https://groups.google.com/d/optout. 
 
 
 -- 
 -- 
 Anthony Flury 
>>> 
 email : *anthon...@btinternet.com* 
>>> 
 Twitter : *@TonyFlury * 
 
>>> 
>>> -- 
>>> 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/c93769b1-55ca-47f7-9f8f-474ab07ede88%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 

RE: OperationalError

2018-05-03 Thread Matthew Pava
I use PhantomJS with Django to create PDFs.  I just pass in the URL with the 
session variable (to maintain authentication) and a few other parameters into a 
customized Rasterize.js script.
Is it an “easy” way?  I wouldn’t say so, but it works for us.

It gets really crazy when you start asking, “Does anyone know of an easy way to 
print in Django?”  It’s not easy, but it can be done in an appropriate 
environment.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Gerald Brown
Sent: Thursday, May 3, 2018 7:22 AM
To: Django users
Subject: Re: OperationalError


FINALLY. SUCCESS!!! What I ended up doing to correct the problem was to drop 
the whole database (NO RECORDS YET). When I tried to run migrations it said 
there were no changes.  I then had to run makemigrations  and 
migrate  so I am now back in business!!!

Now does anyone know of an easy way to create PDF documents in Django???

Thanks to all for the suggestions and ideas!!!

On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:

I finally discovered what I think is the cause of my problem. DJANGO 
MIGRATIONS ARE NOT WORKING. On the system that has the problem is where I made 
migration to change some of the field names.  The fields that were not found 
where the ones that did get changed but the old unchanged names were still 
there.  On another system that is working NONE of the fields names were changed 
so it didn't have any unknown fields. Both systems had migrations run against 
the model file where some fields had changes made and the other one NO changes 
were made and on a third machine all changes were made.

Who knows what evil lurks in the heart of the computer? The Shadow knows!!!

On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:
I have a Django application that I am having problems with.  In the Admin page 
I have 3 sections, ABC, DEF & XYZ. Each has 1 option to "Add/Change".  In 2 of 
them when I click on the option it works fine. The third gives me the following 
error "

1054, "Unknown column 'xyz_xyz.first_name' in "field list"



The Exception location is: 
/home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/MySQLdb/connections.py
 in query,

line 277



On another system (both running the same code) I was also getting a different 
error also in site-packages/MySQLdb but I was

able correct that by installing 2 DEV packages and then installing MySQLClient, 
which I also did on this computer.  The other

system does NOT give this error.



Any ideas, suggestions, solutions on how to solve this error and any other 
errors in the Django code?



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@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/74790172-8bf5-43b6-9bad-bab68ae11a4a%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/e17d8d56-d57c-4f3d-ae6f-a004a5beda70%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/e5e175015b1d445f979cfc318cf32eec%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Nullable vs empty strings

2018-05-03 Thread Jani Tiainen
And then you find out that Oracle implicitly converts empty strings to
NULLs which causes all kind of hassle. :)


On Thu, May 3, 2018 at 3:39 PM, Ken Whitesell 
wrote:

> Nick,
>
>  A null string (string with length 0) is _not_ the same as a null
> field (no string). The two are distinct, and (can) serve two very different
> functions.
>
> Take a look at this for some more detailed information: https://
> softwareengineering.stackexchange.com/questions/32578/sql-empty-string-vs-
> null-value
>
> Ken
>
>
> On Thursday, May 3, 2018 at 5:17:35 AM UTC-4, Nick Sarbicki wrote:
>>
>> I just saw this in the docs: https://docs.djangoproje
>> ct.com/en/2.0/ref/models/fields/#null
>>
>> Suggesting that you should never set a CharField to null unless using a
>> unique index.
>>
>> Is this generally accepted? Historically I've always nulled a CharField
>> because using empty strings, as opposed to letting a column be nullable,
>> has felt very dirty to me.
>>
>> I would have expected (not suggesting this as a change) an empty string
>> to fail if the field isn't nullable.
>>
>> Am I on my own here?
>>
> --
> 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/23e3a4dc-345a-4fb9-8122-0dba7b99bb4d%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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/CAHn91of_PjMgOqpOHhN4q572qLDX%2Bi_SDBrNuZpBthUDyn6r5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nullable vs empty strings

2018-05-03 Thread Ken Whitesell
Nick,

 A null string (string with length 0) is _not_ the same as a null field 
(no string). The two are distinct, and (can) serve two very different 
functions. 

Take a look at this for some more detailed 
information: 
https://softwareengineering.stackexchange.com/questions/32578/sql-empty-string-vs-null-value

Ken


On Thursday, May 3, 2018 at 5:17:35 AM UTC-4, Nick Sarbicki wrote:
>
> I just saw this in the docs: 
> https://docs.djangoproject.com/en/2.0/ref/models/fields/#null
>
> Suggesting that you should never set a CharField to null unless using a 
> unique index.
>
> Is this generally accepted? Historically I've always nulled a CharField 
> because using empty strings, as opposed to letting a column be nullable, 
> has felt very dirty to me.
>
> I would have expected (not suggesting this as a change) an empty string to 
> fail if the field isn't nullable.
>
> Am I on my own here?
>

-- 
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/23e3a4dc-345a-4fb9-8122-0dba7b99bb4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Duška Miloradović
Ayser, thank you very much but that did not help neither. It is still the
same - command ends successfully but still I do not see new folder created.

On Thu, May 3, 2018 at 8:13 AM, Ayser shuhaib 
wrote:

> Create your projectdir manually then inside the projectdir folder (right
> click with your mouse and open command window here)
> After that continue with Django commands
> django-admin startproject ...
>
> On Thu, 03 May 2018 at 07:59, Daisy  wrote:
>
>> Thank you very much for your reply, and here I my answers:
>>   * Does the directory show up when you do a *dir* command in projectdir
>> ? It does not show up, although it says that there are 2 directories
>> (see attachment).
>>
>>   * Can you do anything on the *mysite* directory - can you rename it,
>> or even delete it ? I can't - system cannot find the file specified.
>>   * Can you see it in File explorer - No.
>>   * Can you manually create a directory in your *projectdir* ? - Yes,
>> and it is displayed after command *dir*.
>>
>>   * Can you create a different projectdir - and run *django-admin
>> startproject mysite* in there ? - I tried creating it on different
>> paths, both on C and D disk, but it was the same behavior.
>>
>> What can I do now? :)
>>
>> четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:
>>
>>> Lets troubleshoot:
>>>
>>>   * Does the directory show up when you do a *dir* command in projectdir
>>> ?
>>>   * Can you do anything on the *mysite* directory - can you rename it,
>>> or even delete it ?
>>>   * Can you see it in File explorer
>>>   * Can you manually create a directory in your *projectdir* ?
>>>   * Can you create a different projectdir - and run *django-admin
>>> startproject mysite* in there ?
>>>
>>> My gut feeling is that this is a diskdrive/OS type issue - rather than
>>> Django specific
>>>
>>> You may have a corrupted directory - or a bad section of disk; try the
>>> troubleshooting steps above first.
>>>
>>>
>>>
>>> On 02/05/18 22:09, Daisy wrote:
>>> > I installed django according to provided instructions and I am trying
>>> > to follow the Django article: Writing your first Django app, part 1
>>> >  but I am
>>> > stuck at Creating a project with command: django-admin startproject
>>> > mysite.
>>> > The problem is that I CAN execute command but when I try to access
>>> > directory with cd mysite I get the message "The system cannot find the
>>> > path specified." although when I try to execute command startproject
>>> > again I get the message that it already exists. (see attachment)
>>> > I cannot find new directory via windows explorer neither.
>>> > I have installed django 2.0.5 version and python 3.6.3 (32-bit).
>>> > --
>>> > 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/c574d479-
>>> a1b6-4c20-91ab-208ae42d4996%40googlegroups.com
>>> > >> a1b6-4c20-91ab-208ae42d4996%40googlegroups.com?utm_medium=
>>> email_source=footer>.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> --
>>> Anthony Flury
>>>
>> email : *anthon...@btinternet.com*
>>>
>> Twitter : *@TonyFlury *
>>>
>>> --
>> 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/c93769b1-55ca-47f7-9f8f-474ab07ede88%
>> 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 

Re: OperationalError

2018-05-03 Thread Gerald Brown

FINALLY. SUCCESS!!! What I ended up doing to correct the problem was to 
drop the whole database (NO RECORDS YET). When I tried to run migrations it 
said there were no changes.  I then had to run makemigrations  
and migrate  so I am now back in business!!!

Now does anyone know of an *easy* way to create PDF documents in Django???

Thanks to all for the suggestions and ideas!!!

On Thursday, May 3, 2018 at 6:13:35 PM UTC+8, Gerald Brown wrote:
>
> I finally discovered what I think is the cause of my problem. *DJANGO 
> MIGRATIONS ARE NOT WORKING. *On the system that has the problem is where 
> I made migration to change some of the field names.  The fields that were 
> not found where the ones that did get changed but the old unchanged names 
> were still there.  On another system that is working NONE of the fields 
> names were changed so it didn't have any unknown fields. Both systems had 
> migrations run against the model file where some fields had changes made 
> and the other one NO changes were made and on a third machine all changes 
> were made.
>
> *Who knows what evil lurks in the heart of the computer? The Shadow 
> knows!!! *
>
> On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:
>
> I have a Django application that I am having problems with.  In the Admin 
> page I have 3 sections, ABC, DEF & XYZ. Each has 1 option to "Add/Change".  
> In 2 of them when I click on the option it works fine. The third gives me 
> the following error "
>
> *1054, "Unknown column 'xyz_xyz.first_name' in "field list"
>
> *The Exception location is: 
> */home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/*MySQLdb*/connections.py
>  in query, 
> line 277*
> On another system (both running the same code) I was also getting a different 
> error also in *site-packages/MySQLdb* but I was
> able correct that by installing 2 DEV packages and then installing 
> MySQLClient, which I also did on this computer.  The other
> system does NOT give this error.
>
> Any ideas, suggestions, solutions on how to solve this error and any other 
> errors in the Django code?
>
> 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@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/74790172-8bf5-43b6-9bad-bab68ae11a4a%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/e17d8d56-d57c-4f3d-ae6f-a004a5beda70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[no subject]

2018-05-03 Thread Muwanguzi Derrick
Hlo am a new django user I want be your friend for help

-- 
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/CAKMyrdAxS6y%2BOmzb7cpiA9yn0-wLGa4HNV%2BDgu6sfHSYQpdwYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Umar Kambala
That its not recognized as internal or external command
On May 3, 2018 11:21 AM, "Ayser shuhaib"  wrote:

> Create your projectdir manually then inside the projectdir folder (right
> click with your mouse and open command window here)
> After that continue with Django commands
> django-admin startproject ...
>
> On Thu, 03 May 2018 at 07:59, Daisy  wrote:
>
>> Thank you very much for your reply, and here I my answers:
>>   * Does the directory show up when you do a *dir* command in projectdir
>> ? It does not show up, although it says that there are 2 directories
>> (see attachment).
>>
>>   * Can you do anything on the *mysite* directory - can you rename it,
>> or even delete it ? I can't - system cannot find the file specified.
>>   * Can you see it in File explorer - No.
>>   * Can you manually create a directory in your *projectdir* ? - Yes,
>> and it is displayed after command *dir*.
>>
>>   * Can you create a different projectdir - and run *django-admin
>> startproject mysite* in there ? - I tried creating it on different
>> paths, both on C and D disk, but it was the same behavior.
>>
>> What can I do now? :)
>>
>> четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:
>>
>>> Lets troubleshoot:
>>>
>>>   * Does the directory show up when you do a *dir* command in projectdir
>>> ?
>>>   * Can you do anything on the *mysite* directory - can you rename it,
>>> or even delete it ?
>>>   * Can you see it in File explorer
>>>   * Can you manually create a directory in your *projectdir* ?
>>>   * Can you create a different projectdir - and run *django-admin
>>> startproject mysite* in there ?
>>>
>>> My gut feeling is that this is a diskdrive/OS type issue - rather than
>>> Django specific
>>>
>>> You may have a corrupted directory - or a bad section of disk; try the
>>> troubleshooting steps above first.
>>>
>>>
>>>
>>> On 02/05/18 22:09, Daisy wrote:
>>> > I installed django according to provided instructions and I am trying
>>> > to follow the Django article: Writing your first Django app, part 1
>>> >  but I am
>>> > stuck at Creating a project with command: django-admin startproject
>>> > mysite.
>>> > The problem is that I CAN execute command but when I try to access
>>> > directory with cd mysite I get the message "The system cannot find the
>>> > path specified." although when I try to execute command startproject
>>> > again I get the message that it already exists. (see attachment)
>>> > I cannot find new directory via windows explorer neither.
>>> > I have installed django 2.0.5 version and python 3.6.3 (32-bit).
>>> > --
>>> > 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/c574d479-
>>> a1b6-4c20-91ab-208ae42d4996%40googlegroups.com
>>> > >> a1b6-4c20-91ab-208ae42d4996%40googlegroups.com?utm_medium=
>>> email_source=footer>.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> --
>>> Anthony Flury
>>>
>> email : *anthon...@btinternet.com*
>>>
>> Twitter : *@TonyFlury *
>>>
>>> --
>> 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/c93769b1-55ca-47f7-9f8f-474ab07ede88%
>> 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/CAE0AZGKfOqYa3bpFi5LYXQgRNP1yx
> 

Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Ayser shuhaib
Create your projectdir manually then inside the projectdir folder (right
click with your mouse and open command window here)
After that continue with Django commands
django-admin startproject ...

On Thu, 03 May 2018 at 07:59, Daisy  wrote:

> Thank you very much for your reply, and here I my answers:
>   * Does the directory show up when you do a *dir* command in projectdir ? It
> does not show up, although it says that there are 2 directories (see
> attachment).
>
>   * Can you do anything on the *mysite* directory - can you rename it,
> or even delete it ? I can't - system cannot find the file specified.
>   * Can you see it in File explorer - No.
>   * Can you manually create a directory in your *projectdir* ? - Yes, and
> it is displayed after command *dir*.
>
>   * Can you create a different projectdir - and run *django-admin
> startproject mysite* in there ? - I tried creating it on different
> paths, both on C and D disk, but it was the same behavior.
>
> What can I do now? :)
>
> четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:
>
>> Lets troubleshoot:
>>
>>   * Does the directory show up when you do a *dir* command in projectdir
>> ?
>>   * Can you do anything on the *mysite* directory - can you rename it,
>> or even delete it ?
>>   * Can you see it in File explorer
>>   * Can you manually create a directory in your *projectdir* ?
>>   * Can you create a different projectdir - and run *django-admin
>> startproject mysite* in there ?
>>
>> My gut feeling is that this is a diskdrive/OS type issue - rather than
>> Django specific
>>
>> You may have a corrupted directory - or a bad section of disk; try the
>> troubleshooting steps above first.
>>
>>
>>
>> On 02/05/18 22:09, Daisy wrote:
>> > I installed django according to provided instructions and I am trying
>> > to follow the Django article: Writing your first Django app, part 1
>> >  but I am
>> > stuck at Creating a project with command: django-admin startproject
>> > mysite.
>> > The problem is that I CAN execute command but when I try to access
>> > directory with cd mysite I get the message "The system cannot find the
>> > path specified." although when I try to execute command startproject
>> > again I get the message that it already exists. (see attachment)
>> > I cannot find new directory via windows explorer neither.
>> > I have installed django 2.0.5 version and python 3.6.3 (32-bit).
>> > --
>> > 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/c574d479-a1b6-4c20-91ab-208ae42d4996%40googlegroups.com
>> > <
>> https://groups.google.com/d/msgid/django-users/c574d479-a1b6-4c20-91ab-208ae42d4996%40googlegroups.com?utm_medium=email_source=footer>.
>>
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> --
>> Anthony Flury
>>
> email : *anthon...@btinternet.com*
>>
> Twitter : *@TonyFlury *
>>
>> --
> 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/c93769b1-55ca-47f7-9f8f-474ab07ede88%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/CAE0AZGKfOqYa3bpFi5LYXQgRNP1yxus22gWfamXR8GYBxfyZrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: OperationalError

2018-05-03 Thread Gerald Brown
I finally discovered what I think is the cause of my problem. *DJANGO 
MIGRATIONS ARE NOT WORKING.*On the system that has the problem is where 
I made migration to change some of the field names.  The fields that 
were not found where the ones that did get changed but the old unchanged 
names were still there.  On another system that is working NONE of the 
fields names were changed so it didn't have any unknown fields. Both 
systems had migrations run against the model file where some fields had 
changes made and the other one NO changes were made and on a third 
machine all changes were made.


/Who knows what evil lurks in the heart of the computer? *The Shadow 
knows!!!* /



On Wednesday, 02 May, 2018 07:56 AM, Gerald Brown wrote:
I have a Django application that I am having problems with.  In the 
Admin page I have 3 sections, ABC, DEF & XYZ. Each has 1 option to 
"Add/Change".  In 2 of them when I click on the option it works fine. 
The third gives me the following error "
*1054, "Unknown column 'xyz_xyz.first_name' in "field list" *The 
Exception location is: 
*/home/medrec1/.virtualenvs/medrecproj/lib/python3.5/site-packages/*MySQLdb*/connections.py 
in query, line 277* On another system (both running the same code) I 
was also getting a different error also in *site-packages/MySQLdb* but 
I was able correct that by installing 2 DEV packages and then  installing MySQLClient, which I also did on this computer.  The other

system does NOT give this error.

Any ideas, suggestions, solutions on how to solve this error and any other 
errors in the Django code?

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@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/74790172-8bf5-43b6-9bad-bab68ae11a4a%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/43790a35-4c51-ff0e-09c0-2fbcdad6c9f1%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding to all templates context via Middleware

2018-05-03 Thread Daniel Roseman
On Thursday, 3 May 2018 01:36:26 UTC+1, Bernd Wechner wrote:
>
> This interests me:
>
> 
> https://teamtreehouse.com/community/django-how-can-i-retrieve-a-value-from-the-middleware
>
> alas no answer there, and time has changed things.
>
> I have checked form experience, that stuff added to response.context_data 
> in middleware is not seen in templates (perhaps comes too late!).
>
> Another pager here:
>
> https://mlvin.xyz/django-templates-context-processors.html
>
> describes how to add to context used context processors. Searching the web 
> is nightmare in this space because of how Django has changed over time and 
> the different methods in different versions.
>
> The problem I have with that sample above is he's replicating code by 
> including in settings.py:
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [os.path.join(BASE_DIR, "templates"),],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> # our custom context processor
> 'utils.context_processors.active_shows',
> ],
> },
> },]
>
>
> most of which is standard. Is there not a much more DRY way to add a 
> context processor? Would this work?
>
> TEMPLATES = [
> {
> 'OPTIONS': {
> 'context_processors': [
> 'utils.context_processors.active_shows',
> ],
> },
> },]
>
>
> Probably not at a guess.  But is there a nicer way to do it?
>
> Another way might be to patch the response.content in the middleware but 
> that too seems messy.
>
> Surely there's a nice way for middlware to take some timing stats around 
> the:
>
> response = self.get_response(request)
>
> invocation that typically returns a response (and which I presume has 
> already been through the whole template processing and has finalised 
> response.content by the time it's done, so taking a timestamp after it's 
> done is easy but making the result available in the templates via a context 
> variable like {{execution_time}} would seem structurally impossible if 
> context processing has already happened. 
>
> I can only imagine a trick using another context key like 
> %%execution_time%% say and replacing that response.content.
>
> I wonder if I'm on the right track here? Or if someone has a better idea?
>
> Regards,
>
> Bernd.
>
>

I don't understand what you mean about "repeating code" in settings.py. 
There's no need to repeat anything; that TEMPLATES setting replaces what's 
there already. You just need to edit the existing value and add that extra 
context processor.
--
DR.

-- 
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/8a3fb41d-0396-46fb-b896-b468fb103a2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Nullable vs empty strings

2018-05-03 Thread Nick Sarbicki
I just saw this in the 
docs: https://docs.djangoproject.com/en/2.0/ref/models/fields/#null

Suggesting that you should never set a CharField to null unless using a 
unique index.

Is this generally accepted? Historically I've always nulled a CharField 
because using empty strings, as opposed to letting a column be nullable, 
has felt very dirty to me.

I would have expected (not suggesting this as a change) an empty string to 
fail if the field isn't nullable.

Am I on my own here?

-- 
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/28b6a2c4-564d-4c7c-8498-9c3d5cba5958%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Duška Miloradović
It is on C. I tried to create "mysite" also on C path but the result is the
same.

On Thu, May 3, 2018 at 9:49 AM, Gerald Brown  wrote:

> Is Django installed on your C: or D: drive?  If it is on C: then "mysite"
> should also be on C:
>
> On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:
>
> I tried what you suggested and got this:
> D:\projectdir>python create_dir.py
> Traceback (most recent call last):
>   File "create_dir.py", line 1, in 
> from os import mkdirs
> ImportError: cannot import name 'mkdirs'
>
> среда, 02. мај 2018. 23.13.29 UTC+2, Daisy је написао/ла:
>>
>> I installed django according to provided instructions and I am trying to
>> follow the Django article: Writing your first Django app, part 1
>>  but I am stuck
>> at Creating a project with command: django-admin startproject mysite.
>> The problem is that I CAN execute command but when I try to access
>> directory with cd mysite I get the message "The system cannot find the
>> path specified." although when I try to execute command startproject again
>> I get the message that it already exists. (see attachment)
>> I cannot find new directory via windows explorer neither.
>> I have installed django 2.0.5 version and python 3.6.3 (32-bit).
>>
> --
> 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/58e5b0ab-46c5-46fe-a346-28d1f43619e7%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/afa3504d-38a9-b56b-fbc7-353c14d698d4%40gmail.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/CAJ0SFUAXpQbFJ9iK-sSQAF%2BSfQhmsoGF8b2kvZrBJXskgGnzTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Gerald Brown
Is Django installed on your C: or D: drive?  If it is on C: then 
"mysite" should also be on C:



On Thursday, 03 May, 2018 03:25 PM, Daisy wrote:

I tried what you suggested and got this:
D:\projectdir>python create_dir.py
Traceback (most recent call last):
  File "create_dir.py", line 1, in 
    from os import mkdirs
ImportError: cannot import name 'mkdirs'

среда, 02. мај 2018. 23.13.29 UTC+2, Daisy је написао/ла:

I installed django according to provided instructions and I am
trying to follow the Django article: Writing your first Django
app, part 1
 but I am
stuck at Creating a project with command: django-admin
startproject mysite.
The problem is that I CAN execute command but when I try to access
directory with cd mysite I get the message "The system cannot find
the path specified." although when I try to execute command
startproject again I get the message that it already exists. (see
attachment)
I cannot find new directory via windows explorer neither.
I have installed django 2.0.5 version and python 3.6.3 (32-bit).

--
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/58e5b0ab-46c5-46fe-a346-28d1f43619e7%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/afa3504d-38a9-b56b-fbc7-353c14d698d4%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread Daisy
I tried what you suggested and got this:
D:\projectdir>python create_dir.py
Traceback (most recent call last):
  File "create_dir.py", line 1, in 
from os import mkdirs
ImportError: cannot import name 'mkdirs'

среда, 02. мај 2018. 23.13.29 UTC+2, Daisy је написао/ла:
>
> I installed django according to provided instructions and I am trying to 
> follow the Django article: Writing your first Django app, part 1 
>  but I am stuck 
> at Creating a project with command: django-admin startproject mysite.
> The problem is that I CAN execute command but when I try to access 
> directory with cd mysite I get the message "The system cannot find the 
> path specified." although when I try to execute command startproject again 
> I get the message that it already exists. (see attachment)
> I cannot find new directory via windows explorer neither.
>
> I have installed django 2.0.5 version and python 3.6.3 (32-bit).
>

-- 
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/58e5b0ab-46c5-46fe-a346-28d1f43619e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help: django-admin.py startproject [projectname] creates directory which I cannot access

2018-05-03 Thread 'Anthony Flury' via Django users

On 03/05/18 06:59, Daisy wrote:

Thank you very much for your reply, and here I my answers:
  * Does the directory show up when you do a *dir* command in 
projectdir ? It does not show up, although it says that there are 2 
directories (see attachment).

Those two directories '.' & '..' are standard in every directory

  * Can you do anything on the *mysite* directory - can you rename it,
    or even delete it ? I can't - system cannot find the file specified.
Very odd - points to a an OS/disk problem to be honest - I am not sure 
Django is doing anything clever.

  * Can you see it in File explorer - No.
  * Can you manually create a directory in your *projectdir* ? - Yes, 
and it is displayed after command *dir*.

  * Can you create a different projectdir - and run *django-admin
    startproject mysite* in there ? - I tried creating it on different 
paths, both on C and D disk, but it was the same behavior.


What can I do now? :)



Have you tried write a small Python application that creates a directory :

 from os import mkdirs
     top_dir = path.join(os.getcwd(), name)
 mkdirs(top_dir)

Copy that to a python file called '*create_dir.py*' in your *projectdir* 
- and run it by this command '*python create_dir.py*'


One you run it you should have a new empty directory called 
'python_created_me' - running the comand again should result in an error.


The reason for doing this is to check that the Python code that Django 
is using does work ok.


--
Anthony Flury
email : *anthony.fl...@btinternet.com*
Twitter : *@TonyFlury *


четвртак, 03. мај 2018. 01.08.04 UTC+2, TonyF-UK је написао/ла:

Lets troubleshoot:

  * Does the directory show up when you do a *dir* command in
projectdir ?
  * Can you do anything on the *mysite* directory - can you rename
it,
    or even delete it ?
  * Can you see it in File explorer
  * Can you manually create a directory in your *projectdir* ?
  * Can you create a different projectdir - and run *django-admin
    startproject mysite* in there ?

My gut feeling is that this is a diskdrive/OS type issue - rather
than
Django specific

You may have a corrupted directory - or a bad section of disk; try
the
troubleshooting steps above first.



On 02/05/18 22:09, Daisy wrote:
> I installed django according to provided instructions and I am
trying
> to follow the Django article: Writing your first Django app, part 1
> > but I am
> stuck at Creating a project with command: django-admin startproject
> mysite.
> The problem is that I CAN execute command but when I try to access
> directory with cd mysite I get the message "The system cannot
find the
> path specified." although when I try to execute command
startproject
> again I get the message that it already exists. (see attachment)
> I cannot find new directory via windows explorer neither.
> I have installed django 2.0.5 version and python 3.6.3 (32-bit).
> --
> 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/c574d479-a1b6-4c20-91ab-208ae42d4996%40googlegroups.com



>

>.

> For more options, visit https://groups.google.com/d/optout
.


-- 
-- 
Anthony Flury

email : *anthon...@btinternet.com *
Twitter : *@TonyFlury >*

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

Re: OperationalError

2018-05-03 Thread Gerald Brown
Been there. Done that. Many times!!!  Still can't find the field list 
that it is complaining about.


What is really weird is that the same code runs on 2 other computers 
without any errors.



On Wednesday, 02 May, 2018 09:16 PM, Matthew Pava wrote:


“random letters & numbers”

That looks like merge conflicts with Git.  You’ll want to fix those 
up, not just by deleting those lines, but by verifying the code does 
what you want it to.


You may want to just delete all of your migrations files and start 
anew if they’re not important to you.


*From:*django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] *On Behalf Of *Gerald Brown

*Sent:* Wednesday, May 2, 2018 4:08 AM
*To:* Anthony Flury; django-users@googlegroups.com
*Subject:* Re: OperationalError

Thanks for the reply.

I have done the makemigrations/migrate numerous times.  Each time it 
says there is an error in the previous migration file so I have to 
comment out most of the file.  I then just deleted all of the self 
generated migration files and started fresh.


I was also getting some weird characters in my files like "random 
letters & numbers.  I deleted all of those & ran the migrations again.


The weird thing is that now when I click on the link it says "unknown 
column telephone in field list", previously it was first_name that was 
unknown.


I have this application running on a "similar" computer and it has 
*NO* problems with this area so maybe there are some other 
applications running that cause the problem even though this one is in 
a virtualenv.


On Wednesday, 02 May, 2018 03:00 PM, Anthony Flury wrote:

At first glance it looks like you haven't applied a migration to
this computer.

at the command line on this computer  - in the man project
directory :

If you have not copied the migration scripts from your development
machine do this first :

   $ python manage.py makemigrations

and then do this :

   $ python manage.py migrate

--
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/5499b870-33e8-52db-85e2-df835be17e87%40gmail.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/21802186cf2749e6b6e191e8fc78ce26%40ISS1.ISS.LOCAL 
.

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/9ad1a0d3-9243-a539-e584-b9f1fcb78962%40gmail.com.
For more options, visit https://groups.google.com/d/optout.