Re: Slug not working

2019-04-18 Thread Aakash Baranwal
Can anyone kindly suggest what I am doing wrong?

Thanks
Aakash

On Thu, Apr 18, 2019 at 3:10 PM Aakash Baranwal 
wrote:

> Hi Everybody,
>
> This is my models.py file:
>
> from django.db.models.signals import pre_save
> from django.utils.text import slugify
> from django.db import models
> from django.conf import settings
> from django import forms
>
> # Create your models here.
> class Video(models.Model):
> Video_Description= models.CharField(max_length=500)
> slug = models.SlugField(unique=True)
>
> videofile= models.FileField(upload_to='videos/', null=True,
> verbose_name="")
> timestamp   = models.DateTimeField(auto_now_add=True)
>
> class Meta:
> ordering = ['-timestamp']
>
> def get_absolute_url(self):
> return reverse ("video:detail", kwargs={"slug":self.slug})
>
>
> def __str__(self):
> return self.Video_Description + ": " + str(self.id)
>
>
> def create_slug(instance, new_slug=None):
> slug = slugify(instance.Video_Description)
> if new_slug is not None:
> slug = new_slug
> qs = Video.objects.filter(slug=slug).order_by("-id")
> exists = qs.exists()
> if exists:
> new_slug = "%s-%s" %(slug, qs.first().id)
> return create_slug(instance, slug=new_slug)
> return slug
>
>
> def pre_save_video_receiver(sender, instance, *args, **kwargs):
> if not instance.slug:
> instance.slug = create_slug(instance)
>
> pre_save.connect(pre_save_video_receiver, sender=Video)
>
>
> The problem I am facing is, slug field appears in the admin and
> unfortunately in the create page where I am uploading the videos.
>
> However, in the url it is not coming, also in the create page, I have to
> enter the slug manually. I want it to take whatever input was given to t
> video_description in the models.py file and it should disappear from the
> create post page.
>
> Kindly help me.
>
> With Kind Regards
> Aakash Baranwal
>

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


Re: Convertingg rendered Model Data in HTML to PDF USING XHTML2PDF

2019-04-18 Thread Irfan Khan
thanks for your response Matthew Pava 

Not Exactly getting using xhtml2pdf for converting model data rendered in 
html to pdf 

i have browsed but not exactly getting, can any one please guide me, 



On Thursday, 18 April 2019 20:18:59 UTC+5:30, Irfan Khan wrote:
>
> hi, all
> can any one please guide me how to covert the rendered data from models in 
> html to pdf 
>
> for example i have developed application and in that implemented search 
> field to get the data from the database,till now it now fine but i have 
> used xhtml2pdf library to convert 
> i can see there only some of context passed in views only converting.
> please guide me how to implement.
>
>

-- 
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/217654ee-67fe-4799-b8d4-e9372b4ca63b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Slug not working

2019-04-18 Thread Aakash Baranwal
Hello Sir,

As of now, I haven't thought of making any tutorials as I am just learning.

Best
Aakash

On Thu, Apr 18, 2019 at 4:05 PM fofa Zu  wrote:

> idk what is the problem but i liked your app it is a tutorial if is it may
> i get the link thanks
>
> ‫في الخميس، 18 أبريل 2019 في 12:41 م تمت كتابة ما يلي بواسطة ‪Aakash
> Baranwal‬‏ <‪baakash1...@gmail.com‬‏>:‬
>
>> Hi Everybody,
>>
>> This is my models.py file:
>>
>> from django.db.models.signals import pre_save
>> from django.utils.text import slugify
>> from django.db import models
>> from django.conf import settings
>> from django import forms
>>
>> # Create your models here.
>> class Video(models.Model):
>> Video_Description= models.CharField(max_length=500)
>> slug = models.SlugField(unique=True)
>>
>> videofile= models.FileField(upload_to='videos/', null=True,
>> verbose_name="")
>> timestamp   = models.DateTimeField(auto_now_add=True)
>>
>> class Meta:
>> ordering = ['-timestamp']
>>
>> def get_absolute_url(self):
>> return reverse ("video:detail", kwargs={"slug":self.slug})
>>
>>
>> def __str__(self):
>> return self.Video_Description + ": " + str(self.id)
>>
>>
>> def create_slug(instance, new_slug=None):
>> slug = slugify(instance.Video_Description)
>> if new_slug is not None:
>> slug = new_slug
>> qs = Video.objects.filter(slug=slug).order_by("-id")
>> exists = qs.exists()
>> if exists:
>> new_slug = "%s-%s" %(slug, qs.first().id)
>> return create_slug(instance, slug=new_slug)
>> return slug
>>
>>
>> def pre_save_video_receiver(sender, instance, *args, **kwargs):
>> if not instance.slug:
>> instance.slug = create_slug(instance)
>>
>> pre_save.connect(pre_save_video_receiver, sender=Video)
>>
>>
>> The problem I am facing is, slug field appears in the admin and
>> unfortunately in the create page where I am uploading the videos.
>>
>> However, in the url it is not coming, also in the create page, I have to
>> enter the slug manually. I want it to take whatever input was given to t
>> video_description in the models.py file and it should disappear from the
>> create post page.
>>
>> Kindly help me.
>>
>> With Kind Regards
>> Aakash Baranwal
>>
>> --
>> 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/CALr9hQ2hsoqjBaN7g5%2B6rqkEyRYrfDMHPan8tSvHG%3DQjhnfRbw%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/CAPkS-C57EYh-PS56ZUAM0wcuvUoZs5Lu_71x5fRWwoq2tM0uiQ%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/CALr9hQ1ZMJe_ZniuMDHEeiG_%3D0r0zxPns%2BX00hSQPDx%2Bcakr_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Merging multiple Django project into one

2019-04-18 Thread Simon Liu
Hello, 

I am try to migrate users from an old project into a a new project i am 
working on. I have extracted all the models from my old project into a 
reusable app. I was able to connect to multiple database, but i wasn't able 
to make my project be able to read the users and group from my old project. 
I was hoping to be able to write migrations where i read old user data and 
create it in my new project. Since both project use the auth apps for 
authentication i am not sure i am able to tell the db routers where to read 
the users and groups from which db. What would be a good approach to solve 
this problem of reading user/group data from one django project and migrate 
the data to a new project?

-- 
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/2286a0a7-21c5-400b-b2b6-cc671ec4f250%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select2 field breaks in admin when extending change_form.html

2019-04-18 Thread Jason Burke
Greetings,

I'm not sure I was clear earlier, so I'll reword the problem again here...

*Issue/Problem/Bug:* Extending the admin/change_form.html template in order 
to modify the .form-row style causes the autocomplete (Select2) and raw id 
widgets to stop working as documented.

*Problem behavior*: The autocomplete widget stops populating the drop down 
box, and the raw id widget search icon redirects to the parent objects list 
display instead of opening up a separate selection window.

*Test:* To reproduce the issue, follow the test case I included above.

*Questions:* Is this a bug? Can others reproduce the issue? How to fix it 
without modifying the default admin templates or css files?



On Thursday, April 18, 2019 at 1:12:38 PM UTC-5, Julio Cojom wrote:
>
> Hi sir,
>
> There is a library exclusive for admin, his name it's something like 
> select2 admin , search it, I used it a couple times and only requires that 
> you add it to your settings.py 
>
> Regards!
>

-- 
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/c709ad80-6c7f-4dfd-ba85-adbf0b6364ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select2 field breaks in admin when extending change_form.html

2019-04-18 Thread Julio Cojom
Hi sir,

There is a library exclusive for admin, his name it's something like
select2 admin , search it, I used it a couple times and only requires that
you add it to your settings.py

Regards!

On Thu, Apr 18, 2019, 11:51 AM Jason Burke  wrote:

> Greetings all,
>
> I'm working on a project, and I didn't like the default solid grey lines
> in each form-row, so I extended the change_form.html to remove them.
> However, in doing so, the autocomplete select2 field broke (raw_id_fields
> breaks as well). I've been looking for a workaround on this issue, and I
> don't know if it's a bug or not. If anyone has a workaround, I would
> appreciate hearing what it is (though I would prefer not to modify any
> files in the Django package). And, if anyone wants to replicate the issue,
> I've included a test case below, but please let me know if I forgot
> anything.
>
> Any thoughts or help is greatly appreciated.
>
> Regards,
>
> Jason
>
>
>
> *Autocomplete_fields with **extended** change_form.html test*
>
> 1. Install Python (I have version 3.7.2 64 bit installed on Windows 10
> Pro).
>
>
> 2. Run the following commands in your working directory:
>
> a. mkdir djangotest.
>
> b. cd bugtest
>
> c. python -m venv venv
>
> d. .\venv\scripts\activate
>
> e. django-admin startproject bugtest .
>
> f.  python manage.py startapp testing
>
> g. python manage.py migrate
>
>
>
> 3. Update installed apps settings in .\djangotest\bugtest\settings.py
>
> INSTALLED_APPS = [
> 'testing.apps.TestingConfig',
> # leave default apps...
> ]
>
>
> 4. Change .\djangotest\testing\models.py to the following:
>
> from django.db import models
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> def __str__(self):
> return self.question_text
>
>
> class Choice(models.Model):
> question = models.ForeignKey(Question, on_delete=models.CASCADE)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
>
> def __str__(self):
> return self.choice_text
>
>
> 5. Change .\djangotest\testing\admin.py to the following:
>
> from .models import Question, Choice
>
>
> class QuestionAdmin(admin.ModelAdmin):
> ordering = ['pub_date']
> search_fields = ['question_text']
>
>
> class ChoiceAdmin(admin.ModelAdmin):
> autocomplete_fields = ['question']
> #raw_id_fields = ('question',)
>
>
> admin.site.register(Question, QuestionAdmin)
> admin.site.register(Choice, ChoiceAdmin)
>
>
>
> 6. Run the following commands:
>
> a. python manage.py migrate
>
> b. python manage.py makemigrations testing
>
> c. python manage.py migrate testing
>
> d. python manage.py createsuperuser (enter in info for testing superuser).
>
> e. python manage.py runserver
>
>
>
> 7. Open http://127.0.0.1:8000/admin/testing/choice/add/ in browser (I'm
> using Chrome version 73.0.3683.103 (Official Build) (64-bit)).
>
>
> 8. Verify that the foreign key field (question) is working as expected.
>
>
> 9. Create the following directories: .\djangotest\testing\templates,
> .\djangotest\testing\templates\admin
>
>
> 10. Create change_form.html file in .\djangotest\testing\templates\admin
> with the following information:
>
> {% extends "admin/change_form.html" %}
> {% block extrahead %}
> 
> .form-row {
> border-bottom: none;
> }
> 
> {% endblock %}
>
>
> 11. Reload http://127.0.0.1:8000/admin/testing/choice/add/ in browser.
>
>
> 12. Verify that foreign key field (question) is not working as expected.
>
> --
> 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/e8a43eae-2f3c-4d6a-848b-02e3cce11ab1%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/CAHRQUH%3DDCnS0ok-GBtPqudohUsSLrm54riQtp_-w-pG5SESzxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Select2 field breaks in admin when extending change_form.html

2019-04-18 Thread Jason Burke
Greetings all,

I'm working on a project, and I didn't like the default solid grey lines in 
each form-row, so I extended the change_form.html to remove them. However, 
in doing so, the autocomplete select2 field broke (raw_id_fields breaks as 
well). I've been looking for a workaround on this issue, and I don't know 
if it's a bug or not. If anyone has a workaround, I would appreciate 
hearing what it is (though I would prefer not to modify any files in the 
Django package). And, if anyone wants to replicate the issue, I've included 
a test case below, but please let me know if I forgot anything.

Any thoughts or help is greatly appreciated.

Regards,

Jason



*Autocomplete_fields with **extended** change_form.html test*

1. Install Python (I have version 3.7.2 64 bit installed on Windows 10 Pro).


2. Run the following commands in your working directory:

a. mkdir djangotest.

b. cd bugtest

c. python -m venv venv

d. .\venv\scripts\activate

e. django-admin startproject bugtest .

f.  python manage.py startapp testing

g. python manage.py migrate



3. Update installed apps settings in .\djangotest\bugtest\settings.py

INSTALLED_APPS = [
'testing.apps.TestingConfig',
# leave default apps...
]


4. Change .\djangotest\testing\models.py to the following:

from django.db import models

class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __str__(self):
return self.question_text


class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def __str__(self):
return self.choice_text


5. Change .\djangotest\testing\admin.py to the following:

from .models import Question, Choice


class QuestionAdmin(admin.ModelAdmin):
ordering = ['pub_date']
search_fields = ['question_text']


class ChoiceAdmin(admin.ModelAdmin):
autocomplete_fields = ['question']
#raw_id_fields = ('question',)


admin.site.register(Question, QuestionAdmin)
admin.site.register(Choice, ChoiceAdmin)



6. Run the following commands:

a. python manage.py migrate

b. python manage.py makemigrations testing

c. python manage.py migrate testing

d. python manage.py createsuperuser (enter in info for testing superuser).

e. python manage.py runserver



7. Open http://127.0.0.1:8000/admin/testing/choice/add/ in browser (I'm 
using Chrome version 73.0.3683.103 (Official Build) (64-bit)). 


8. Verify that the foreign key field (question) is working as expected.


9. Create the following directories: .\djangotest\testing\templates, 
.\djangotest\testing\templates\admin


10. Create change_form.html file in .\djangotest\testing\templates\admin 
with the following information:

{% extends "admin/change_form.html" %}
{% block extrahead %}

.form-row {
border-bottom: none;
}

{% endblock %}


11. Reload http://127.0.0.1:8000/admin/testing/choice/add/ in browser.


12. Verify that foreign key field (question) is not working as expected.

-- 
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/e8a43eae-2f3c-4d6a-848b-02e3cce11ab1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django form help

2019-04-18 Thread Pramod Pandey
Dear all
i did not pass drives_a value to drives variable ;
i am using django module plz help me if any one using this django module..

#My Code is

from django import forms
import os
drives_a = [chr(x) + "," for x in range(65, 90) if os.path.exists(chr(x) + 
':')]

class contactForm(forms.Form):
drives = forms.CharField(label='Drive Name', 
widget=forms.Select(choices=drives_a))

-- 
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/941af6e4-764e-4846-9833-93f8c8da62e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: File not getting uploaded

2019-04-18 Thread Aakash Baranwal
Yes Sir,

I corrected it. Thanks a lot.

Best
Aakash

On Thu, Apr 18, 2019 at 8:46 PM adarsh pandey 
wrote:

> Gentle man you have not given enctype=" form/multipartdata" in the form
> tag of the HTML file
>
>
> On Wed, Apr 17, 2019, 12:05 PM Aakash Baranwal 
> wrote:
>
>> Hi Everybody,
>>
>> I am trying to upload a file, but it says "No file chosen", even when I
>> have selected the file. However it is getting uploaded when I have logged
>> in as as admin and i am uploading it from there.
>>
>> Kindly help me, thanks in advance.
>>
>> views.py file:
>>
>> class VideoCreateView(CreateView):
>> form_class = VideoModelForm
>> fields = ['Video_Description','videofile']
>> template_name = 'deploy/create_view.html'
>>
>> success_url = "/video/create/"
>>
>> def form_valid(self, form):
>> form.instance.user = self.request.videofile
>> return super(VideoCreateView, self).form_valid(form)
>>
>>
>> models.py file:
>>
>> class Video(models.Model):
>> Video_Description= models.CharField(max_length=500)
>> videofile= models.FileField(upload_to='videos/', null=True,
>> verbose_name="")
>> timestamp   = models.DateTimeField(auto_now_add=True)
>>
>> class Meta:
>> ordering = ['-timestamp']
>>
>>
>> def __str__(self):
>> return self.Video_Description + ": " + str(self.id)
>>
>>
>> urls.py file:
>>
>>
>> url(r'^create/$', VideoCreateView.as_view(), name='create')
>>
>>
>> create_view.html :
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>> PFA the image file displaying the page after i selected the file and hit
>> the Upload Video button
>>
>> With Kind Regards
>>
>> Aakash Baranwal
>>
>> --
>> 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/CALr9hQ0iBSOt1tUxXUW06bVBd%2B1Crm-O8_A-tyV01jtGWhS5sw%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/CAKzwNoZBxxjgqchh1UbtK1r_W1fjTYaFg6ASh-q%2BgjFPvTPVaQ%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/CALr9hQ2UX_amyG%3DCaNtc6MuW97M7go26Vxcw-E%3Dbam%3DZcsDA6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Convertingg rendered Model Data in HTML to PDF USING XHTML2PDF

2019-04-18 Thread Matthew Pava
We use Google’s Puppeteer in Node.js.
I use the URL of the HTML page to convert as a GET parameter to the PDF 
generator view.
The PDF generator view then uses subprocess.Popen to run the Node.js script 
that prints that HTML as a PDF page.
As icing on the cake, the user can also automatically print the PDF to a 
printer close by to them on the network.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Irfan Khan
Sent: Thursday, April 18, 2019 9:49 AM
To: Django users
Subject: Convertingg rendered Model Data in HTML to PDF USING XHTML2PDF

hi, all
can any one please guide me how to covert the rendered data from models in html 
to pdf

for example i have developed application and in that implemented search field 
to get the data from the database,till now it now fine but i have used 
xhtml2pdf library to convert
i can see there only some of context passed in views only converting.
please guide me how to implement.

--
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/03530d36-a49f-40ec-b623-dee9138387e7%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/d06d0060aabb4bbaacbd8869032285ee%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Django model field and external SQL query

2019-04-18 Thread aardzhanov
Hello, my friends.

I need to connect SQL query and model field as ManyToManyField.

For example, models.py:

cursor = connections['req'].cursor()

query="""SELECT…."""

cursor.execute(query)

emps = cursor.fetchall()



class test(models.Model)
 name = models.CharField(...)
 ext_field=models.ManyToManyField('emps')


Is it possible?


-- 
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/e810044e-1058-46e5-a930-eb72d709ce91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how to update choices of field in change_view

2019-04-18 Thread richard . wu . 03
hi There,
I have a field named A which has default choices, but when some filed named 
B was changed, i need to update the choices of filed A.
I have tried overried function get_form, formfield_for_choice_filed, none 
of them could update choice of A based on value of filed B.

Any help would be appreciated, 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/ce65f7d7-4e9c-4f98-901a-d11524318cc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I'm going to ask you an editor in django.

2019-04-18 Thread bang
I would like to add editor function in django 
and call up stored document( word, pdf, excel), edit and save. Is there 
a way?
Something like an Apache POI in Java.

-- 
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/1cc8e459-11f4-47d7-a056-117ce1de309a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: File not getting uploaded

2019-04-18 Thread adarsh pandey
Gentle man you have not given enctype=" form/multipartdata" in the form tag
of the HTML file


On Wed, Apr 17, 2019, 12:05 PM Aakash Baranwal 
wrote:

> Hi Everybody,
>
> I am trying to upload a file, but it says "No file chosen", even when I
> have selected the file. However it is getting uploaded when I have logged
> in as as admin and i am uploading it from there.
>
> Kindly help me, thanks in advance.
>
> views.py file:
>
> class VideoCreateView(CreateView):
> form_class = VideoModelForm
> fields = ['Video_Description','videofile']
> template_name = 'deploy/create_view.html'
>
> success_url = "/video/create/"
>
> def form_valid(self, form):
> form.instance.user = self.request.videofile
> return super(VideoCreateView, self).form_valid(form)
>
>
> models.py file:
>
> class Video(models.Model):
> Video_Description= models.CharField(max_length=500)
> videofile= models.FileField(upload_to='videos/', null=True,
> verbose_name="")
> timestamp   = models.DateTimeField(auto_now_add=True)
>
> class Meta:
> ordering = ['-timestamp']
>
>
> def __str__(self):
> return self.Video_Description + ": " + str(self.id)
>
>
> urls.py file:
>
>
> url(r'^create/$', VideoCreateView.as_view(), name='create')
>
>
> create_view.html :
>
> 
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
>
> PFA the image file displaying the page after i selected the file and hit
> the Upload Video button
>
> With Kind Regards
>
> Aakash Baranwal
>
> --
> 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/CALr9hQ0iBSOt1tUxXUW06bVBd%2B1Crm-O8_A-tyV01jtGWhS5sw%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/CAKzwNoZBxxjgqchh1UbtK1r_W1fjTYaFg6ASh-q%2BgjFPvTPVaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django model field and external SQL query

2019-04-18 Thread aardzhanov
Hello, my friends.

I need to add in my model ManyToManyField connected to any sql query

For example, models.py:

cursor = connections['req'].cursor()
query="""SELECT…."""
cursor.execute(query)
emps = cursor.fetchall()



class test(models.Model)
  name = models.CharField(...)
  ext_field=models.ManyToManyField('emps')



Is it possible? 


-- 
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/cfbb6e80-50e3-41b0-96ba-1ae92a5def79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failed to push Django project on github using gitbash

2019-04-18 Thread Joakim Hove
> [...]  and merged also but it was giving same error again and again.

bash% git fetch origin  (assuming your remote is "origin" - which is
typically the default)
bash% git merge origin/master
bash% git push origin master

If this for some reason does not work (I can not understand why it should
not - but anyway) you can always force:

bash% git push -f origin master

The force (-f) will override the protection which is creating trouble for
you - but before doing that; be certain you want to overwrite what is on
the remote!

-- 
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/CALKD1M8tyreNccmg%3DP-xPfo%2BDX94Wmmunit69A%3DqmHFR%2BjR4AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Convertingg rendered Model Data in HTML to PDF USING XHTML2PDF

2019-04-18 Thread Irfan Khan
hi, all
can any one please guide me how to covert the rendered data from models in 
html to pdf 

for example i have developed application and in that implemented search 
field to get the data from the database,till now it now fine but i have 
used xhtml2pdf library to convert 
i can see there only some of context passed in views only converting.
please guide me how to implement.

-- 
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/03530d36-a49f-40ec-b623-dee9138387e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failed to push Django project on github using gitbash

2019-04-18 Thread Mayur Bagul
Hello online judge,

after getting this error i deleted that repository and created it again and 
did same commands in git bash but it was giving same errors.
and i also did google and as you said pull those changes i found similar 
answers on google but it didnt worked.
i pull, fetched, and merged also but it was giving same error again and 
again.

i'm not getting what i should do.

thanks for help judge.

On Thursday, April 18, 2019 at 7:46:04 PM UTC+5:30, OnlineJudge95 wrote:
>
> It means your remote has some changes that are not there in your local so 
> when you are pushing, git is unable to merge those changes.
>
> Try a git pull then local merge and then push. Feel free to ask in case of 
> any queries.
>
> On Thu, Apr 18, 2019, 6:58 PM Mayur Bagul  > wrote:
>
>> Hello Community,
>>
>> im using gitbash to upload my code to github but it giving below error:
>>
>>  ! [rejected]master -> master (non-fast-forward)
>> error: failed to push some refs to '
>> https://github.com/MayurBagul/Weather-Informer.git'
>> hint: Updates were rejected because the tip of your current branch is 
>> behind
>> hint: its remote counterpart. Integrate the remote changes (e.g.
>> hint: 'git pull ...') before pushing again.
>> hint: See the 'Note about fast-forwards' in 'git push --help' for details.
>>
>> i tried to use fetch and merge command but even though it is giving error.
>> please help me to solve this issue.
>>
>> Thanking You,
>> Mayur Bagul.
>>
>> -- 
>> 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...@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/a27866f8-1a92-45b9-80c4-84099df30df5%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/ee22b602-00de-4017-9265-01c1548f51b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failed to push Django project on github using gitbash

2019-04-18 Thread Test Bot
It means your remote has some changes that are not there in your local so
when you are pushing, git is unable to merge those changes.

Try a git pull then local merge and then push. Feel free to ask in case of
any queries.

On Thu, Apr 18, 2019, 6:58 PM Mayur Bagul  wrote:

> Hello Community,
>
> im using gitbash to upload my code to github but it giving below error:
>
>  ! [rejected]master -> master (non-fast-forward)
> error: failed to push some refs to '
> https://github.com/MayurBagul/Weather-Informer.git'
> hint: Updates were rejected because the tip of your current branch is
> behind
> hint: its remote counterpart. Integrate the remote changes (e.g.
> hint: 'git pull ...') before pushing again.
> hint: See the 'Note about fast-forwards' in 'git push --help' for details.
>
> i tried to use fetch and merge command but even though it is giving error.
> please help me to solve this issue.
>
> Thanking You,
> Mayur Bagul.
>
> --
> 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/a27866f8-1a92-45b9-80c4-84099df30df5%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/CAD%3DM5eQGxcJ9M31%3DmRC9e_xMrM7y0X%2BFAzoCy-SD75N%2B9ZbPuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Failed to push Django project on github using gitbash

2019-04-18 Thread Mayur Bagul
Hello Community,

im using gitbash to upload my code to github but it giving below error:

 ! [rejected]master -> master (non-fast-forward)
error: failed to push some refs to '
https://github.com/MayurBagul/Weather-Informer.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

i tried to use fetch and merge command but even though it is giving error.
please help me to solve this issue.

Thanking You,
Mayur Bagul.

-- 
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/a27866f8-1a92-45b9-80c4-84099df30df5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: compute model field by related field

2019-04-18 Thread omar ahmed
thank you for response , derek
but how can i increment 'win' 'lost' or 'draw' Club fields by 'winner' 
Match field

On Wednesday, April 17, 2019 at 3:26:22 PM UTC+2, Derek wrote:
>
> 1. Add a "winner" field to your Match
> 2. Implement a post_save  signal for the Match model that updates the 
> "won" or "lost" fields for each Club in the match (simple if/then logic 
> based on winner).
>
> PS I think the default values for "won" and "lost" for a Club should be 
> "0" and not "1".
>
> On Tuesday, 16 April 2019 20:19:34 UTC+2, omar ahmed wrote:
>>
>> hello ... i have two models "Club" class and "Match" class and it has 
>> foreign key to Club
>> now i want to increment "won" field (or draw or lost) in "Club" class by 
>> "score_local" and "score_visitor" in "Match" class ..
>> how can i do this
>> class Club(models.Model):
>> name = models.CharField(max_length=100)
>> won = models.IntegerField(default=1)
>> draw = models.IntegerField(default=1)
>> lost = models.IntegerField()
>> goal_for = models.IntegerField()
>> goal_against = models.IntegerField()
>>
>>
>> class Match(models.Model):
>> play_date = models.DateTimeField('play date')
>> club_visitor = models.ForeignKey(Club, on_delete=models.CASCADE, 
>> related_name='match_club_visitor')
>> club_local = models.ForeignKey(Club, on_delete=models.CASCADE, 
>> related_name='match_club_local')
>> score_visitor = models.IntegerField()
>> score_local = models.IntegerField()
>>
>

-- 
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/30a83974-7115-4617-9da2-e32937753cca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Slug not working

2019-04-18 Thread fofa Zu
idk what is the problem but i liked your app it is a tutorial if is it may
i get the link thanks

‫في الخميس، 18 أبريل 2019 في 12:41 م تمت كتابة ما يلي بواسطة ‪Aakash
Baranwal‬‏ <‪baakash1...@gmail.com‬‏>:‬

> Hi Everybody,
>
> This is my models.py file:
>
> from django.db.models.signals import pre_save
> from django.utils.text import slugify
> from django.db import models
> from django.conf import settings
> from django import forms
>
> # Create your models here.
> class Video(models.Model):
> Video_Description= models.CharField(max_length=500)
> slug = models.SlugField(unique=True)
>
> videofile= models.FileField(upload_to='videos/', null=True,
> verbose_name="")
> timestamp   = models.DateTimeField(auto_now_add=True)
>
> class Meta:
> ordering = ['-timestamp']
>
> def get_absolute_url(self):
> return reverse ("video:detail", kwargs={"slug":self.slug})
>
>
> def __str__(self):
> return self.Video_Description + ": " + str(self.id)
>
>
> def create_slug(instance, new_slug=None):
> slug = slugify(instance.Video_Description)
> if new_slug is not None:
> slug = new_slug
> qs = Video.objects.filter(slug=slug).order_by("-id")
> exists = qs.exists()
> if exists:
> new_slug = "%s-%s" %(slug, qs.first().id)
> return create_slug(instance, slug=new_slug)
> return slug
>
>
> def pre_save_video_receiver(sender, instance, *args, **kwargs):
> if not instance.slug:
> instance.slug = create_slug(instance)
>
> pre_save.connect(pre_save_video_receiver, sender=Video)
>
>
> The problem I am facing is, slug field appears in the admin and
> unfortunately in the create page where I am uploading the videos.
>
> However, in the url it is not coming, also in the create page, I have to
> enter the slug manually. I want it to take whatever input was given to t
> video_description in the models.py file and it should disappear from the
> create post page.
>
> Kindly help me.
>
> With Kind Regards
> Aakash Baranwal
>
> --
> 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/CALr9hQ2hsoqjBaN7g5%2B6rqkEyRYrfDMHPan8tSvHG%3DQjhnfRbw%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/CAPkS-C57EYh-PS56ZUAM0wcuvUoZs5Lu_71x5fRWwoq2tM0uiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why my email goes to spam?

2019-04-18 Thread Kasper Laudrup

Hi Mohammad,

On 18/04/2019 10.05, Mohammad Etemaddar wrote:
Hello. I'm working on a bussiness website. I send invitation and also 
confirm emails by django-allauth.

Invitation and allauth emails go to spam box.
I don't know what is the problem?
How can I prevent emails going to spam?



This is hardly related to Django, but anyway...

There is really no standard way to detect spam, for good reasons, so it 
really depends on the mail server receiving the mail.


The first thing I would do would be to look at the headers for the mail 
flagged as spam. Some spam scanners (eg. spamassasin) sets some 
additional headers with scores it has used to determine the mail is 
spam. You could use that to see what might be the cause for this mail 
being flagged as spam.


It could be something as simple as the mail only having HTML content 
which is not only a violation of the RFC but also one of the seven 
deadly sins :-)


Apart from that, you should ensure that the host you are using to send 
the mail is configured correctly. That potentially requires messing a 
lot around with mail server configuration. Specifically, you should look 
into things like DKIM, SPF and DMARC.


Also, make sure that the host sending the mail has a static IP. I know 
that some mail servers (eg. hotmail/outlook365/whatever it's called 
these days) always flags mail sent from a dynamic IP as spam, so make 
sure you can get a static IP from your hosting provider (or change your 
hosting provider to someone who will give you that).


If you can provide the full content (including all headers) of the mail 
being flagged as spam, feel free to post it and I'll try to have a look.


Hope that helps a bit.

Kind regards,

Kasper Laudrup

--
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/b82a7852-0256-a8ff-bfc1-0eea2576c1e2%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Why my email goes to spam?

2019-04-18 Thread Mohammad Etemaddar
Hello. I'm working on a bussiness website. I send invitation and also 
confirm emails by django-allauth.
Invitation and allauth emails go to spam box.
I don't know what is the problem?
How can I prevent emails going to spam?

-- 
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/2ad0d969-1d04-4c94-8aa7-671ef5915057%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.